Jcombobox size

hi guys, I have a JLabel follwed by a rigidarea followed by a JComboBox...omgggggggggggggggggg, the JComboBox takes up all the space, it is soooo bit, it looks sooooooooo stupid.
I tried googling on setting the size, this person here asked the same question I want but no one replied to him
https://lists.xcf.berkeley.edu/lists/advanced-java/2000-April/008693.html
Please help me. I cant set the size hand-coded, cos the JComboBox lists the results of a SQL query, and so its size should be dependent on the longest value
Thanks guys

Thanks, I just decided to hand code it in...that code is too much to just copy and paste as it would probably be plagiarising!!!

Similar Messages

  • JComboBox Size Problem

    This is my code:
    MyComboBox.setSize(new Dimension(50, 20));
    MenuBar.add(MyComboBox);
    But the combo Box take all the space of my menu !
    What's wrong?

    Use setMinimumSize(...), setMaximumSize(...) and setPreferredSize(...) also.
    Kurta

  • Reducing the Width of JComBoBox

    I have a ComboBox which are having elments like
    ComPort
    COM2
    COM3
    COM4And in the same i have some more like that like Baudrate,ParityBit arranged in GridLayout.My JComboBox size is little big that i dont need.So how to reduce it..
    Any Help Appreciated.
    Thanks in advance.
    regards,
    Viswanadh

    Normally the combox loops through all the entries to find the largest and it uses that entry as the basis for the combo box size.
    However, the combobox has a method that allows you to specify the display value you want to use as the largest. Take a look at the set... methods in the API.

  • Cost Estimating Applet HELP PLEASE!!!!!!!!!

    i need to develop an applet that calculates the choices that the user makes and the numeric input in the textfield...i have done a basic applet with a panel and 3 comboboxes that i need and the textfield. my problem is how to take the value that the user inputs from the textfield in order to calculate it with the other choices. in the begginng when i had the only the combo boxes was working fine..when i added the textfield something in the code smells..i provide anyone who wants to help with the code..thanx everyone for their time...
    * Course Work Assignment - Applet Programming *
    * Programmed by Christos Lappas *
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.event.ActionEvent;
    import javax.swing.JApplet;
    import javax.swing.JComboBox;
    import javax.swing.JFormattedTextField;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.SwingConstants;
    import javax.swing.border.TitledBorder;
    * This is the main class that implements the "Pricer" applet.
    public class Pricer extends JApplet {
    // The standar colours available
    private String[] colours = {"None","Red","White","Black"};
    // Bonus colour available only for Cars and Boats
    private String bonusColour = "Any other color";
    // The standar items available
    private String[] items = {"None","<50 tiles","100>50 tiles","100=<"};
    // The base prices of these items
    private double[] prices = {0,1.1,1.0,0.8};
    // The sizes available
    private String[] sizes = {"None","small","normal","large"};
    // Initialize the combo-boxes
    private JComboBox item = new JComboBox(items);
    private JComboBox size = new JComboBox(sizes);
    private JComboBox colour = new JComboBox(colours);
    private int cols = 5;
    private int tiles;
    private JTextField notiles = new JTextField(cols);
    // Initialize the price
    private JLabel price = new JLabel("Please select a combination");
    // Initialize the current values
    private int curTeam = 0;
    private int curItem = 0;
    private int curColour = 0;
    private int curSize = 0;
    * The constructor method. Leaves everything to the init method.
    public Pricer()
    // do nothing
    * Initialize the components and add them to the applet.
    public void init()
    // Set applet size and layout
    this.setSize(new Dimension(400,250));
    this.getContentPane().setLayout(new BorderLayout());
    // Initialize the title
    JLabel title = new JLabel("Tiles-U-Like Inc.");
    title.setHorizontalAlignment(SwingConstants.CENTER);
    title.setFont(new java.awt.Font("Comic Sans MS", 2, 16));
    title.setMaximumSize(new Dimension(400,50));
    title.setMinimumSize(new Dimension(400,50));
    title.setPreferredSize(new Dimension(400,50));
    // Initialize the price
    price.setHorizontalAlignment(SwingConstants.CENTER);
    price.setFont(new java.awt.Font("Comic Sans MS", 2, 14));
    price.setMaximumSize(new Dimension(400,50));
    price.setMinimumSize(new Dimension(400,50));
    price.setPreferredSize(new Dimension(400,50));
    // Initialize the optionPanel that will hold the combo-boxes
    JPanel optionPanel = new JPanel();
    TitledBorder border = new TitledBorder("Choose a combination to display it's value");
    border.setTitleJustification(TitledBorder.CENTER);
    optionPanel.setBorder(border);
    optionPanel.setMaximumSize(new Dimension(594, 450));
    optionPanel.setMinimumSize(new Dimension(394, 350));
    optionPanel.setPreferredSize(new Dimension(400, 400));
    // Create the Anonymous Class that will handle the item's actions
    item.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e1) {
    int itemIndex = item.getSelectedIndex();
    if (itemIndex!=curItem) // If the selection was changed
    curItem = itemIndex;
    int team = ((itemIndex==1) || (itemIndex==5))?1:0;
    if ((team != curTeam) && (itemIndex>0)) // If team changed
    curTeam = team;
    setColours(team); // Fix the colours
    // Finally, calculate and display the price
    // for the new combination
    displayPrice();
    // Create the Anonymous Class that will handle the size's actions
    size.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e2) {
    int sizeIndex = size.getSelectedIndex();
    // If the selection was changed, calculate and display
    // the price for the new combination
    if (sizeIndex!=curSize)
    curSize = sizeIndex;
    displayPrice();
    // Create the Anonymous Class that will handle the colour's actions
    colour.addActionListener(new java.awt.event.ActionListener() {
    public void actionPerformed(ActionEvent e2) {
    int colourIndex = colour.getSelectedIndex();
    // If the selection was changed, calculate and display
    // the price for the new combination
    if (colourIndex!=curColour)
    curColour = colourIndex;
    displayPrice();
    //Class to handle tiles actions
    notiles.addActionListener(new java.awt.event.ActionListener(){
                   public void actionPerformed(ActionEvent e3) {
    // Add the combo-boxes to the optionPanel
    optionPanel.add(item);
    optionPanel.add(size);
    optionPanel.add(colour);
    optionPanel.add(notiles);
    // Add the components to the applet
    this.getContentPane().add(title, "North");
    this.getContentPane().add(optionPanel, "Center");
    this.getContentPane().add(price, "South");
    // This method determines the available colours
    // depending on the curent team
    private void setColours(int team)
    if (team==1) colour.addItem(bonusColour);
    else colour.removeItem(bonusColour);
    // This method calculates and displays the price
    private void displayPrice()
    // If an invalid combination was selected,
    // display the appropriate message
    if ((curItem==0) || (curSize==0) || (curColour==0)|| (tiles==0))
    price.setFont(new java.awt.Font("Comic Sans MS", 2, 14));
    price.setText("Please select a valid combination");
    else // valid combination
    // Determine the base price, as well as the
    // colour and size bias
    double base = prices[curItem];
    double colAdd=0, sizeAdd=0;
    switch (curColour)
    case 1: colAdd=1.25; break; // Red or Green
    case 2: colAdd=1.0; break; // White
    case 3: colAdd=1.50; break; // Black
    case 4: colAdd=3.50; break; // Any other
    switch (curSize)
    case 1: sizeAdd=-6.75; break; // Small
    case 2: sizeAdd=4.25; break; // Normal
    case 3: sizeAdd=3.50; break; // Large
    // Determine the total price
    double totalPrice = Math.round(base + (base*colAdd) + (base*sizeAdd)+ (base*tiles));
    // Set the font and print the result (rounded)
    price.setFont(new java.awt.Font("Comic Sans MS", 1, 18));
    price.setText(Math.round(totalPrice)+" pounds");
    }

    ok then..i want the applet to take the options from
    the comboboxes and the number from the
    textfield..multiplying them all together and display
    the total price..originally the problem was stated
    as: An applet is required that allows a potential
    customer to obtain an estimate of the cost associated
    with tiling a supplied square area of floor with
    tiles of a specified size and colour.
    ...that is all for now..i can provide even more
    detailed description..thanx..I don't need a more detailed of your homework, I need a more detailed description of your problem.

  • E.getActionCommand()

    I have the following code below.
    The problem is that all buttons and menuitems work fine except one probelm and that is that the last logical IF statement is also executed whenever i clikc on any menuitem which is not connected to the last IF statement (see below). all these events are for buttons and menuitems. I have put in System.out statements to see if they work properly, but i dont get why the last IF statement should also be executed even though i dont select that menuitem. Please do help. This code is for my text editor that i am creating.
    Can be found at alpha66.cjb.net. but the one on the net is a beta version.
         public void actionPerformed(ActionEvent e)
              if (e.getActionCommand() == "Exit")
                   System.exit(0);
              if (e.getActionCommand() == "Cut")
                   System.out.println("Cut");
              if (e.getActionCommand() == "Copy")
                   System.out.println("Copy");
              if (e.getActionCommand() == "Paste")
                   System.out.println("Paste");
              if (e.getActionCommand() == "Font")
                   System.out.println("Font");
              if (e.getActionCommand() == "Clear")
                   txt.setText("");
              if (e.getActionCommand() == "wordcount");
                   System.out.println("Count Words");

    >
    thanks, the-sue
    but i m not sure how i m going to chek if its saved, i
    am at the moment working on making a word counter, and
    font selector. Try this;-import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    import javax.swing.text.*;
    // NB: This is a subclass JDialog window and opens with "new FontChooser()"
    // substitute MyGUI for your main app name and add a JLabel called myMessageLabel to it
    public class FontChooser extends JDialog{
       private JLabel sample;
       private JTextField fontField;
       private JTextPane pane;
       private JPanel pan;
       private String fontSelected;
       private int size=12;
       public FontChooser() {
          setTitle("Font Chooser Window");
          pan = fontsPanel();
          getContentPane().add(northPanel(), BorderLayout.NORTH);
          getContentPane().add(pan, BorderLayout.CENTER);
          getContentPane().add(southPanel(), BorderLayout.SOUTH);
          addWindowListener(new WindowAdapter(){
             public void windowClosing(WindowEvent we){
                dispose();
             public void windowDeactivated(WindowEvent we){
                dispose();
          pack();
          setLocation(200,100);
          setResizable(false);
          setVisible(true);
       private JPanel northPanel(){
          JPanel pan = new JPanel(new GridLayout(1,2));
          JPanel left = new JPanel(new GridLayout(1,1));
          JPanel right = new JPanel(new GridLayout(1,2));
          fontField = new JTextField(MyGUI.getEditorFont());
          left.add(fontField);
          String []sizes = {"10","11","12","14","16","18","20","22","24","28","32","36"};
          final JComboBox box = new JComboBox(sizes);
          box.setEditable(true);
          box.setBackground(Color.white);
          box.setMaximumRowCount(5);
          box.addItemListener(new ItemListener(){
             public void itemStateChanged(ItemEvent ie){
                try{
                   size = Integer.parseInt(box.getSelectedItem().toString());
                   pane.setFont(new Font(fontSelected,0,size));         
                }catch(ArithmeticException ae){ pane.setFont(new Font("",0,12));
                }catch(NumberFormatException nfe){ pane.setFont(new Font("",0,12)); }
          right.add(new JLabel("   font size:"));
          right.add(box);
          pan.add(left);
          pan.add(right);
          pan.setPreferredSize(new Dimension(pan.getWidth(), 20));
          return pan;
       private JPanel fontsPanel(){
          pan = new JPanel(new GridLayout(1,2));
          GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
          String fonts[] = ge.getAvailableFontFamilyNames();
          final JList FONT_LIST = new JList(fonts);
          FONT_LIST.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
          FONT_LIST.setVisibleRowCount(7);
          FONT_LIST.addListSelectionListener(new ListSelectionListener(){
          public void valueChanged(ListSelectionEvent lse) {
             fontSelected = FONT_LIST.getSelectedValue().toString();
             sample.setFont(new Font(fontSelected,0,14));
             try{
                pane.setFont(new Font(fontSelected,0,size));
             }catch(ArithmeticException ae){ pane.setFont(new Font("",0,12));
             }catch(NumberFormatException nfe){ pane.setFont(new Font("",0,12)); }
             fontField.setText(fontSelected);
          JScrollPane scroll = new JScrollPane(FONT_LIST);
          pane =  new JTextPane(){
             public void setSize(Dimension d) {   
                if(d.width < pan.getWidth()) d.width = pan.getWidth();
                   super.setSize(d);
             public boolean getScrollableTracksViewportWidth(){ return false; }
          pane.setEditable(false);
          pane.setText("\n\n   Some text\n   to view in the\n      display window\n");
          JScrollPane text = new JScrollPane(pane);
          pan.add(scroll);
          pan.add(text);
          return pan;
       private JPanel southPanel(){
          JPanel pan =new JPanel(new GridLayout(1,2));
          JPanel left =new JPanel();
          JPanel right =new JPanel();
          sample = new JLabel("AaBbCcDdEe 12345", JLabel.CENTER);
          JButton select = new JButton("Select");
          select.addActionListener(new ActionListener(){
             public void actionPerformed(ActionEvent e){
                MyGUI.textPane.setFont(new Font(fontSelected,0,size));
                MyGUI.myMessageLabel.setText("  Font : "+fontSelected+"  size "+size+"  ");
          JButton cancel = new JButton("Cancel");
          cancel.addActionListener(new ActionListener(){
             public void actionPerformed(ActionEvent e){
                dispose();
          left.add(sample);
          right.add(select);
          right.add(cancel);
          pan.add(left);
          pan.add(right);
          return pan;

  • Changing the size of a JComboBox

    Greetings,
    I am trying to build a mechanism to perform zooming on a JPanel with an arbitrary collection of components (including nested JPanels). I've tried a number of things with little success. The following is my most promising contraption. It can zoom labels, textfields, checkboxes, and buttons. However, for some reason, the combo box refuses to accept a changes to its size. I'm not sure why this is the case. Its font changes size appropriately.
    Anyway, I'm running in JDK 1.4, and the following program lays out a palette of components. To change the size of the components, hit F1 to zoom in, and F2 to zoom out.
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Dimension;
    import java.awt.Font;
    import java.awt.KeyEventPostProcessor;
    import java.awt.KeyboardFocusManager;
    import java.awt.event.KeyEvent;
    import java.awt.geom.AffineTransform;
    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class Demo extends JPanel
        public class Zoomer
            private double m_zoom = 1;
            private JPanel m_panel;
            public Zoomer(JPanel panel)
                m_panel = panel;
            private AffineTransform getTransform()
                return AffineTransform.getScaleInstance(m_zoom, m_zoom);
            private Font transform(Font font)
                return font.deriveFont(getTransform());
            private Dimension transform(Dimension dimension)
                Dimension retval = new Dimension();
                retval.setSize(dimension.getWidth() * m_zoom, dimension.getHeight() * m_zoom);
                return retval;
            private void performZoom(Container container)
                Component[] components = container.getComponents();
                for(int i = 0; i < components.length; i++)
                    Component component = (Component)components;
    component.setFont(transform(component.getFont()));
    component.setSize(transform(component.getSize()));
    for(int i = 0; i < components.length; i++)
    Component component = components[i];
    if(component instanceof Container)
    performZoom((Container)component);
    public double getZoom()
    return m_zoom;
    public void setZoom(double zoom)
    if(zoom > 8.0 || zoom < 0.125) return;
    m_zoom = zoom;
    performZoom(m_panel);
    public void zoom(double factor)
    setZoom(getZoom() * factor);
    public Demo()
    JPanel panel = new JPanel();
    panel.add(buildPanel());
    panel.add(buildPanel());
    final Zoomer zoomer = new Zoomer(panel);
    add(panel);
    KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventPostProcessor(new KeyEventPostProcessor()
    public boolean postProcessKeyEvent(KeyEvent e)
    if(e.getID() != KeyEvent.KEY_PRESSED) return false;
    if(e.getKeyCode() == KeyEvent.VK_F1)
    zoomer.zoom(1.2);
    if(e.getKeyCode() == KeyEvent.VK_F2)
    zoomer.zoom(1/1.2);
    return false;
    private JPanel buildPanel()
    JPanel panel = new JPanel();
    panel.add(new JLabel("label: "));
    panel.add(new JTextField("Hello World"));
    panel.add(new JCheckBox("checkbox"));
    panel.add(new JComboBox(new String[] { "Bread", "Milk", "Butter" }));
    panel.add(new JButton("Hit Me!"));
    return panel;
    * Create the GUI and show it. For thread safety, this method should be
    * invoked from the event-dispatching thread.
    private static void createAndShowGUI()
    // Create and set up the window.
    JFrame frame = new JFrame("Demo");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // Create and set up the content pane.
    Demo newContentPane = new Demo();
    newContentPane.setOpaque(true); // content panes must be opaque
    frame.setContentPane(newContentPane);
    // Display the window.
    frame.pack();
    frame.setVisible(true);
    public static void main(String[] args)
    // Schedule a job for the event-dispatching thread:
    // creating and showing this application's GUI.
    javax.swing.SwingUtilities.invokeLater(new Runnable()
    public void run()
    createAndShowGUI();

    component.setSize(transform(component.getSize()));First of all the above line is not needed. The LayoutManager will determine the bounds (size and location) of each component in the container based on the rules of the LayoutManager. The Flow Layout is the default layout manager for a panel and it simply uses the preferred size of the component as the size of the component.
    So what happens is that when you change the font of the component you are changing the preferred size of the component.
    So why doesn't the combo box work? Well I took a look at the preferred size calculation of the combo box (from the BasicComboBoxUI) and it actually caches the preferred size. The combo box uses a renderer, so the value is cached for performance one would assume. The method does recalculate the size when certain properties change. Note the isDisplaySizeDirty flag used in the code below:
             else if (propertyName.equals("prototypeDisplayValue")) {
                    isMinimumSizeDirty = true;
                    isDisplaySizeDirty = true;
                    comboBox.revalidate();
             else if (propertyName.equals("renderer")) {
                    isMinimumSizeDirty = true;
                    isDisplaySizeDirty = true;
                    comboBox.revalidate();
                }It also handles a Font property change as well:
                else if ( propertyName.equals( "font" ) ) {
                    listBox.setFont( comboBox.getFont() );
                    if ( editor != null ) {
                        editor.setFont( comboBox.getFont() );
                    isMinimumSizeDirty = true;
                    comboBox.validate();
                }but notice that the isDisplaySizeDirty flag is missing. This would seem to be a bug (but I don't know why two flags are required).
    Anyway, the following change to your code seems to work:
    // component.setSize(transform(component.getSize()));
    if (component instanceof JComponent)
         ((JComponent)component).updateUI();
    }

  • Maximum size of a JComboBox in a GridBagLayout

    I'm having a problem with a JComboBox inside a GridBagLayout. The general layout is a GridBag with labels / combo / textfields on the first line, a large table in a scrollpane that takes all columns on the second line, and a few labels / combo / textfields on the third.
    As long as the combo on the first combo is empty, it looks fine. When it gets populated, the combo gets resized to the size of the largest text. I would like to have it smaller and truncate the text.
    I tried to set maximum size, but the GridBag doesnt care. I've been trying with weightx but no success.
    What should I do ?

    And I would be interested which LayoutManager you prefer using.I don't use a single Layout Manager. I use a combination of Layout Managers to do the job. Thats why this question doesn't have a specific example. Remember LayoutManagers can be nested. The default layout manager for a frame is a border layout. That great for the general look of your application.
    a) you add a toolbar to the north
    b) you add a status bar to the south
    c) you add your main panel to the center.
    the main panel in turrn may use nested panels depending on your requirements. I don't do a lot of screen design but I typically use BorderLayout, FlowLayout, GridLayout and BoxLayout. GridBagLayout and SpringLayout have too many constraints to learn and master. They may be good for a GUI tool that only uses a single layout manager for the entire GUI, but I believe a better design is to break down the form into smaller more manageable areas and group components and use the appropriate layout manager for the group. That may or may not be a GridBagLayout for the small group, but I don't think you should force the entire form to use a GridbagLayout.

  • Minimize size of a JComboBox

    Hi,
    i�ve got a JComboBox rendered into a JTable. This works fine but the ComboBox is much to big. I played around with setMaximumSize in several LayoutManagers. The problem is that at a certain size it cuts the JComboBox. What to do? thanks
    uri

    And I would be interested which LayoutManager you prefer using.I don't use a single Layout Manager. I use a combination of Layout Managers to do the job. Thats why this question doesn't have a specific example. Remember LayoutManagers can be nested. The default layout manager for a frame is a border layout. That great for the general look of your application.
    a) you add a toolbar to the north
    b) you add a status bar to the south
    c) you add your main panel to the center.
    the main panel in turrn may use nested panels depending on your requirements. I don't do a lot of screen design but I typically use BorderLayout, FlowLayout, GridLayout and BoxLayout. GridBagLayout and SpringLayout have too many constraints to learn and master. They may be good for a GUI tool that only uses a single layout manager for the entire GUI, but I believe a better design is to break down the form into smaller more manageable areas and group components and use the appropriate layout manager for the group. That may or may not be a GridBagLayout for the small group, but I don't think you should force the entire form to use a GridbagLayout.

  • JCombobox and internal component sizes

    Hello,
    I am using a JCombobox in a table header. I would like to change the event handling in that way, that the combobox will be opened only if the arrow button has been selected or the arrow key has been pressed.
    The problem I have is that I do not know the size or lokation of the button inside the JCombobox.
    I created a new HeaderUI where I check the mousePressed event.
    With the function getDeepestComponentAt I get a MetalComboboxButton, but the width seems to be the width of the column size.
    Doese anybody knows how to get the size of the arrow button?
    Claudia

    The API documentation for that method says:
    "Invoked when an item has been selected or deselected. The code written for this method performs the operations that need to occur when an item is selected (or deselected)."
    So, when you change the selection from 4-5-6 to 1-2-3, you deselect 4-5-6 and then select 1-2-3. Two calls result. Fortunately, the ItemEvent parameter has a method getStateChange() that returns either ItemEvent.SELECTED or ItemEvent.DESELECTED, so you can program accordingly.

  • How can I constrain the size of a JComboBox?

    How can I constrain the size of a JComboBox? My JCB is held within a Box on my JFrame. I tried using setSize(int, int) and setSize (Dimension d) but neither worked at all, and the JCB remained the same size. Right now it is equal to the size of the box, which is the entire GUI.

    tried using setSize(int, int) and setSize (Dimension d)Read the Swing tutorial on [Using Layout Managers|http://java.sun.com/docs/books/tutorial/uiswing/TOC.html]. Each layout manager is different, but you never use the setSize(...) methods.

  • JComboBox question (size of entry)

    I have a JComboBox that I am populating with a wide varying length of entries and in order not to mess up my GUI I need to constrain it to a certain size. This works but the drop down menu that is shown when the user clicks on the combo box stays the same width... I was hoping (and still holding out) that there is a way for it to be only the part on the GUI be constrained and have it expand so you can read the entire entry when the user opens up the combobox... This is how it is in web environments so does anyoen know a way I can accomplish this?

    I had these results from searching forum on the combobox horizontal scrollbar keywords:
    http://onesearch.sun.com/search/developers/index.jsp?col=devforums&qp_name=Swing&qp=forum%3A57&qt=combobox+horizontal+scrollbar
    Hope that helped,
    Regards.

  • Change the size of Scrollbar in JComboBox

    Hello,
    I want to change the width of Scrollbar that appears in JComboBox....any idea?

    Swing related questions should be posted in the Swing forum.
    You might be able to use the following. If it does work it would be for all scrollbars in your application:
    UIManager.put("ScrollBar.width", new Integer(...));

  • Hi how to create jbutton, jcombobox with same size

    hi i m just new in gui
    and i added some of buttons and comboboxes
    but i want their width to be equally sized
    regardless of their character length..
    but..
    how to do

    using null layout and set the component size
    setLayout(null);
    add(b1); \\Button
    add(c1); \\Combo bax
    b1.setBounds(0,10,30,20); \\(Left,top,width,height)
    c1.setBounds(0,35,30,20); \\(Left,top,width,height)
    this will create a button size of 30*20 at 0,10 position
    and create a Combobox size of 30*20 at 0,35 position
    try it...........

  • How do I change size of JComboBox's popup?

    I have a JComboBox. Problem is, I need the popup from this JComboBox to be wider than the JComboBox itself.
    How do I do this?

    A cross-post ... so I cross-answer ...
    Write a new UI for your JComboBox.
    Rommie.

  • JcomboBox list size is wrong if using PopupMenuListener

    Just wondering if someone else has already implmented the workaround for this bug and would be able to tell me if it was very difficult to get going.
    Basically, if you use PopupMenuListeners to populate a combo-box list dynamically when the user selects the combo, the size of the list which gets presented to the user is based on the number of entries the combo previously had, not teh size of the new list.
    http://developer.java.sun.com/developer/bugParade/bugs/4743225.html
    We were hoping that this would get fixed in v1.5, but customers are complaining so much, its getting to the point where we will have to code a work-around. Just wondering how nasty it is to do.

    Basically, if you use PopupMenuListeners to populate a combo-box list dynamically ...I guess I don't fully understand what you are attempting to do, so I guess the next question is why are you using a PopupMenuListener to dynamically change the contents of the comboBox? Why does clicking on the dropdown menu cause the contents do dynamically change? Usually the contents are change as a result of some other action by the user. Maybe some sample code will clarify what you are attempting do do and an alternative approach can be suggested.
    For example, this thread shows how to dynamically change the contents of a second combBox when a selection is made in the primary comboBox:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=428181

Maybe you are looking for

  • Error while releasing PO :  System error: block object EKKO, Key PO Number.

    Dear All, I am getting error while releasing PO :  System error: block object EKKO, Key PO Number. Please help to resolve.

  • Can anyone explain how they made this Jar file

    Hi all, I have searched the forum without luck. Lots of people asked questions about protecting their jar files but almost everyone said to either use exe file or use obfuscators. But how can I make my jar so it is not possible to open it or when you

  • ADOBE 9.1.1 UPDATE FAILURE (FIX)

    For those who have ERROR when trying to update to 9.1.3 First you must use the "Windows Installer Cleanup Tool" Remove all Adobe entries 7.0,8.0,9.0,Adobe.com,Adobe AIR, etc.,etc. Downloadhttp://www.ccleaner.com/ and Run the "Registry Scan" in this F

  • Updating a JTable using a JTable

    I am looking to update an empty JTable using the data from a JTable containing a set of data. I am aware that addRow can be used with the DefaultTableModel from previous discussions on this forum, but I have found this call isn't available when using

  • End of year as default value in date item [SOLVED]

    Hi I'd like the last day of the current year (i.e. 31.12.2008) to be the default value of an item (in Forms 6i) (Format dd.mm.rrrr). The default value in the database is TO_DATE('31.12.'||TO_CHAR(sysdate,'yyyy')) and there it works fine. In Forms I h