public class Main extends JFrame implements ActionListener, WindowListener
{
JEditorPane pane;
JPanel panel;
TextField t;
Button s,d;
public static void main(String args[] )
{
Main f = new Main();
f.setSize(500, 300);
f.setLocation(250, 200);
f.setResizable(false);
f.setTitle("Hilfe");
f.setVisible(true);
f.show();
}
public Main()
{
Calendar cal = Calendar.getInstance();
SimpleDateFormat formater = new SimpleDateFormat();
MenuBar hauptMenue = new MenuBar();
Menu menue1 = new Menu("Einführung");
Menu menue2 = new Menu("Programmbedienung");
Menu menue3 = new Menu("Installation");
Menu menue4 = new Menu("Suchen");
Menu menue5 = new Menu( formater.format(cal.getTime()) );
menue1.add("Einführung");
menue1.addSeparator(); //grenze
menue2.add("Menu1");
menue2.add("Menu2");
menue2.add("Menu3");
menue2.addSeparator(); //grenze
menue3.add("Menu4");
menue3.add("Menu5");
menue3.add("Menu6");
menue3.addSeparator();//grenze
menue4.add("Suchen");
menue4.add("beenden");
menue4.addSeparator();//grenze
hauptMenue.add(menue1);
hauptMenue.add(menue2);
hauptMenue.add(menue3);
hauptMenue.setHelpMenu(menue4);
hauptMenue.add(menue5);
setMenuBar(hauptMenue);
menue1.addActionListener(this);
menue2.addActionListener(this);
menue3.addActionListener(this);
menue4.addActionListener(this);
menue5.addActionListener(this);
addWindowListener(this);
this.pane = new JEditorPane("text/html","<html><body><head></head>
<center>" +
"[img]H:/java/üben/simcoat/logo.jpg[/img]" +
"
<font face='Arial' size='22' Color='green'>SIMCOAT Hilfe</font>
" +
"
Version: 0.1</center>
</body></html>");
this.pane.setVisible(true);
getContentPane().add(pane); //Logo anzeigen
this.panel = new JPanel();
this.panel.setVisible(false);
getContentPane().add(panel); //Panel für suchen
JScrollPane scrollPane = new JScrollPane(pane);
add(scrollPane, BorderLayout.CENTER);
}
public void actionPerformed(ActionEvent evt)
{
if (evt.getActionCommand().equals(" Löschen "))
{
t.setText(" ");
}
if (evt.getActionCommand().equals(" Suchen "))
{
String inhalt = t.getText(); ------------------------>NullPointerException!!! Aber warum?????
if (inhalt.length() == 0)
{
/*Frame dia = new Frame();
dia.setSize(200,100);
dia.setLocation(200,150);
dia.setTitle("Meldung");
dia.show();*/
System.out.println("es steht nichts drine");
}
else
{
System.out.println("es steht was drine");
}
}
//suchen();
if (evt.getSource() instanceof MenuItem)
{
String menuAdd = evt.getActionCommand();
System.out.println(menuAdd);
if (menuAdd == "beenden")
{
System.exit(0);
}//----------------------------------------------------------------
//Einlesen Html-Seiten
else if(menuAdd.equals(" Menu1 "))
{
bauteilverarbeitung();
}//----------------------------------------------------------------
//nächste Seite
else if(menuAdd.equals("Menu2"))
{
einstellung();
}//---------------------------------------------------------------
//nächste Seite
else if(menuAdd.equals("Menu3"))
{
ergebnissdarstellung();
}//----------------------------------------------------------------
//nächste Seite
else if(menuAdd.equals("Menu4"))
{
vorraussetzung();
}//----------------------------------------------------------------
//nächste Seite
else if(menuAdd.equals("Menu6"))
{
installation();
}//----------------------------------------------------------------
//nächste Seite
else if(menuAdd.equals("Menu5"))
{
javaD();
}//----------------------------------------------------------------
else if(menuAdd.equals("Einführung"))
{
einfuhrung();
}//----------------------------------------------------------------
//<<<<<<Suchformular
else if(menuAdd.equals("Suchen"))
{
suchenformular();
}//----------------------------------------------------------------
else
{
String htmlContent = "<html><body>" + menuAdd + "<body></html>";
//this.text.setText(htmlContent);
this.pane.setText(htmlContent);
}
}
}
public void windowClosing(WindowEvent evt)
{
System.exit(0);
}
public void windowOpened(WindowEvent evt){}
public void windowIconified(WindowEvent evt){}
public void windowDeiconified(WindowEvent evt){}
public void windowClosed(WindowEvent evt){}
public void windowActivated(WindowEvent evt){}
public void windowDeactivated(WindowEvent evt){}
private void bauteilverarbeitung() {
try {
this.panel.setVisible(false);
this.pane.setVisible(true);
this.pane.setPage("file:///H:/java/üben/simcoat/bauteilverarbeitung.html");
} catch (IOException ex) {
ex.printStackTrace();
}
}
private void einstellung() {
try {
this.panel.setVisible(false);
this.pane.setVisible(true);
this.pane.setPage("file:///H:/java/üben/simcoat/einstellung.html");
} catch (IOException ex) {
ex.printStackTrace();
}
}
private void ergebnissdarstellung() {
try {
this.panel.setVisible(false);
this.pane.setVisible(true);
this.pane.setPage("file:///H:/java/üben/simcoat/ergebnissdarstellung.html");
} catch (IOException ex) {
ex.printStackTrace();
}
}
private void vorraussetzung() {
try {
this.panel.setVisible(false);
this.pane.setVisible(true);
this.pane.setPage("file:///H:/java/üben/simcoat/vorraussetzung.html");
} catch (IOException ex) {
ex.printStackTrace();
}
}
private void installation() {
try {
this.panel.setVisible(false);
this.pane.setVisible(true);
this.pane.setPage("file:///H:/java/üben/simcoat/installation_java.html");
} catch (IOException ex) {
ex.printStackTrace();
}
}
private void javaD() {
try {
this.panel.setVisible(false);
this.pane.setVisible(true);
this.pane.setPage("file:///H:/java/üben/simcoat/install_java_3d.html");
} catch (IOException ex) {
ex.printStackTrace();
}
}
private void einfuhrung() {
try {
this.panel.setVisible(false);
this.pane.setVisible(true);
this.pane.setPage("file:///H:/java/üben/simcoat/Einfuhrung.html");
} catch (IOException ex) {
ex.printStackTrace();
}
}
private void suchenformular() {
panel.setLayout(null);
this.pane.setVisible(false);
this.panel.setVisible(true);
Button s = new Button (" Suchen ");
s.setBounds(200,50,50,25);
s.setForeground(Color.BLUE);
s.setBackground(Color.WHITE);
s.addActionListener(this);
this.panel.add(s);
Button d = new Button (" Löschen ");
d.setBounds(250,50,50,25);
d.setForeground(Color.ORANGE);
d.setBackground(Color.WHITE);
d.addActionListener(this);
this.panel.add(d);
Label l = new Label ("Search Word: ");
l.setBounds(100,30,100,15);
this.panel.add(l);
TextField t = new TextField();
t.setBounds(200,30,200,20);
t.addActionListener(this);
this.panel.add(t);
}
}