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 7527999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T04:15:21+00:00 2026-05-30T04:15:21+00:00

I have a MigLayout that I’d like to add components to dynamically, while keeping

  • 0

I have a MigLayout that I’d like to add components to dynamically, while keeping two buttons at the bottom of the frame (because that’s intuitive).

Firstly, I’d like to know if what I’m currently doing is the best way to go about it, and secondly how to get what I’m trying to do to actually work.

At the moment, I’m using the MigLayout’s “grid” to position the dynamically-added components, and then using the MigLayout’s “border” to position the fixed components but I can’t get both buttons to sit on the south border next to one another.

According to the Quickstart PDF, this should be possible (and I quote, “you aren’t confined to use only one component per side”) but it doesn’t go on to say how you achieve this.

  • 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-30T04:15:23+00:00Added an answer on May 30, 2026 at 4:15 am

    Personnally I’d rather split my JFrame in 2 JPanels with a BorderLayout. Place the MigLayout form within a JPanel in the CENTER area, and the the buttons within a Box in the SOUTH area.

    EDIT

    With an example it even better 😉

    public static void main(String[] args) {
    
        JFrame frame = new JFrame();
        frame.setLayout(new BorderLayout());
    
        // == MigLayout Form ==
        JPanel panelCenter = new JPanel();
        panelCenter.setLayout(
                    new MigLayout(
                            new LC().wrapAfter(4),
                            new AC().size(":80:", 0).size("115:115:115", 1, 2, 3).align("right", 0, 2),
                            new AC().size("19:19:19")
                    ));
        panelCenter.setOpaque(false);
    
        panelCenter.add(new JLabel("Label1"));
        panelCenter.add(new JTextField(), new CC().growX());
        panelCenter.add(new JLabel("Label2"));
        panelCenter.add(new JTextField(), new CC().growX());
        panelCenter.add(new JLabel("Label3"));
        panelCenter.add(new JTextField(), new CC().growX());
        panelCenter.add(new JLabel("Label4"));
        panelCenter.add(new JTextField(), new CC().growX());
        panelCenter.add(new JLabel("Label5"));
        panelCenter.add(new JTextField(), new CC().growX());
        panelCenter.add(new JLabel("Label6"));
        panelCenter.add(new JTextField(), new CC().growX());
    
        frame.add(panelCenter, BorderLayout.CENTER);
    
        // == Buttons ==
        Box southPanel = Box.createHorizontalBox();
        southPanel.add(Box.createHorizontalGlue());
        southPanel.add(new JButton("Ok"));
        southPanel.add(new JButton("Cancel"));
        southPanel.add(Box.createHorizontalGlue());
        frame.add(southPanel, BorderLayout.SOUTH);
    
        frame.setVisible(true);
        frame.setSize(500, 150);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Component that uses MigLayout as its LayoutManager. It is set to
I have a VBScript script that looks like this: Const ForAppending = 8 Set
I have an Android Activity that needs to catch two different broadcasts. My current
I have some controls in columns that I would like to look like this,
I am trying to create a panel that can dynamically insert components based on
I'm using 'hidemode 3' in MigLayout so that hidden components aren't visible at all
I have setup a project in node with the express framework. I like that
What java GUI layout manager does everyone use? Lately, I have been using MigLayout
I have a miglayout for a window where one of the columns was specified
I have a JScrollpane that has a JPanel on the inside (and the panel

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.