473,394 Members | 1,800 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

size of JComboBox

39
Hi, I am developing an application for which I need to increase the size of the JComboBox.But it is not getting increased.I used the following technique:

Container cont;
JComboBox valueTypeBox ;
valueTypeBox = new JComboBox();

valueTypeBox.addItem("asia");
valueTypeBox.addItem("india");

cont = getContentPane();
GridBagLayout theLayout = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
JPanel hostPanel = new JPanel();
hostPanel.setLayout(theLayout);
c.gridx = 2;
c.gridy = 3;
c.anchor = GridBagConstraints.FIRST_LINE_START;
c.fill = GridBagConstraints.NONE;
c.weightx = 1;
c.weighty = 0;
c.insets = new Insets(10, 0, 0, 40);
hostPanel.add(valueTypeBox,c);

Please suggest as how can I increase the size of the JComboBox.Thanks for help.

Jerico
Nov 20 '06 #1
2 9898
We have two method called setPreferedSize(int,int) and setMinimumSize(int,int) . try this it may solve your problem
Jan 4 '07 #2
Soujiro
35
The size of JComponents depends on the Layout specified by the container.. In order to change sizes and even locations you need to implement LayoutManager and do it as you want.. here is a snippet of it.


Expand|Select|Wrap|Line Numbers
  1. container.setLayout(new CustomLayout);
  2.  
  3.     public void layoutContainer(Container parent) {
  4.         Insets insets = parent.getInsets();
  5.  
  6.         Component c;
  7.         c = parent.getComponent(0);   /* the first component you add into the container */
  8.         if (c.isVisible()) {c.setBounds(insets.left+8,insets.top+24,480,248);} /* its location and size */
  9.     }
  10.  
Jan 6 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: L L | last post by:
Dear all, Is it possible to set selected item a table row or in other ways, the editable JComboBox 's JTextField- can that be replace by a one row table? If possible, any direction of what...
3
by: Hal Vaughan | last post by:
I have a JComboBox with a list of numbers, from 1 digit to 5 digits. Numbers with more than 3 digits have a comma in them. I've been aligning them with leading spaces. Is there any simple and...
0
by: Yasser | last post by:
Hi All, I developed an application (JFrame) to connect to mysql database. The application will select price from itemsTable and add each each item to a JComboBox. If the user change the prices in...
1
by: Robert | last post by:
When I select a normal cell with a default editor for strings and press a letter key, the letter is automaticaly typed in the cell, but when I select a cell with an editable JComboBox editor and...
8
by: dycharles | last post by:
I have a JComboBox loaded with 20,000 data, my problem is when i scroll down or scroll up, it is slower than the JComboBox with the smaller data. What can i do to make my JComboBox run faster or like...
2
by: thesti | last post by:
hi, How to, if user change the selected item of a JComboBox, it will enable another JComboBox. it's like a validation that the user has to select the year first, then the month, than the date. ...
0
by: wajedali | last post by:
hi......... i have problem in incresing and decreasing the component. I have a one main panel (i.e. i used as _basewindowPanel) in that again two panel in that two panel like wise.... ...
2
by: HaifaCarina | last post by:
i have this unfinished java program and i can't figure out what is the problem.. please help... /** * @(#)Answer3.java * * * @author * @version 1.00 2008/1/17
2
by: javatech007 | last post by:
I am trying to use comboboxes in a ticket payment screen for train tickets. I have two combo boxes. One for picking a route and the other for picking a time. What i want is when you pick a route in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.