Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Won't build a Jframe  RSS feed

 
Bernie Bonn
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a simple Java program (tutorial actually, yes I'm new) It compiles fine. However when it comes to this line
dlframe = new JFrame(); It stalls. I have imported javax.swing. I am using j2sdk1.4.1_02. Any ideas. I can give more info if needed.
Thanks for any help,
Bernie
 
Dorothy Finkel-Laverty
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If, by "stalls", you mean that it seems to think it is done, but you don't see anything, try this - when you instantiate a JFrame, it is in RAM only. By default, all JFrames are invisible. You'll need to do a frame.setVisible(true).
If you don't have anything in the JFrame yet, it will be very, very tiny - you may want to use the setSize() method to establish a size, until you've added components into it.
 
Dirk Schreckmann
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch, Bernie Bonn!
How do you know it "stalls" at that line?
Feel free to post necessary example code (surrounded with the [code] and [/code] UBB tags).
 
Bernie Bonn
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dirk Schreckmann:
Welcome to JavaRanch, Bernie Bonn!
How do you know it "stalls" at that line?
Feel free to post necessary example code (surrounded with the [code] and [/code] UBB tags).

I placed a couple of println's in there. So when i run the prgram (command line from DOS prompt) I see the echo "Building a Frame" right before the line dlframe = new JFrame();
executes. Then it just hangs.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try posting the code so we can see.
 
Bernie Bonn
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
After your dlframe = new JFrame() line add the following:
dlframe.setBounds(10, 10, 100, 100);
dlframe.setVisible(true);
In fact, I think Dorothy already pointed the setVisible out to you. Are you reading the other posts?
I also noticed that you have omitted your main method from the code you posted. Any particular reason?
[ March 17, 2003: Message edited by: Gregg Bolinger ]
 
Bernie Bonn
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry, I did see her post and tried that approach. i will post the whole class, I just posted the part it was executing through before. When I run it gets to the point where it prints out "Creating a Frame" then quits.
 
Gregg Bolinger
Ranch Hand
Posts: 15304
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I ran your code and it worked just fine. What JDK version and was OS are you running?
 
Bernie Bonn
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok, i thought that might happen. I am running 1.4.1_02 on Windows 2000. I had a feeling ( because I tried copying the code right from the tutorial) that it was something other than the code. I wonder if something is goofy with my video card. Thanks for all your help anyway,
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!