This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to avoid getting ridiculously huge textboxes?

 
Besjamain Greenaway
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I want it to look the same except that I want the textboxes to be not so high. How is this done?
teGroteTextBoxen.jpg
Picture of my screen with huuuge textboxes...
[Thumbnail for teGroteTextBoxen.jpg]
 
K. Tsang
Bartender
Posts: 3222
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are using GridLayout?? If so add a panel instead of adding the text field directly to the window.
 
Besjamain Greenaway
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For now I added a bunch of labels with empty strings to fill the whole thing up. I add a panel to the contentPane, in which I add a panel for the labels, and one for the textfields. Here's my code:
 
Campbell Ritchie
Sheriff
Pie
Posts: 47216
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may need another layout. You could try GridBag, with insets round the JTextFields, or Google for MigLayout.
You may be able to set sizes on the JTextFields; they probably have several methods like setXXXSize.
 
K. Tsang
Bartender
Posts: 3222
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean something like this:

 
Besjamain Greenaway
Ranch Hand
Posts: 45
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@k. tsang

I adjusted and compiled the code you posted, and it works. Is it because you left the default layout for JPanel instead of giving it a GridLayout? Maybe I have to fiddle some more with that and see what works and what not...

@Campbell Ritchie

I will look for what you suggested.

Thanks!
 
K. Tsang
Bartender
Posts: 3222
12
Android Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The reason mine works is I used a tempPanel for the text field instead of adding the field directly to the grid panel.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic