• Post Reply Bookmark Topic Watch Topic
  • New Topic

Which layout for JTextField  RSS feed

 
dav mrazek
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, i would like to have my JTextField to fill my panel whatever size the panel is. Whenever i maximise or minimize the JFrame my JTextField should adapt to it.
Thank you for help.
 
dav mrazek
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that with the GridBagLayout it must be possible so here is what i tried, but all component are in the center and my JTextField is small and doesnt spread like i want.



The TextFieldDemo in sun tutorial does what i want but they are using the SpringLayout and GroupLayout in their exemples and they are too complicated to use without an IDE.
How to use TextField
 
Rob Spoor
Sheriff
Posts: 20895
81
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try BorderLayout, and add the component with BorderLayout.CENTER as the constraints.
 
dav mrazek
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello thank you for replying.
Sorry but it doesnt help much, to use a BorderLayout, the JTextField doesnt want to spread.

 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
all component are in the center and my JTextField is small and doesnt spread like i want.
It behaved the way you wanted when I ran your code.
I made some suggestions in your code.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by dav mrazek:
Hello thank you for replying.
Sorry but it doesnt help much, to use a BorderLayout, the JTextField doesnt want to spread.


Quite probably, the JTextFile *does* spread over the whole panel, it's just that the *panel* doesn't spread over whatever it is added to.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!