Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Fixed Sizes and positions  RSS feed

 
Eddie Long
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm a newbie to SWING programming so bear with me if these are simple questions...
1. Is it possible to ensure that a screen can't be resized? How can you do this?
2. How do you make sure that a textfield is not stays in the same position and has the same size even if the window is resized
Regards
 
Joe Ess
Bartender
Posts: 9429
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Eddie Long:

1. Is it possible to ensure that a screen can't be resized? How can you do this?

If by "screen" you mean a javax.swing.JFrame or java.awt.Frame, you invoke setResizable(false).


2. How do you make sure that a textfield is not stays in the same position and has the same size even if the window is resized

That's a bit more complex. Java uses Layout Managers to size and arrange components when a GUI's size changes. Your choice of layout manager depends on what widgets you are using and you want to arrange them. Check out the Java Tutorial on
Laying Out Components.
 
Eddie Long
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot for the set.resizable(false). I got the layout ok by doing nesting a few JPanels and it seem to work. A bit like using a poor mans gridbag layout.
Ciao
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!