Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Limit the size of a JComboBox button but not its drop down list

Posted on 1998-07-21
2
Medium Priority
?
937 Views
Last Modified: 2008-02-01
I'm trying to display large strings in JComboBox but this forces the JComboBox to be as large as the largest string.
I have limited the size of the JComboBox button by overloading getPrefferedSize with a constant width.  This then limits the size of the drop down list box.  I want to limit the size of the button but allow the list to be as wide as it likes or at least have a horizontal scroll bar.

 Have you any sugesstions about how to achive this?
0
Comment
Question by:macum
2 Comments
 
LVL 4

Accepted Solution

by:
evijay earned 50 total points
ID: 1227261
You can atmost attach a tool tip to each of the list item which can be of any size. See TreeCombo.java in SwingSet demo example for doing it. You need to modify getListCellRenderer and add setTooltipText to that component there.

0
 

Author Comment

by:macum
ID: 1227262
Its a solution but the combo box holds over two hundred items and searching them by using a tool tip will be unfeasible.

I could use a button with the selected item in and listen for when the button is pressed so I can display a JList but I want it to look like a JComboBox for all L&F.
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This video teaches viewers about errors in exception handling.
Suggested Courses

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question