import javax.swing.*; import java.awt.*; import java.awt.event.*; //import GUI.class; public class GUI implements ActionListener,ItemListener { JEditorPane pane; public JMenuBar createMenuBar() { //menu stuff JMenuBar menuBar = new JMenuBar(); //setMenuBar(menuBar); JMenu menuFile = new JMenu("FILE"); menuBar.add(menuFile); JMenu menuEdit = new JMenu("EDIT"); JMenuItem menuEditPreferences = new JMenuItem("Preferences"); menuEditPreferences.addActionListener(this); menuEdit.add(menuEditPreferences); menuBar.add(menuEdit); //menuitemExit = new JMenuItem("QUIT"); //menuFile.add(menuitemExit); return menuBar; } public void actionPerformed(ActionEvent e) { String source = e.toString(); String s = "Action event detected: "+ e.getActionCommand(); pane.setText(pane.getText() + s + "\n"); //output.append(s + newline); //output.setCaretPosition(output.getDocument().getLength()); } public void itemStateChanged(ItemEvent e) { JMenuItem source = (JMenuItem)(e.getSource()); String s = "Action event detected: "+ source.getText(); pane.setText(pane.getText() + s + "\n"); //output.append(s + newline); //output.setCaretPosition(output.getDocument().getLength()); } public Container createContentPane() { //Create the content-pane-to-be. JPanel contentPane = new JPanel(new BorderLayout()); contentPane.setOpaque(true); pane = new JEditorPane(); pane.setEditable(false); //frame.getContentPane().add(new JScrollPane(pane), "Center"); //Add the text area to the content pane. contentPane.add(pane, BorderLayout.CENTER); return contentPane; } }