• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to avoid getting ridiculously huge textboxes?

 
Besjamain Greenaway
Ranch Hand
Posts: 45
  • 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
[Thumbnail for teGroteTextBoxen.jpg]
Picture of my screen with huuuge textboxes...
 
K. Tsang
Bartender
Posts: 3508
16
Android Java
  • 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
  • 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: 49813
69
  • 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: 3508
16
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I mean something like this:

 
Besjamain Greenaway
Ranch Hand
Posts: 45
  • 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: 3508
16
Android Java
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic