Home arrow static arrow Java Programming [Archive] - Expanding Width of Drop-Down List from JComboBox
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - Expanding Width of Drop-Down List from JComboBox
This topic has 5 replies on 1 page.

Posts:1
Registered: 5/9/03
Expanding Width of Drop-Down List from JComboBox  
May 9, 2003 8:25 AM



 
Is anyone aware of any way to expand the width of the Drop-Down list of a JComboBox? I have a GUI in which there is no more real estate available to expand the size of the JComboBox itself, but to fit the items in the list, the Font is so small that it is hard to read. I have been trying many different things to attempt to simply widen the drop-down list itself but nothing seems to work. It appears as if the size of the JComboBox is overriding anything I do, even in the ListCellRenderer. I can manipulate the height and font of the items in the list, but I cannot figure out how to make the list WIDER.
 

Posts:60
Registered: 11/1/98
Re: Expanding Width of Drop-Down List from JComboBox  
May 9, 2003 3:56 PM (reply 1 of 5)



 
Adding spaces doesn't help?

"Option1" == " Option 1 "

As far as changing the size of the list independant of the control itself (the text box with the down arrow button on the right) I don't know.
 

Posts:8,813
Registered: 10/4/00
Re: Expanding Width of Drop-Down List from JComboBox  
May 9, 2003 4:14 PM (reply 2 of 5)



 
Look here
http://www2.gol.com/users/tame/swing/examples/SwingExamples.html
 

Posts:5
Registered: 7/6/04
Re: Expanding Width of Drop-Down List from JComboBox  
Jul 6, 2004 6:48 AM (reply 3 of 5)



 
Hi,

You wouldn't happen to know where the examples below (the link that is now dead) can be found now?

Many thanks,
Marcus
 

Posts:5,119
Registered: 16.08.01
Re: Expanding Width of Drop-Down List from JComboBox  
Jul 6, 2004 7:37 AM (reply 4 of 5)



 
I found this on my comp:
// A Custom UI for the combo box popupprivate static class PopupExpandingComboBoxUI extends WindowsComboBoxUI{protected ComboPopup createPopup(){return new ExpandingComboPopup(comboBox);}} // Our custom popup menu - it makes up its own widthprivate static class ExpandingComboPopup extends BasicComboPopup{public ExpandingComboPopup(JComboBox cBox){super(cBox);} public Rectangle computePopupBounds(int px, int py, int pw, int ph){// Ok - just set the popup width to 200 for now - should be calculated thoughreturn super.computePopupBounds(px, py, 200, ph);}} 
 

Posts:24,517
Registered: 98-02-27
Re: Expanding Width of Drop-Down List from JComboBox  
Jul 6, 2004 7:55 AM (reply 5 of 5)



 
The above examples can now be found [url http://www.senun.com/Left/Programming/Java_old/Examples_swing/SwingExamples.html]here[/url].
 
This topic has 5 replies on 1 page.