title: JComboBox width
body: <p>I have created a jComboBox but it takes the full width of the frame. how to set the width fixed. </p>
  
  <p>yes borderlayout for the frame and box layout for the panel.  i am adding the code here:</p>
  
  <pre><code>import javax.swing.*;
  import java.awt.BorderLayout;
  
  public class Window8  {
  
      JFrame frame;
      JPanel panel;
      JComboBox combo;
      public void go(){
  
      String[] option = { "STUDENT", "TEACHER" };
  
      combo.setPreferredSize(new Dimension(1,25));
      combo = new JComboBox(option);
      menu.setSelectedIndex(0);
  
      frame = new JFrame("DELETION"); 
      frame.setLocationRelativeTo(null);
      frame.setSize(400, 300);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setVisible(true);
  
      panel = new JPanel();
      panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
  
      frame.getContentPane().add(BorderLayout.NORTH,panel);
      panel.add(combo);   
  }
  </code></pre>