Results 1 to 2 of 2
- 01-02-2012, 12:54 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 30
- Rep Power
- 0
How to set the size of a JComboBox?
I have a JComboBox and I can't figure out how why, but it takes up the whole window, even if I resize the window itself.
Even though Dimension(300, 100) is smaller than my JFrame window, the JComboBox still takes up the whole window.Java Code:String[] firstOptions = {"--Pick one--", "One", "Second", "Next", "Testing"}; JComboBox firstValue = new JComboBox(firstOptions); firstValue.setPreferredSize(new Dimension(300, 100)); firstValue.setSelectedIndex(0); frame.getContentPane().add(firstValue, BorderLayout.NORTH);
Any help? I'm a little new to Java
- 01-02-2012, 01:21 AM #2
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,537
- Rep Power
- 11
Re: How to set the size of a JComboBox?
Use a layout manager to determine the size of components.
See Using Layout Managers (The Java™ Tutorials > Creating a GUI With JFC/Swing > Laying Out Components Within a Container) and following.
Similar Threads
-
JComboBox
By Java_25 in forum New To JavaReplies: 10Last Post: 04-20-2011, 06:39 PM -
Activate JComboBox 1 when object is selected in JComboBox 2...
By bahumbaba in forum AWT / SwingReplies: 2Last Post: 12-10-2009, 01:58 PM -
Setting frame size to the size of an image
By Yoruichi in forum AWT / SwingReplies: 5Last Post: 04-22-2009, 04:37 PM -
JCombobox
By daniel50096230 in forum NetBeansReplies: 1Last Post: 09-21-2008, 12:23 PM -
jcombobox
By Freddie in forum AWT / SwingReplies: 4Last Post: 05-11-2007, 12:48 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks