I have created a jComboBox but it takes the full width of the frame. how to set the width fixed.
yes borderlayout for the frame and box layout for the panel. i am
The width is automatically determined by the width of the largest item added to the combo box. You can control the display by using:
comboBox.setPrototypeDisplayValue("text here");
You might also consider using the Combo Box Popup to control the popup size.
Edit:
Since you added code that shows you are using a BoxLayout you can try the following:
comboBox.setMaximumSize( comboBox.getPreferredSize() );
Or you can do something like:
JPanel wrapper = new JPanel();
wrapper.add( comboBox );
panel.add( wrapper );
Read the section from the Swing tutorial on Using Layout Managers to understand how these suggestions work.