JComboBox with 1.4.2

i tried my applet with java 1.4.2 and wonderd, that a JComboBox' popup window was the background of a custom canvas. this worked fine with any jre version from 1.4 to 1.4.1_03.
the solution was to call
comboBox.setLightWeightPopupEnabled( false );juergen

i tested this also with 1.4.1_03 and had no problems.

Similar Messages

  • How to create a JComboBox with Dates???

    Hi... I need to create a JComboBox with Date elements...
    For example: from "Jan-01-2007" to "Mar-02-2007"
    Jan-01-2007
    Jan-02-2007
    Jan-03-2007
    Mar-01-2007
    Mar-02-2007
    Anyone know how to do it???
    Regards...

    //here is an example how to get the date
    //I think this might help you!!!
    import java.text.DateFormat;
    import java.util.Date;
    public class DateFormatExample1 {
        public static void main(String[] args) {
            // Make a new Date object. It will be initialized to the current time.
            Date now = new Date();
            // See what toString() returns
            System.out.println(" 1. " + now.toString());
            // Next, try the default DateFormat
            System.out.println(" 2. " + DateFormat.getInstance().format(now));
            // And the default time and date-time DateFormats
            System.out.println(" 3. " + DateFormat.getTimeInstance().format(now));
            System.out.println(" 4. " +
                DateFormat.getDateTimeInstance().format(now));
            // Next, try the short, medium and long variants of the
            // default time format
            System.out.println(" 5. " +
                DateFormat.getTimeInstance(DateFormat.SHORT).format(now));
            System.out.println(" 6. " +
                DateFormat.getTimeInstance(DateFormat.MEDIUM).format(now));
            System.out.println(" 7. " +
                DateFormat.getTimeInstance(DateFormat.LONG).format(now));
            // For the default date-time format, the length of both the
            // date and time elements can be specified. Here are some examples:
            System.out.println(" 8. " + DateFormat.getDateTimeInstance(
                DateFormat.SHORT, DateFormat.SHORT).format(now));
            System.out.println(" 9. " + DateFormat.getDateTimeInstance(
                DateFormat.MEDIUM, DateFormat.SHORT).format(now));
            System.out.println("10. " + DateFormat.getDateTimeInstance(
                DateFormat.LONG, DateFormat.LONG).format(now));
    }

  • Fill JComboBox with Vector from database

    Hi there,
    I have a problem with filling a JComboBox with data from a database. I can print the data in the console, but it seems to be impossible to do it in a ComboBox ...
    I tried this:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    *package client;*
    *import data.Raum;*
    *import data.RaumImpl;*
    *import java.net.MalformedURLException;*
    *import java.rmi.Naming;*
    *import java.rmi.NotBoundException;*
    *import java.rmi.RemoteException;*
    *import java.sql.SQLException;*
    *import javax.swing.JComboBox;*
    *import javax.swing.JFrame;*
    *import java.util.Vector;*
    *import verwaltung.*;
    import server.DraServer;
    * @author philipp
    public class ComboBox extends JFrame
        ComboBox(String title) throws RemoteException, SQLException, NullPointerException, MalformedURLException, NotBoundException {
        super(title);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        DraVerwaltung verwaltung = (DraVerwaltung) Naming.lookup ("rmi://localhost/DRA");
        System.out.println("Remote object created...");
        Vector raeume = verwaltung.RaumAusleser();
        Raum r;
        for (int i = 0; i < raeume.size(); i++)
            r = (Raum)raeume.elementAt(i);
    //      System.out.println ("Raum: " + r.getRaumname());
    //      System.out.println ("Raumid: " + r.getIdRaum());
         JComboBox jcb = new JComboBox(r.getRaumname());
        getContentPane().add(jcb);
        setSize(200, 50);
        setVisible(true);      
      public static void main(String[] args) throws RemoteException, SQLException, NullPointerException, MalformedURLException, NotBoundException {
        new ComboBox("Test");
    }In this case I get the following for JComboBox (line 44):
    "cannot find symbol
    symbol: constructor JComboBox(java.lang.string)
    location: class javax.swing.JComboBox"
    I tried:
    -> change "JComboBox jcb = new JComboBox(r.getRaumname());" to "JComboBox jcb = new JComboBox(raeume);"
    then I got the JComboBox, but with ... I don't know how to describe the content. It seems like a (very long) reference.
    All other tries can't be tested, because I got the problem with constructor again.
    I'm happy for an early response.
    Regards

    Now, it works!
    It looks like that:
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    package client;
    import data.Raum;
    import data.RaumImpl;
    import java.net.MalformedURLException;
    import java.rmi.Naming;
    import java.rmi.NotBoundException;
    import java.rmi.RemoteException;
    import java.sql.SQLException;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import java.util.Vector;
    import verwaltung.*;
    import server.DraServer;
    * @author philipp
    public class ComboBox extends JFrame
        ComboBox(String title) throws RemoteException, SQLException, NullPointerException, MalformedURLException, NotBoundException {
        super(title);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        DraVerwaltung verwaltung = (DraVerwaltung) Naming.lookup ("rmi://localhost/DRA");
        System.out.println("Remote object created...");
        Vector raeume = verwaltung.RaumAusleser();
        Raum r = new RaumImpl();
        Vector vJcb = new Vector();
        for (int i = 0; i < raeume.size();i++){
            r = (Raum)raeume.elementAt(i); 
            vJcb.add(r.getRaumname());
        JComboBox jcb = new JComboBox(vJcb);
        getContentPane().add(jcb);
        setSize(200, 50);
        setVisible(true);     
        public static void main(String[] args) throws RemoteException, SQLException, NullPointerException, MalformedURLException, NotBoundException {
           new ComboBox("Combo box Demo1");
    }Thanks in advantage to all!

  • How can I fill a JComboBox with a ResultSet?

    I want to fill a JComboBox with the data in ResultSet. What�s the better way to do this? Can I convert a RecordSet to a Vector and use the vector in JComboBox constructor?
    Thanks for any help.
    Renato

    Prova cosi:
    myComboBox = new JComboBox();
    ArrayList items = new ArrayList();
    ResultSet result = conn.executeQuery("SELECT BLABLA FROM BLABLA");
    while (result.next())
    items.add(result.getString(1));
    result.close();
    myComboBox.setModel(new DefaultComboBoxModel(items.toArray()));
    E' molto pi� efficiente che aggiungere gli item alla combo uno alla volta.
    G.M.

  • How can i populate the Jcombobox with the data from my jpa list? Desperate

    I need to populate my jcombobox with data from my jpa. This is my first time trying this and i just need some sample or a quick solution to this. Thanks in advance
    <code>
    public static MyNames myNames() {
    EntityManagerFactory emf = Persistence.createEntityManagerFactory("JavaTrialsPU");
    EntityManager em = emf.createEntityManager();
    em.getTransaction().begin();
    Query q = em.createNamedQuery("MyNames.findAll");
    MyNames n = (MyNames) q.getResultList();
    return n;
    public static void myCombo() {       
    comboBox = new JComboBox(????--how can i make the jcombobox display my myNames() list--?????);
    frame.add(comboBox, BorderLayout.PAGE_START);
    </code>

    Implement toString() on your entity to return whatever you want to use as a label for the combobox.
    Your need for quick solutions is very destructive to your learning process. In stead take the time and read around a little. Swing happens to have an excellent tutorial with many example programs readily available for you to pick through:
    http://docs.oracle.com/javase/tutorial/uiswing/
    And PS: you need to use \ tags in this forum.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • JComboBox with checkboxes - how to ?

    How can I implement a JComboBox with JChecBoxes as elements ?

    my first guess:
    import java.awt.BorderLayout;
    import java.awt.Component;
    import javax.swing.JCheckBox;
    import javax.swing.JList;
    import javax.swing.ListCellRenderer;
    public class CheckListCellRenderer extends JCheckBox implements
            ListCellRenderer {
        public CheckListCellRenderer() {
            setLayout(new BorderLayout());
        public Component getListCellRendererComponent(JList list, Object value,
                int index, boolean isSelected, boolean cellHasFocus) {
            return (Component) value;
    }The problem is the checkboxes are not editable....

  • JComboBox with Custon Renderer Problem

    Hi, I am using a JComboBox with a custom ListCellRenderer that changes the colors of the strings on the list depending on some circunstances. The problem is that the changes only work on the list, but when one item is finally selected, and the list is no longer visible, the selected item has the default format (no colors)
    Thanks in advance

    I am not exactly sure what you mean, but here is something I wrote that sounds similar. It allows items in the dropdown list to be highlighted (text in red). The highlighted state is maintained when the dropdown list disappears, though in this implementation a selected item has highlighting turned off (the idea was that the items are things the user needed to see, once the user had selected a item, it no longer needed to be highlighted).
    For this to work all the items in your list must implement HighlightingComboBox.Highlightable.
    import javax.swing.*;
    import java.awt.event.*;
    import java.awt.*;
    * An extension to JComboBox that allows items to be "highlighted"
    * (if they implement the HighlightingComboBox.Highlightable interface).
    * Highlighted items are shown in red. Highlighting is turned off when
    * the item is first selected. Items not impleneting that interface are
    * displayed normally. The drop-down list is rendered the same
    * regardless of the font property of the components, it is therefore
    * possible to set that property to, say, a huge, fancy font without the
    * drop-down panel being affected.
    public class HighlightingComboBox extends JComboBox
                                      implements ActionListener {
        public HighlightingComboBox() {
            super();
            addActionListener(this);
            setRenderer(new FancyRenderer());
        public HighlightingComboBox(Object[] os) {
            super(os);
            this.addActionListener(this);
            setRenderer(new FancyRenderer());
        public void actionPerformed(java.awt.event.ActionEvent ae) {
            if (getSelectedItem() instanceof Highlightable)
                ((Highlightable)getSelectedItem()).setHighlighted(false);
        private static class FancyRenderer extends JLabel
                                           implements ListCellRenderer {
            public java.awt.Component getListCellRendererComponent(
                    javax.swing.JList list,
                    Object value,
                    int index,
                    boolean isSelected,
                    boolean cellHasFocus) {
                setText(value.toString());
                if ((value instanceof Highlightable)
                           && (((Highlightable)value).isHighlighted())) {
                    setForeground(Color.red);
                } else {
                    setForeground(Color.black);
                setBackground(isSelected ? Color.yellow : Color.white);
                setForeground(Color.black);
                return this;
         * Objects that implement this interface can be
         * highlighted on a HighlightingComboBox.
        public interface Highlightable {
            public boolean isHighlighted();
            public void setHighlighted(boolean flag);
    }

  • Make a JComboBox With JTextField Appear Empty?

    greetings all
    i have a JComboBox With a JTextField
    and the JComboBox Always Appear with the First value in the array or in the vector
    but i want it to appear empty when the program runs,how to do that?

    You only want to do that if you want to allow the user to select the null value in the course of running the program. If not, Joerg22's solution is the correct one.
    db

  • JComboBox with type-ahead capabilities?

    Hi, guys:
    I have a JComboBox with a list of string items. Since the list is very long (with several hundred of items), I would like to implement someting like
    the following so that use does not have to scroll down the list to search for an item: when user types the starting letter of an item, it should locate the first item starting with this letter. IE address bar has this kind of type-ahead capability
    I am wondering how I can do the similar thing using Swing JComboBox?
    regards,

    Thanks for your sample, it works.
    Here is the "old code" I am talking about. I slightly modified it and add a main method. It looks fine, but it just does not work. I really have no clue why this one just does not work:
    import java.awt.event.KeyListener;
    import java.util.Vector;
    import javax.swing.ComboBoxModel;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    public class SelectableComboBox
        extends JComboBox
        protected boolean required;
        protected JLabel fieldLabel;
        public SelectableComboBox()
            super();
        public SelectableComboBox( final boolean required )
            super();
            this.required = required;
        public SelectableComboBox( final ComboBoxModel model )
            super( model );
        public SelectableComboBox( final Object[] objects )
            super( objects );
        public SelectableComboBox( final Vector v )
            super( v );
        public void setEnabled( final boolean b )
            super.setEnabled( b );
            if( this.fieldLabel != null )
                this.fieldLabel.setEnabled( b );
        public JLabel getLabel()
            return this.fieldLabel;
        public void setLabel( final JLabel l )
            this.fieldLabel = l;
        public JLabel createLabel( final String s )
            this.fieldLabel = new JLabel( s );
            return this.fieldLabel;
        public boolean isEquals( final String s )
            if( this.fieldLabel != null && this.fieldLabel.getText() != null
                    && s != null )
                return s.equals( this.fieldLabel.getText() );
            return false;
        public String toString()
            if( this.fieldLabel != null && this.fieldLabel.getText() != null
                    && this.fieldLabel.getText().length() > 0 )
                return this.fieldLabel.getText();
            return super.toString();
        public void setRequired( final boolean req )
            this.required = req;
        public boolean isRequired()
            return this.required;
        public JTextField getTextField()
            int total = getComponentCount();
            JTextField field = null;
            for( int i = 0; i < total; i++ )
                if( getComponent( i ) instanceof JTextField )
                    field = (JTextField) getComponent( i );
                    break;
            return field;
        public JButton getButton()
            int total = getComponentCount();
            JButton button = null;
            for( int i = 0; i < total; i++ )
                if( getComponent( i ) instanceof JButton )
                    button = (JButton) getComponent( i );
                    break;
            return button;
        public void addKeyListener( final KeyListener l )
            JTextField field = getTextField();
            if( field != null )
                field.addKeyListener( l );
        public void removeKeyListener( final KeyListener l )
            JTextField field = getTextField();
            if( field != null )
                field.removeKeyListener( l );
        public static void main( final String[] args )
            JFrame fr = new JFrame();
            fr.setSize(150,75);
              fr.setLocation(400,300);
              fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel jp = new JPanel();
              SelectableComboBox cb = new SelectableComboBox();
            cb.addItem( "Abc" );
            cb.addItem( "cbs" );
            cb.addItem( "nbc" );
            cb.addItem( "fox" );
            cb.addItem( "wb" );
            cb.addItem( "ycc" );
              jp.add(cb);
              fr.getContentPane().add(jp);
            fr.pack();
            fr.setVisible( true );
    }Appreciate your help.

  • JComboBox with Horizontal ScrollBar

    Hi all,
    I created this custom ComboBox:
    import com.sun.java.swing.*;
    import com.sun.java.swing.plaf.basic.*;
    public class myCombo extends JComboBox{
        public myCombo(){
            super();
            setUI(new myComboUI());
        public class myComboUI extends BasicComboBoxUI{
            protected ComboPopup createPopup(){
                BasicComboPopup popup = new BasicComboPopup(comboBox){
                    protected JScrollPane createScroller() {
                            return new JScrollPane( list, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
                                    ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED );
                return popup;
      {code}
    When i add this ComboBox to a Frame, it has a look and feel diffrent from the others component !
    How to resolve that ?
    Regards
    Jack                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    [removed]
    Just another cross poster.
    [http://www.coderanch.com/t/432788/Swing-AWT-SWT-JFace/java/JComboBox-with-horizontall-scroll-bar]
    Edited by: Darryl.Burke

  • JComboBox with MySQL Database

    The Agency table stores the names of possible agencies that can be selected in the first JComboBox.
    Since these agencies may have multiple locations another table is used to store Location specific information.
    AgencyID, the primary key of the Agency table is used to identify Locations.
    The Locations table stores the AgencyID as an indexed field.
    I am trying to get a second JComboBox populated with Location details pertaining to the Agency Selected.
    I am not getting any syntax errors in Netbeans 5.5, although when I compile
    I am getting multiple SQLExceptions in my result set.
    Since my java is infantile I am asking for any help you can give.
    Thanks, in advance.
    Agency JComboBox is populated via a database query as follows:
        public Main() throws Exception{
            MyDBConnection mdbc = new MyDBConnection();
            mdbc.init();
            conn = mdbc.getMyConnection();
            stmt = conn.createStatement();
            ResultSet rs_AgencyNames = getAgencyNames();
            initComponents();
            updateCboAgencyName(rs_AgencyNames);
        public ResultSet getAgencyNames() {
            ResultSet rs=null;
            try{
                rs=stmt.executeQuery("SELECT `ID`,`AgencyName` FROM `Agency`");
            }catch(SQLException e){}
            return rs;
        public void updateCboAgencyName(ResultSet rs) throws SQLException {
            while(rs.next()){
                cboAgencyName.addItem(rs.getString("AgencyName"));
        }The above worked well until I tried to move on to the second JComboBox.
    The code below, I feel, was a wild stab in the dark at populating the second JComboBox with the corresponding locations.
        public void updateCboAgencyLocation(Object value) throws SQLException {
            ResultSet rs_AgencyID = null;
            ResultSet rs_Loc = null;
            DBStatements dbS = new DBStatements();
            try{
                PreparedStatement r = conn.prepareStatement("SELECT `ID` FROM `Agency` WHERE `AgencyName` = ?");
                r.setString(1, String.valueOf(cboAgencyName.getSelectedItem()));
                rs_AgencyID = r.executeQuery();
            }catch(SQLException sqlex) {
                sqlex.printStackTrace();
            if (dbS.rowCount(rs_AgencyID) == 1){
                try{
                    PreparedStatement s = conn.prepareStatement("SELECT `LocationID`, `AgencyID`, `DelAddr`, `DelCity`, `DelState`, `DelCounty`, `DelZip` FROM `AgencyLocation` INNER JOIN `AgencyID` ON ?" );
                    s.setString(1, String.valueOf(rs_AgencyID.getInt("ID")));
                    rs_Loc = s.executeQuery();
                }catch(SQLException sqlex) {
                    sqlex.printStackTrace();
            while(rs_Loc.next()){
                //cboAgencyLocation.addItem(rs_Loc.getString("DelCity") + " " + rs_Loc.getString("DelState") + " " + rs_Loc.getString("DelCounty") + " " + rs_Loc.getString("DelZip"));
                cboAgencyLocation.addItem(rs_Loc.getString("DelAddr"));
        private void cboAgencyNameActionPerformed(java.awt.event.ActionEvent evt) {                                             
            Object value;
            value = cboAgencyName.getSelectedItem();
            try {
                updateCboAgencyLocation(value);
            } catch (SQLException ex) {
                ex.printStackTrace();
        }

    Well, you need to store two pieces of information in your first combo box:
    a) Agency Name
    b) Agency Id
    The combo box should only display the name. Then when you select the name you need to use the id to build a second query so you can populate the second combo box.
    This posting shows how to store the two pieces of information in the combo box model:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=613731
    I'll let you word out the SQL for the second query.

  • Exception raised using JComboBox with JUComboBoxBinding in a JTable

    Hello,
    I am using JDeveloper 9.0.3.1035.
    I have a JTable bound to a bc4j view object. Now I want to use a JComboBox to select the value for a foreign key column in that Table. For this I have followed the HOWTO posted by Arno van der Kolk in Thread JClient - JTable and JComboBox which extends the OTN example "How to Add a JComboBox to a Cell in a JTable". This almost works fine except for one thing:
    In the the ComboBox I display a String value but the view attribute is of type Number. Now when I edit the column using the ComboBox and the value of the selected entry cannot be converted to Number I get an exception like the following:
    oracle.jbo.domain.DataCreationException: JBO-25009: Cannot create an object of type:oracle.jbo.domain.Number with value:030522 001
    Even after this exception is raised the database record is updated with the correct number value corresponding to the selected entry when the changes are commited. The only w/a I have found so far is to display the foreign key attribute as the first column of the JComboBox but this is not what I want. This behaviour also occurs using the aforementioned OTN example with my JDev version but the sample works with JDev 9.0.2.
    How can I get this to work using JDev 9.0.3?
    Any help is greatly appreciated.
    Regards,
    Christof Breker

    The Thread I was really referring to is:
    [JClient] HOWTO: Using databound comboboxes (for foreign keys) in a JTable
    The OTN sample can be found under:
    http://otn.oracle.com/sample_code/products/jdev/jclient/jclient_table_combo_sample.html

  • JComboBox With JTable as Editor

    Hi everybody
    I'm working with JTable and having a ComboBox as first CellEditor. for that purpose i used following code
            cmbFeeType.setModel(new javax.swing.DefaultComboBoxModel(DefaultFee.FeeTypeItemList()));       
            DefaultCellEditor DCEFeeType = new DefaultCellEditor(cmbFeeType);
            DCEFeeType.setClickCountToStart(2);here DefaultFee.FeeTypeItemList is a vector returns array. This is working fine except that the ComboBox remains visible till I dobule clik on a column for editing. Then It becomes invisible and works fine.
    my JComboBox is a seperate Control on a JFrame I do not want to use
    Class FeeTypeEditor extends JComboBox implements TableCellEditoras a ComboBox editor for JTable
    Please Help Me.

    Hi
    I am giving u a sample code which simulate the error
    * TestJTable.java
    * Created on August 5, 2008, 11:05 AM
    package TestJTable;
    import javax.swing.DefaultCellEditor;
    import javax.swing.table.TableColumn;
    * @author  yogi
    public class TestJTable extends javax.swing.JFrame {
        /** Creates new form TestJTable */
        public TestJTable() {
            initComponents();
            DefaultCellEditor ColumnEditor = new DefaultCellEditor(jComboBox1);
            ColumnEditor.setClickCountToStart(2);
            TableColumn column = jTable1.getColumnModel().getColumn(0);
            column.setCellEditor(ColumnEditor);       
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        private void initComponents() {
            jScrollPane1 = new javax.swing.JScrollPane();
            jTable1 = new javax.swing.JTable();
            jComboBox1 = new javax.swing.JComboBox();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(null);
            jTable1.setModel(new javax.swing.table.DefaultTableModel(
                new Object [][] {
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null}
                new String [] {
                    "Title 1", "Title 2", "Title 3", "Title 4"
            jScrollPane1.setViewportView(jTable1);
            getContentPane().add(jScrollPane1);
            jScrollPane1.setBounds(10, 10, 340, 180);
            jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
            getContentPane().add(jComboBox1);
            jComboBox1.setBounds(180, 220, 120, 20);
            pack();
        }// </editor-fold>//GEN-END:initComponents
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    TestJTable TJTable = new TestJTable();
                    TJTable.setExtendedState(MAXIMIZED_BOTH);               
                    TJTable.setVisible(true);
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JComboBox jComboBox1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTable jTable1;
        // End of variables declaration//GEN-END:variables
    }Above code is generated by Netbeans IDE 6.0
    My promblem is that when you run the code the combobox JComboBox1 remains visible till i starts to edit the Table after once started editing it disappears.
    I want to avoid this
    thanks in advance

  • JComboBox with 2 or more columns

    I think this topic has been discussed here several times. However, I was not able to find a clear example on how to do this thing.
    I need a combo box (JComboBox) to display 2 or 3 columns with data from a database. I have no clue what to do. I have tried several things without any result. If anyone can send me some code I'd apprecite it. (email: [email protected])
    Thanks in advanced.

    This thread has a working example:
    http://forum.java.sun.com/thread.jsp?forum=57&thread=425824

  • JComboBox with Generics

    Hi,
    I have a class with two fields/propertys. Like this:
    public class TestClass {
         private string myCode = "";
         private string myDescription = "";
         public TestClass (String Code, String Description) {
              this.myCode = Code;
              this.myDescription = Description;
         public List<TestClass> getAll() {
              List<TestClass> lTest = new ArrayList<TestClass>();
              lTest.Add(new TestClass("AA", "Abcdef");
              lTest.Add(new TestClass("BB", "Bcdefg");
              lTest.Add(new TestClass("CC", "Cdefgh");
              lTest.Add(new TestClass("DD", "Defghi");
              return
    I want to fill a jComboBox and I have used this code:
    jComboBox1.setModel(new DefaultComboBoxModel(new Vector(new TestClass().getAll())));
    But the results was:
    [ AA ]
    [ BB ]
    [ CC ]
    [ DD ]
    And the results that I want is:
    [ Abcdef ]
    [ Bcdefg ]
    [ Cdefgh ]
    [ Defghi ]
    With the Key "AA" or "BB" or "CC" or "DD".
    In C# (framework 2.0) you can bind this method, that returns a List of the class, specifying who will be the key and who will be the value/description.
    I can do this in Java?
    T#

    Check out my answer in this posting:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=613731

Maybe you are looking for

  • How can i enable my iTunes account ?

    My account has been disabled and so now i can't make any more purchases and i have tryed to search it online but it doesn't seem to watch with the new iTunes so i was wondering if anyone could help me! And i really don't want to make a new account si

  • Not booting, clicking sound

    So yesterday I came home, and the computer was in sleep mode which is normal.  I clicked the mouse as I always do to do some work but nothing happened.  So I rebooted the whole thing. I came back after supper to find my iMac off.  I did not turn it o

  • Set autocommit= off in JDBC driver

    Hi, i'm running jdev v. 11.1.2.4 and deploying a simple ADF application on glassfish against a mySQL database v 5.1..... when i commit my changes to the database i receive an exception: at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractTh

  • How do I get deleted photos back???

    How do I get deleted photos back???

  • OBIEE Map views and Google controls

    Hi All, I have OBIEE set up for map views using Google maps as the background map. However it now appears to be showing 2 zoom controls, one from OBIEE and one from the background Google maps. Does anyone know how to configure Mapviewer to turn off t