import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Programm extends JFrame {
private JMenuBar menu = new JMenuBar();
private JMenu file = new JMenu("Datei");
private JMenuItem open = new JMenuItem("Öffnen");
private JMenuItem save = new JMenuItem("Speichern");
private JMenuItem saveAs = new JMenuItem("Speichern als");
private JMenuItem exit = new JMenuItem("Beenden");
private JMenu help = new JMenu("Hilfe");
private JMenuItem vInfo = new JMenuItem("Info");
private JMenuItem helpsec = new JMenuItem("Hilfe");
private JToolBar toolmenu = new JToolBar();
private JButton toolSave = new JButton("picS");
private JButton toolOpen = new JButton("picO");
private JTextArea textBlock = new JTextArea();
public LessonDoc(String title) {
// Frame-Initialisierung
super(title);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) { System.exit(0); }
});
Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
int frameWidth = d.width - 80;
int frameHeight = d.height - 80;
setSize(frameWidth, frameHeight);
int x = 30; //(d.width - getSize().width) / 2;
int y = 30; //(d.height - getSize().height) / 2 ;
setLocation(x, y);
Container cp = getContentPane();
cp.setLayout(null);
file.add(open);
open.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(null, "Hier erscheint der Öffnen-Dialog");
}
});
file.add(save);
save.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(null, "Hier erscheint der Speichern-Dialog");
}
});
file.add(saveAs);
saveAs.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(null, "Hier erscheint der SpeichernAls-Dialog");
}
});
exit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(null, "Programm wird beendet");
System.exit(0);
}
});
file.add(exit);
menu.add(file);
helpsec.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(null, "Hier erscheint der Hilfe-Dialog");
}
});
help.add(helpsec);
vInfo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(null, "Hier erscheint der Info-Dialog");
}
});
help.add(vInfo);
menu.add(help);
setJMenuBar(menu);
toolmenu.add(toolSave);
toolSave.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(null, "xyz");
}
});
toolmenu.add(toolOpen);
toolOpen.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
JOptionPane.showMessageDialog(null, "xyz");
}
});
cp.add(toolmenu);
setResizable(true);
setVisible(true);
}
}