Results 1 to 6 of 6
- 07-15-2011, 05:56 PM #1
Senior Member
- Join Date
- Jul 2011
- Posts
- 100
- Rep Power
- 0
My "form" is 9X uglier than a bag of butts (How to restrict the width of JTextField?)
I'm using BorderLayout on my frame and BoxLayout on my panel:
This is working well enough, except that my JTextFields are the entire width of the panel (about 10X wider than they need to be). How can I get them to straighten up and fly right?Java Code:frame.getContentPane().add(BorderLayout.CENTER, mainPanel); mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.PAGE_AXIS));
Similarly, how can I add some "padding" or margins to my components, so that they don't scrunch right up against each other?
- 07-15-2011, 06:39 PM #2
Member
- Join Date
- May 2011
- Posts
- 56
- Rep Power
- 0
Try two things:
andJava Code:textField.setSize(int width, int height);
Java Code:textField.setResizable(false);
- 07-15-2011, 07:44 PM #3
Senior Member
- Join Date
- Jul 2011
- Posts
- 100
- Rep Power
- 0
- 07-15-2011, 09:34 PM #4
Senior Member
- Join Date
- Jul 2011
- Posts
- 100
- Rep Power
- 0
The only thing I've found that does any good is to provide some space around the JLabels:
Java Code:lblIPAddr.setPreferredSize(new Dimension(32, 32));
-
I strongly disagree with asifzbaig's advice. The key is to use the right combinations of nested containers using the best layout managers for the situation at hand. To help you best I suggest you post three things:
- An sscce that shows your current gui (please read the link).
- An image of the current GUI
- An image of the desired GUI layout
With this we will be able to get a much better grasp of just what you're trying to do and how to help you achieve it.
-
You might look at using GridBagLayout, for example: GridBagLayout example
Or even MiGLayout, although you'd have to download that one.
Similar Threads
-
Not Getting "SourceURL" When content copied form browser using Clipboard java
By Anuj Oscar in forum AWT / SwingReplies: 5Last Post: 07-13-2011, 02:25 PM -
JTable vs JTextField - which to use for creating "Search" screen
By tashimoto in forum AWT / SwingReplies: 6Last Post: 11-19-2010, 07:44 PM -
How to change my form design from "metal" to "nimbus" in Netbeans 6.7.1?
By mlibot in forum New To JavaReplies: 1Last Post: 01-21-2010, 09:20 AM -
the dollar sign "$", prints like any other normal char in java like "a" or "*" ?
By lse123 in forum New To JavaReplies: 1Last Post: 10-20-2008, 07:35 AM -
"Displayed tab width" problem...
By Petike in forum EclipseReplies: 0Last Post: 03-17-2008, 09:39 PM


3Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks