aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to avoid getting ridiculously huge textboxes? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to avoid getting ridiculously huge textboxes?" Watch "How to avoid getting ridiculously huge textboxes?" New topic
Author

How to avoid getting ridiculously huge textboxes?

Besjamain Greenaway
Ranch Hand

Joined: Dec 21, 2007
Posts: 45
I want it to look the same except that I want the textboxes to be not so high. How is this done?



[Thumbnail for teGroteTextBoxen.jpg]

K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2531
    
    8

You are using GridLayout?? If so add a panel instead of adding the text field directly to the window.


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5 OCPBCD5
Besjamain Greenaway
Ranch Hand

Joined: Dec 21, 2007
Posts: 45
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

Joined: Oct 13, 2005
Posts: 39436
    
  28
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

Joined: Sep 13, 2007
Posts: 2531
    
    8

I mean something like this:

Besjamain Greenaway
Ranch Hand

Joined: Dec 21, 2007
Posts: 45
@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

Joined: Sep 13, 2007
Posts: 2531
    
    8

The reason mine works is I used a tempPanel for the text field instead of adding the field directly to the grid panel.
 
 
subject: How to avoid getting ridiculously huge textboxes?