Solved

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

Posted on 1998-07-21
2
884 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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
hash value 2 38
groovy example issue 10 65
bitbucket vs gitbucket 3 28
Where to store the queries for modification of table 4 24
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…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:

763 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now