Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-05-2007, 07:24 PM
Member
 
Join Date: Jul 2007
Posts: 2
JToolTip is on a distinguished road
Why isn't this showing?
I don't see whats wrong with this code. It looks fine, but the applet on the website doesn't show the gui at all

Code:
import java.applet.*; import java.awt.*; import java.awt.event.*; import java.io.*; import java.net.*; import javax.swing.*; public class Client extends JApplet implements ActionListener { public void init() { setContentPane(new Client()); } 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 Client() { setLayout(new BorderLayout()); setJMenuBar(menuBar); menuBar.add(file); file.add(home); home.addActionListener(this); setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); panel.add(intro); } public void actionPerformed(ActionEvent e) { Object s = e.getSource(); if(s == home) { intro.setText("Once again, welcome!"); } } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-05-2007, 07:53 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
I guess it will give you an exception if it does not show you anything. Try opening java console and see the exception.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 07-08-2007, 12:54 AM
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!"); } } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help showing text in JTextArea GuyFawkes AWT / Swing 3 05-05-2008 10:19 AM
Error Messages Not Showing Up nvidia Web Frameworks 0 04-07-2008 11:41 PM
showing the servlets api docs in netbeans truegilly New To Java 0 12-05-2007 10:14 PM
Assert - not showing any msg on console ravian New To Java 0 11-16-2007 04:20 PM
Showing Images with J2ME luisarca CLDC and MIDP 0 06-18-2007 11:39 AM


All times are GMT +3. The time now is 05:39 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org