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 01-24-2008, 10:40 PM
Member
 
Join Date: Dec 2007
Posts: 4
vassil_zorev is on a distinguished road
JFrame problem
Hey guys,
to the point:
I've got two "test classes" - one creates a JFrame instance and the other extends the JFrame class. They do exactly the same thing. The problem is one of them doesn't work. Now here are the classes:

Code:
public class GameTest { /** * Creates a new instance of GameTest */ public GameTest() { } public void PlayAGame() { JFrame myFrame = new JFrame("Beginner Mode:"); BeginnerMode panel = new BeginnerMode(); myFrame.setSize(256,256); myFrame.setDefaultCloseOperation(myFrame.EXIT_ON_CLOSE); myFrame.getContentPane().add(panel); panel.PlayAGame(); myFrame.pack(); myFrame.setVisible(true); } public static void main(String ar[]){ GameTest myGame = new GameTest(); myGame.PlayAGame(); } }

Code:
public class Navigator extends javax.swing.JFrame { /** Creates new form Navigator */ public Navigator() { initComponents(); } public void PlayAGame() { BeginnerMode panel = new BeginnerMode(); this.getContentPane().add(panel); panel.PlayAGame(); this.pack(); this.setVisible(true); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ // <editor-fold defaultstate="collapsed" desc=" Generated Code "> private void initComponents() { setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 400, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 300, Short.MAX_VALUE) ); pack(); }// </editor-fold> /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { Navigator gameStart = new Navigator(); gameStart.PlayAGame(); } }); }
The second one doesn't work. What might be the reason? The problem is that the BeginnerMode panel doesn't display itself in the Navigator frame...
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-25-2008, 03:53 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 840
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
Not having the BeginnerMode class, I had to comment out those lines where that applies. Once I did that, they both worked for me. Would you mind posting the missing class? I seem to recall that you might need a method similar to ... alwaysOnTop or to that effect.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
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
Add an image to JFrame Eranga AWT / Swing 2 03-14-2008 09:24 AM
Picture in a JFrame problem saytri New To Java 3 01-12-2008 10:44 AM
JFrame problem saytri New To Java 6 01-11-2008 06:12 PM
How to close a JFrame valery New To Java 1 08-06-2007 06:33 PM
Help with JFrame Albert AWT / Swing 2 07-04-2007 05:44 AM


All times are GMT +3. The time now is 08:46 PM.


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