Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JFrame JPanel JDesktopPane

 
Mwenya Chongo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
I am working on some swing components. What am trying to do is to create a Jframe and this Jframe will take to size of the computer screen. In this Jframe I want to add the JPanel which has a fixed width and the JDesktopPane to take up the remaining Jframe size. So the Jframe size will be variable depending on the screen of the computer it running on. Can this work? If so how can I do it?



 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you set the frame to full screen
give your panel a preferredSize - the width you want, height can be any number
add the panel to the frame's contentPane at BorderLayout.EAST or WEST (depends on which side you want the panel)
add the desktopPanel to the frame's contentPane at BorderLayout.CENTER

basically, the panel will get the width it wants, height will be determined by screen size and
desktopPane will get what's left over
 
Mwenya Chongo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot that worked perfect.

I have another issue. How can I force the screen to load fast. I am experiencing a noticeable delay in the loading of the components an at time do not load at all, all I see is the JFrame. Is there anything I can do about that?
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when do you set the frame visible:
before or after adding the components?
 
Mwenya Chongo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I set the set the frame visible before adding the components
 
Darryl Burke
Bartender
Posts: 5132
11
Java Netbeans IDE Opera
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try changing that.
 
Mwenya Chongo
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much, I will try that.

Do you have any code that compares time and executes an event when the two times are equivalent?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic