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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:53:10+00:00 2026-06-07T20:53:10+00:00

I have a problem using MigLayout in combination with dynamically changing the font-size of

  • 0

I have a problem using MigLayout in combination with dynamically changing the font-size of the components which are shown in the MigLayout cells.

In detail: I added a JCheckBox via MigLayout to a JPanel. The font-size of the JCheckBox is default (12pt?) and the row which contains the JCheckBox has a preferred height of 17lp. That all works fine.
(View here: http://www.bilderload.com/bild/227327/migproblemcellheight1UQXP2.png)

Now I change the font-size to e.g. 20pt and start the program again. Now the text of the JCheckBox is cut because the row has also the height of 17lp.
(View here: http://www.bilderload.com/bild/227328/migproblemcellheight2DDPGJ.png)

If I for example let the row definition empty (“[]”) the text shows correctly with both font sizes – the normal and the large one. But in this case the row will sadly never reach a minimum of 17lp. (It will always have a minimum of 23lp or so)

How can I change the MigLayout definition to get a minimum row-height of 17lp and to let the cell grow correctly with the components font-size/text etc.?
Or maybe this is a L&F problem?

Thanks & best regards,

Philipp

Here is my sample code (working example):

import java.awt.Font;

import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;

import net.miginfocom.swing.MigLayout;

public class TestMigLayoutFontSize extends JFrame {
  public TestMigLayoutFontSize() {
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    setSize(600, 400);
    setContentPane(getTestPanel());
    setVisible(true);
  }

  private JPanel getTestPanel() {
    JCheckBox testBox = new JCheckBox("Program argument");
    Font normalFont = testBox.getFont();
    Font largeFont = new Font(testBox.getFont().getName(), testBox.getFont().getStyle(), 20);
    // testBox.setFont(normalFont);
    testBox.setFont(largeFont);

    JPanel tempPanel = new JPanel(new MigLayout("debug", "0lp![grow,fill]0lp!", "[17lp:17lp:n]"));
    tempPanel.add(testBox);

    JPanel testPanel = new JPanel(new MigLayout("", "[grow,fill]", "[grow,fill]"));
    testPanel.add(tempPanel);

    return testPanel;
  }

  public static void main(String[] args) {
    new TestMigLayoutFontSize();
  }
}
  • 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-06-07T20:53:11+00:00Added an answer on June 7, 2026 at 8:53 pm

    You may reduce the space around your checkbox by reducing the border size, e.g. put

    testBox.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    

    directly after the assignment of testBox. You may then leave the row definition empty and still get a reasonable height for your panel.

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

Sidebar

Related Questions

I have problem using arabic font for iOS. All fonts have the same render,
I have a problem using fadeIn() on div that contains elements which positions are
I have a small problem, i started a new GUI project using MigLayout and
I have a problem using iOS 5 new functionality to select multiple cells during
i have problem using LIKE structure in DB2 : for example: select * from
I have problem while using jquery maskedinput with asp.net textbox. I have a check
I have a problem using Linq to NHibernate to load an object and eagerly
I have a problem using the SSIS. I try to import data from database
I have a problem using JSON and arrays. Here is my code: while($row =
i have a problem using the Catch Clipboard Events code found on this link

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.