View Single Post
  #3 (permalink)  
Old 07-08-2007, 12:54 AM
Heather Heather is offline
Senior Member
 
Join Date: Jun 2007
Posts: 164
Heather is on a distinguished road
I think that the problem is in init(), since Client() is a JApplet not Jframe

I send you a code that works, analyze it
Code:
public class AppletTest extends JApplet { JFrame j = null; public void init() { j = new MyFrame(); j.setVisible(true); } } class MyFrame extends JFrame implements ActionListener { public static JMenuBar menuBar = new JMenuBar(); public static JMenu file = new JMenu("File"); public static JMenuItem home = new JMenuItem("Main Page"); public static JPanel panel = new JPanel(new BorderLayout()); public static JLabel intro = new JLabel("Welcome."); public MyFrame() { setLayout(new BorderLayout()); setJMenuBar(menuBar); menuBar.add(file); file.add(home); home.addActionListener(this); panel.add(intro); pack(); } public void actionPerformed(ActionEvent e) { Object s = e.getSource(); if (s == home) { intro.setText("Once again, welcome!"); } } }
Reply With Quote