Reputation: 8397
Please, is there any option in MigLayout to stretch some element 100% of the JPanel size? Like when you add JButton into JFrame using BorderLayout? Thanks.
Code:
Jframe frame = new JFrame();
frame.setLayout(new MigLayout());
JPanel mainPanel = new JPanel(new MigLayout());
mainPanel.add(new JButon());
I want the JButton to fill entire area of JFrame. JButton is only reference object I used to explain what I want to achieve.
Upvotes: 0
Views: 830
Reputation: 2116
You can use "grow" for this. This should do same as border layout adding in centre.
See miglayout cheat sheet below
http://migcalendar.com/miglayout/cheatsheet.html
public class test {
public static void main(String[] args) {
JFrame frame = new JFrame();
JPanel mainPanel = new JPanel(new MigLayout());
mainPanel.add(new JButton(), "dock center");
// or
//mainPanel.add(new JButton(), "dock center");
frame.getContentPane().add(mainPanel);
frame.setSize(200,200);
frame.setVisible(true);
}
}
Upvotes: 2