Solved

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

Posted on 1998-07-21
2
897 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Java Jpanels and Jframe 8 28
Java - Why doesn't this JFrame work 3 40
Java JRE greater than 1.6 5 50
jar file executable 12 38
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
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 basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

919 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

18 Experts available now in Live!

Get 1:1 Help Now