Results 1 to 6 of 6
Thread: Simple MigLayout Question
- 12-22-2012, 08:26 PM #1
Member
- Join Date
- Dec 2012
- Posts
- 3
- Rep Power
- 0
Simple MigLayout Question
I am just starting out with MigLayout and im having some trouble with getting the frame to autosize. I don't really want to define a size by doing something like frame.setSize(500,500) but when I remove this, the frame size is basically nothing and I can't see my application unless I resize the window with my mouse. Here is my basic example code below and a screen capture of what I see when running this.

Java Code:import javax.swing.*; import net.miginfocom.swing.MigLayout; public class GUI2 { public static void main(String[] args) { new GUI2().buildGUI(); } public void buildGUI() { JFrame frame = new JFrame(); JPanel panel = new JPanel(new MigLayout()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(panel); // frame.setSize(500,500); frame.setVisible(true); JLabel firstNameLabel = new JLabel("First Name"); JLabel lastNameLabel = new JLabel("Last Name"); JLabel addressLabel = new JLabel("Address"); JTextField firstNameTextField = new JTextField(100); JTextField lastNameTextField = new JTextField(100); JTextField addressTextField = new JTextField(); panel.add(firstNameLabel); panel.add(firstNameTextField); panel.add(lastNameLabel); panel.add(lastNameTextField, "wrap"); panel.add(addressLabel); panel.add(addressTextField, "span, grow"); } }
- 12-22-2012, 10:36 PM #2
Re: Simple MigLayout Question
Moved from New to Java
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 12-22-2012, 10:38 PM #3
Re: Simple MigLayout Question
1. Add all content
2. Call pack()
3. Set the frame visible
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 12-22-2012, 10:39 PM #4
Re: Simple MigLayout Question
Cross posted
Java using MigLayout Size - Stack Overflow
Any more?
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 12-22-2012, 11:31 PM #5
Member
- Join Date
- Dec 2012
- Posts
- 3
- Rep Power
- 0
- 12-22-2012, 11:31 PM #6
Member
- Join Date
- Dec 2012
- Posts
- 3
- Rep Power
- 0
Similar Threads
-
simple question
By jwl in forum New To JavaReplies: 4Last Post: 08-05-2012, 02:31 AM -
Problem with MigLayout (Added Components don't appear on screen)
By Boreeas in forum AWT / SwingReplies: 0Last Post: 02-19-2012, 06:53 PM -
Simple question...
By Onyx in forum New To JavaReplies: 10Last Post: 08-10-2011, 10:44 PM -
Please help. Simple question
By owencain in forum New To JavaReplies: 14Last Post: 06-16-2011, 01:07 AM -
Simple Question
By barusk in forum NetworkingReplies: 13Last Post: 03-04-2009, 07:33 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
.gif)

Bookmarks