?
Solved

Swing Combobox Doesn't "Drop Down"

Posted on 1999-11-12
8
Medium Priority
?
356 Views
Last Modified: 2013-11-23
I'm fairly new to Java, so bear with me.

I am creating an applet (using Visual Cafe) and have added a Swing Combobox.

When the applet is run, and I click on the combobox, the list portion doesn't appear.  The Combobox highlights, and with the arrow keys I can cycle through the list, but I need it to drop so that I can select.
0
Comment
Question by:clifABB
8 Comments
 
LVL 7

Expert Comment

by:vladi21
ID: 2203868
post ur code
0
 
LVL 6

Author Comment

by:clifABB
ID: 2203886
/*
      A basic extension of the java.applet.Applet class
 */

import java.awt.*;
import java.applet.*;
import com.sun.java.swing.JLabel;
import com.sun.java.swing.JTextField;
import com.symantec.itools.swing.borders.BevelBorder;
import com.symantec.itools.swing.borders.EtchedBorder;
import com.symantec.itools.swing.borders.MatteBorder;
import com.symantec.itools.swing.borders.SoftBevelBorder;
import com.symantec.itools.swing.borders.TitledBorder;
import com.symantec.itools.swing.borders.CompoundBorder;
import com.symantec.itools.swing.borders.EmptyBorder;
import com.sun.java.swing.JTable;
import com.sun.java.swing.table.*;
import com.sun.java.swing.JScrollPane;
import com.symantec.itools.swing.models.StringComboBoxModel;
import com.symantec.itools.swing.models.StringTableModel;
import com.sun.java.swing.JComboBox;
import java.sql.*;
import oracle.dacf.dataset.*;

public class DDTableInfoVC extends Applet
{
      public void init()
      {
            // Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller
            //symantec.itools.lang.Context.setApplet(this);
      
            // This code is automatically generated by Visual Cafe when you add
            // components to the visual environment. It instantiates and initializes
            // the components. To modify the code, only use code syntax that matches
            // what Visual Cafe can generate, or Visual Cafe may be unable to back
            // parse your Java file into its visual environment.
            //{{INIT_CONTROLS
            setLayout(null);
            setBackground(java.awt.Color.lightGray);
            setSize(566,472);
            JLabel1.setText("Table Name:");
            add(JLabel1);
            JLabel1.setBounds(12,12,99,19);
            JLabel2.setText("Description:");
            add(JLabel2);
            JLabel2.setBounds(12,36,99,19);
            JLabel3.setText("Type:");
            add(JLabel3);
            JLabel3.setBounds(12,60,99,19);
            JLabel4.setText("Download Flag:");
            add(JLabel4);
            JLabel4.setBounds(12,84,99,19);
            JLabel5.setText("Upload Flag:");
            add(JLabel5);
            JLabel5.setBounds(156,84,99,19);
            JLabel6.setText("Version:");
            add(JLabel6);
            JLabel6.setBounds(336,12,99,19);
            softBevelBorder1.setBevelType(com.sun.java.swing.border.BevelBorder.LOWERED);
            //$$ softBevelBorder1.move(72,473);
            lblDescription.setOpaque(true);
            lblDescription.setBorder(softBevelBorder1);
            add(lblDescription);
            lblDescription.setBackground(java.awt.Color.white);
            lblDescription.setForeground(java.awt.Color.black);
            lblDescription.setFont(new Font("SansSerif", Font.PLAIN, 12));
            lblDescription.setBounds(108,36,192,19);
            lblType.setOpaque(true);
            lblType.setBorder(softBevelBorder1);
            add(lblType);
            lblType.setBackground(java.awt.Color.white);
            lblType.setForeground(java.awt.Color.black);
            lblType.setFont(new Font("SansSerif", Font.PLAIN, 12));
            lblType.setBounds(108,60,96,19);
            lblDLFlag.setOpaque(true);
            lblDLFlag.setBorder(softBevelBorder1);
            add(lblDLFlag);
            lblDLFlag.setBackground(java.awt.Color.white);
            lblDLFlag.setForeground(java.awt.Color.black);
            lblDLFlag.setFont(new Font("SansSerif", Font.PLAIN, 12));
            lblDLFlag.setBounds(108,84,19,19);
            lblULFlag.setOpaque(true);
            lblULFlag.setBorder(softBevelBorder1);
            add(lblULFlag);
            lblULFlag.setBackground(java.awt.Color.white);
            lblULFlag.setForeground(java.awt.Color.black);
            lblULFlag.setFont(new Font("SansSerif", Font.PLAIN, 12));
            lblULFlag.setBounds(228,84,19,19);
            lblVersion.setOpaque(true);
            lblVersion.setBorder(softBevelBorder1);
            add(lblVersion);
            lblVersion.setBackground(java.awt.Color.white);
            lblVersion.setForeground(java.awt.Color.black);
            lblVersion.setFont(new Font("SansSerif", Font.PLAIN, 12));
            lblVersion.setBounds(396,12,96,19);
            JScrollPane1.setOpaque(true);
            add(JScrollPane1);
            JScrollPane1.setBounds(12,108,547,349);
            grdMain.setModel(mdlGrid);
            grdMain.setRowSelectionAllowed(false);
            grdMain.setAutoResizeMode(com.sun.java.swing.JTable.AUTO_RESIZE_LAST_COLUMN);
            JScrollPane1.getViewport().add(grdMain);
            grdMain.setBounds(0,0,544,327);
            {
                  String[] tempString = new String[1];
                  tempString[0] = " , , , , , , , ";
                  mdlGrid.setItems(tempString);
            }
            mdlGrid.setColumnHeaders("Column Name,Seq,Key,Type,Length,Nulls,UOM,Description");
            //$$ mdlGrid.move(96,473);
            add(cboTables);
            cboTables.setBounds(108,12,192,19);
            //}}
      }
      
      //{{DECLARE_CONTROLS
      com.sun.java.swing.JLabel JLabel1 = new com.sun.java.swing.JLabel();
      com.sun.java.swing.JLabel JLabel2 = new com.sun.java.swing.JLabel();
      com.sun.java.swing.JLabel JLabel3 = new com.sun.java.swing.JLabel();
      com.sun.java.swing.JLabel JLabel4 = new com.sun.java.swing.JLabel();
      com.sun.java.swing.JLabel JLabel5 = new com.sun.java.swing.JLabel();
      com.sun.java.swing.JLabel JLabel6 = new com.sun.java.swing.JLabel();
      com.symantec.itools.swing.borders.SoftBevelBorder softBevelBorder1 = new com.symantec.itools.swing.borders.SoftBevelBorder();
      com.sun.java.swing.JLabel lblDescription = new com.sun.java.swing.JLabel();
      com.sun.java.swing.JLabel lblType = new com.sun.java.swing.JLabel();
      com.sun.java.swing.JLabel lblDLFlag = new com.sun.java.swing.JLabel();
      com.sun.java.swing.JLabel lblULFlag = new com.sun.java.swing.JLabel();
      com.sun.java.swing.JLabel lblVersion = new com.sun.java.swing.JLabel();
      com.sun.java.swing.JScrollPane JScrollPane1 = new com.sun.java.swing.JScrollPane();
      com.sun.java.swing.JTable grdMain = new com.sun.java.swing.JTable();
      com.symantec.itools.swing.models.StringTableModel mdlGrid = new com.symantec.itools.swing.models.StringTableModel();
      com.sun.java.swing.JComboBox cboTables = new com.sun.java.swing.JComboBox();
      //}}

      public void start() {
          loadTableList();
          setupGrid();
      }
      
      public void loadTableList() {
      cboTables.addItem("Line 1");
        cboTables.addItem("Line 2");
        cboTables.addItem("Line 3");
        cboTables.addItem("Line 4");
        cboTables.addItem("Line 5");
      }


}
0
 
LVL 7

Expert Comment

by:vladi21
ID: 2203908
cboTables.setBounds(108,12,192,19);

try
cboTables.setBounds(108,12,192,100); :)

or better use normal layout
setLayout(null);  - very bad

0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
LVL 6

Author Comment

by:clifABB
ID: 2204021
vladi21:
"cboTables.setBounds(108,12,192,100);"
Tried that.  It made the combo box bigger, but it still didn't drop down.

The Layout produced an interesting effect.  I tried changing the layout to one of the various default selections that Visual Cafe allows and it completely screwed up the control positions of my applet.  However, the Combobox was still visible, and it did drop down.  So, now the question is, how do I keep the position of all my controls, and have the combo box drop down as well?
0
 
LVL 1

Expert Comment

by:vivexp
ID: 2204896
Try this out!!!

public void setPopupVisible(boolean v)

eg:
public void setPopupVisible(true)
0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 200 total points
ID: 2206149
don't mix AWT and Swing components.
extend JApplet instead of java.awt.Applet.
0
 
LVL 6

Author Comment

by:clifABB
ID: 2208112
vivexp:
I tried as you suggested and nothing is different.
0
 
LVL 6

Author Comment

by:clifABB
ID: 2208116
heyhey_:
What you suggested works perfectly.  Thanks for the help.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month3 days, 13 hours left to enroll

600 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question