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

  • Home
  • SEARCH
  • 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 8456107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T12:27:43+00:00 2026-06-10T12:27:43+00:00

When I put a JComboBox into a JPanel with GridBagLayout, I find the longest

  • 0

When I put a JComboBox into a JPanel with GridBagLayout, I find the longest JComboBox item will not fully show, instead, it show part of with ‘…’

For example, it show ‘Healthcare Ingred…’ for ‘Healthcare Ingredient’.

Please have a look at the screenshot here:

JComboBox width issue

Code is something like this:

JPanel infoPanel = JPanel(new GridBagLayout());            
dataTypeCB = new JComboBox(dataTypeList.toArray());
infoPanel.add(dataTypeCB, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5,5,5,5), 0, 0));

I find out two solution already:

  1. overwrite the getPreferenceSize of JComboBox, however a bit annoying.
  2. wrap the JComboBox with a JPanel, like below, however the warpped JPanel introduce some intents and cause alignment issue instead, still not perfect:

code of second solution:

dataTypeCB = new JComboBox(dataTypeList.toArray());
JPanel dataTypeCBPanel = new JPanel();//make item can be fully show up.
dataTypeCBPanel.add(dataTypeCB, BorderLayout.CENTER);
infoPanel.add(dataTypeCBPanel, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5,5,5,5), 0, 0));

My question is : is any other easy way to solve this issue?

Enviroment: windows 7 with JDK 1.6_25(64bit version)

Many 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-06-10T12:27:45+00:00Added an answer on June 10, 2026 at 12:27 pm

    Solve this issue by myself.

    The reason why I get this, is because I am using a library with the name “JIDE”, which bring its LookAndFeel into my application.

    I tested on the JDK’s default look and feel, they looks do not have this issue.
    Then I switch to JIDE’s look and Feel, then I can reproduce this issue.

    So I think the problem is related with the LookAndFeel. The ComboBoxUI class.

    So what I really need to do is to write my own ComboBoxUI or extends the UI class in JIDE library.

    Sorry for did not give enough information for this, when I ask question, I did not realize it is related with the LookAndFeel.

    Thanks

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

Sidebar

Related Questions

Hi if You put JComboBox in JTable and String[] array to JComboBox everything works
I am trying to put a QComboBox into a QStandardItem to be used in
I have an item which type is QString: for example: QString name=Name the question
I am trying to find out how to detect if a JComboBox lost focus
I am working on project where I need to put different controls into one
I have information that was gathered from a service about TFS builds put into
I want to put individual JComboBoxes into each cells of a JTable. ie. The
How can I put the contents of the examplefile.dat into the Jlist examplefile.dat evan:joe:lance:steve
I'm trying to query an MySql table, put all results into a combobox. So
I want to put a JComboBox inside a JRadioButtonMenuItem in a popup menu, is

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.