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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:05:04+00:00 2026-06-18T00:05:04+00:00

My JFrame consists of some JTextFields. For Windows OS I simply use the system

  • 0

My JFrame consists of some JTextFields. For Windows OS I simply use the system look&feel. For Linux distributions I use Nimbus L&F shipped with Java SE 6.

In Nimbus L&F, the lower border of the JTextField cuts-off 4 pixels. Thus, letters like “g” are cutted and look like an “a”.

Does somebody know how to get rid of this white border within the text fields?

Here’s an illustration of the issue:

enter image description here

Here’s an SSCCE (example code):

public class NimbusTextFieldIssue extends javax.swing.JFrame {

    public NimbusTextFieldIssue() {
        initComponents();
    }

    private void initComponents() {

        txtField = new javax.swing.JTextField();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        txtField.setText("The letters \"g\" and \"p\" are not shown correctly.");
        txtField.setPreferredSize(new java.awt.Dimension(234, 22));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txtField, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(txtField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }


    public static void main(String args[]) {
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {

        } catch (InstantiationException ex) {

        } catch (IllegalAccessException ex) {

        } catch (javax.swing.UnsupportedLookAndFeelException ex) {

        }

        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new NimbusTextFieldIssue().setVisible(true);
            }
        });
    }

    private javax.swing.JTextField txtField;

}

Many thanks in advance!

  • 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-18T00:05:05+00:00Added an answer on June 18, 2026 at 12:05 am

    I don’t have this kind of issue with Nimbus. You probably have something else that causes this problem. Check out the example below.

    UPDATE

    You should never call setPreferredSize() on any components (I really mean that). It always leads to problem across different look and feels. If you want to indicate the width of the textfield, use JTextField.setColumns(int).

    import java.awt.FlowLayout;
    
    import javax.swing.JFrame;
    import javax.swing.JTextField;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    import javax.swing.UIManager.LookAndFeelInfo;
    import javax.swing.UnsupportedLookAndFeelException;
    
    public class TestNimbusTextField {
    
        private void initUI() {
            JFrame frame = new JFrame(TestNimbusTextField.class.getSimpleName());
            frame.setLayout(new FlowLayout());
            JTextField textfield = new JTextField(20);
            textfield.setText("good morning. Look like I have no problems with 'g' and 'p'.");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.add(textfield);
            frame.setSize(300, 300);
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    
        public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException,
                UnsupportedLookAndFeelException {
            LookAndFeelInfo[] installedLookAndFeels = UIManager.getInstalledLookAndFeels();
            for (LookAndFeelInfo lafInfo : installedLookAndFeels) {
                if (lafInfo.getName().equals("Nimbus")) {
                    UIManager.setLookAndFeel(lafInfo.getClassName());
                    break;
                }
            }
            SwingUtilities.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    new TestNimbusTextField().initUI();
                }
            });
        }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a JFrame which consists only of a JList , the JList has
I have a JFrame with some a JTextField and a JButton. I want it
I have a main JFrame which consists of 3 small JPanel which are switched
I use an undecorated JFrame with a modal dialog. The problem is the modal
I am trying to program a java application that consists of several windows using
To put it simple, there's a simple java swing app that consists of JFrame
I have a main JFrame which holds a default JPanel. I'm trying to use
Whenever I run my program (Which only consists of a JFrame in main and
I have this Java JFrame class, in which I want to use a boxlayout,
I have a JFrame with 1 panel for drawing and set KyeListener for JFrame.

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.