Solved

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

Posted on 1998-07-21
2
926 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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:

617 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