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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:23:36+00:00 2026-06-17T01:23:36+00:00

I have a jComboBox in my Swing GUI, filling the value from my SQL

  • 0

I have a jComboBox in my Swing GUI, filling the value from my SQL Database.

All looks fine but when I run the application, my combobox appeared e.g [Black …] with the 3 dots to the side.

Please advice how can I remove the 3 dots.

Edited:
Added code for my jComboBox and a image of it

    public void fillTankDepth()
{

    String fill = "Select * from swdepth";
    try{
        ps = conn.prepareStatement(fill);
        rs = ps.executeQuery();

        while(rs.next()){
            String depth = rs.getString("depth");
            comboDepth.addItem(depth);

                        }
    }
    catch(Exception e){
    JOptionPane.showMessageDialog(null, e);    
    }
 }

enter image description here

As per the image above, I’ve given quite a long width to it yet I’m unable to remove the 3 dots.

  • 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-17T01:23:38+00:00Added an answer on June 17, 2026 at 1:23 am

    You likely aren’t providing enough physical room on your GUI to display the data. Make more horizontal room for your combobox (i.e., make it longer).

    UPDATE

    As per the image above, I’ve given quite a long width to it yet I’m unable to remove the 3 dots.

    Looking at the screenshot you added, my guess is that it’s a data problem. Some jdbc drivers will give you space-padded strings out to the length of the column, even if the data is much shorter. For example, a column defined as char(10) that has the value “A” in it may come back from your query as

    "A         "

    . If this is the case, trim the strings before adding them to the combo:

    String depth = rs.getString("depth").trim();
    

    Also, as suggested by mKorbel, you can set the prototype for your combo:

    // if you're using strings, and the max length will be 10
    comboDepth.setPrototypeDisplayValue("1234567890");
    

    Keep in mind, the padded spaces (as your screenshot suggests) will still be a problem if the spaces are causing the data to be longer than what you’re expecting.

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

Sidebar

Related Questions

I have following code for my java swing application which is executing fine in
I have a GUI designed in Swing with all of the Components laid out.
I have a little problem. I had some JComboBox to a JDialog but they
I have a combobox whose value I want to use with a SQL WHERE
I want to add a JComboBox in Swing that is simple but I want
I would like to populate a java.swing JComboBox with values from an Enum .
I have a JCombobox with many items and first of all them is a
I have a Java swing application with a panel that contains three JComboBoxe s
I'm writing a Java Desktop utility in Java swing and have a minimal GUI
I am creating a swing font chooser. (See also: How to prevent JComboBox from

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.