Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > How to set the size on a JComboBox

Reply
Thread Tools

How to set the size on a JComboBox

 
 
Aaron Fude
Guest
Posts: n/a
 
      12-17-2008
Hi,

I would like to set the width of a JComboBox to the widest item that
it contains. How does one do that after all the items have been added
to the JComboBox?

Many thanks in advance,

Aaron
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      12-17-2008
On Dec 17, 3:21*pm, Aaron Fude <(E-Mail Removed)> wrote:
> ...
> I would like to set the width of a JComboBox to the widest item that
> it contains.


<sscce>
import javax.swing.*;

class ComboWidthTest {

public static void main(String[] args) {
String[] items = {
"a",
"b",
"c",
"dddddddddddddddddddddddddddddddddddddd",
"e"
};
JComboBox combo = new JComboBox(items);
JOptionPane.showMessageDialog(null, combo);
}
}
</sscce>

>..How does one do that after all the items have been added
> to the JComboBox?


It is usually automatic, unless any of
a number of silly things have been done
by one in the code that one is asking us
to guess about.

--
Andrew Thompson
http://pscode.org/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
mega pixels, file size, image size, and print size - Adobe Evangelists Frank ess Digital Photography 0 11-14-2006 05:08 PM
Controlling JComboBox size in JTable cell Yulia Java 1 07-04-2005 10:29 AM
How to set size for JComboBox Bobby Java 1 01-07-2005 07:16 PM
How to set size for JComboBox Bobby Java 0 01-07-2005 03:42 PM



Advertisments