I've looked through the swing tutorials and i do not see what i'm doing wrong. Why is nothing happening when i click on the jmenuitem?
my first class:
import javax.swing.*;
public class WordProcess{
/*TODO: make program end on close
*/
public static void main(String[] args) {
MainFrame frame = new MainFrame("Word Processor", 10000, 10000);
}
}
second class:
import javax.swing.*;
public class MainFrame extends JFrame {
JMenuBar menubar = new JMenuBar();
public MainFrame(String name, int x, int y) {
setTitle(name);
setSize(x, y);
setVisible(true);
setJMenuBar(menubar);
//creates file menu and adds to menubar
//TODO populate with JMenuItems
JMenu filemenu = new JMenu("file");
filemenu.setVisible(true);
menubar.add(filemenu);
buttonnew buttonnew = new buttonnew("new");
buttonnew.setVisible(true);
filemenu.add(buttonnew);
}
}
and third class:
import javax.swing.*;
import java.awt.event.*;
public class buttonnew extends JMenuItem implements ActionListener{
buttonnew(String s) {
super();
super.setText(s);
addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent ae) {
JFrame newframe = new JFrame("sup");
}
}