Note that there are some explanatory texts on larger screens.

plurals
  1. POMigLayout - Need help on how to use the dock parameters (or need an alternative)
    text
    copied!<p>I just started using MigLayout for SWING in Java and I'm really liking it so far. The only thing, though, is that the dock parameters don't seem to work the way I thought they worked and I can't figure out what I'm doing wrong.</p> <p>The problem is: I'm trying to add a JButton inside a JPanel and docking it to the right side using <i>panel.add(button, "east");</i>. While it actually makes it the rightmost component, it still only takes the same space as it would in a flowLayout. What I'd like it to do is stick to the right side of the panel.</p> <p>Here's some compilable code that recreates the problem:</p> <pre><code>public class MigLayoutTest extends JFrame { public MigLayoutTest() { setSize(500,500); JPanel panel = new JPanel(new MigLayout()); panel.setBackground(Color.YELLOW); setContentPane(panel); panel.setSize(500,500); panel.add(new JButton("Dock east"), "east"); panel.add(new JButton("No dock")); } public static void main(String[] args) { JFrame frame = new MigLayoutTest(); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } } </code></pre> <p>Here's what the output looks like: <img src="https://i.stack.imgur.com/ImKSq.png" alt="MigLayoutTest result"></p> <p>And here's where I'd want the "dock east" button: <img src="https://i.stack.imgur.com/gocza.png" alt="MigLayoutTest expected result"></p> <p>If I'm using the parameters wrong, I'd like it if someone could tell me how I'm supposed to make my button dock to the right side of the panel.</p> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload