Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6132577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T17:07:08+00:00 2026-05-23T17:07:08+00:00

I just started using MigLayout for SWING in Java and I’m really liking it

  • 0

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.

The problem is: I’m trying to add a JButton inside a JPanel and docking it to the right side using panel.add(button, “east”);. 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.

Here’s some compilable code that recreates the problem:

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);
  }
}

Here’s what the output looks like:
MigLayoutTest result

And here’s where I’d want the “dock east” button:
MigLayoutTest expected result

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.

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T17:07:09+00:00Added an answer on May 23, 2026 at 5:07 pm

    You have to specify growth paarameters:

    new MigLayout("", "[grow]", "[]")
    

    Be careful though how you use it – it may not work the way you think it is. Here is a good read up on MigLayout features http://www.miglayout.com/QuickStart.pdf

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Just started using Java (for Android, if that matters) and all I want is
I just started using the WPF WebBrowser that is included in Net 3.5 SP1.
I just started using SVN, and I have a cache directory that I don't
I just started using datatables (java script) for tabular data, due to js I
I just started using LISP, coming from a background in C. So far its
I just started using mock objects (using Java's mockito) in my tests recently. Needless
I just started using Resharper. One of its features is that it suggests changes
I just started using Coderush and found some stuff that I used to have
I just started using Linq to SQL, and it just occurred to me that
Have just started using Google Chrome , and noticed in parts of our site,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.