JComboBox problem.

Hi All,
I have a JComboBox to which i added an actionlistener. On selecting 'New Data' it will popup another window to add a new data. This works fine when i use my mouse for selection where as when I use the keyboard for selection after the poped up window is closed it throws exception in the client console.
Can anybody help me in this... Thanx in advance..
The exception is:
Exception occurred during event dispatching:
java.lang.NullPointerException
at javax.swing.plaf.basic.BasicComboBoxUI.selectNextPossibleValue(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsComboBoxUI.access$600(Unknown Source)
at com.sun.java.swing.plaf.windows.WindowsComboBoxUI$DownAction.actionPerformed(Unknown Source)
at javax.swing.SwingUtilities.notifyAction(Unknown Source)
at javax.swing.JComponent.processKeyBinding(Unknown Source)
at javax.swing.JComponent.processKeyBindings(Unknown Source)
at javax.swing.JComponent.processKeyEvent(Unknown Source)
at javax.swing.JComboBox.processKeyEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.Dialog$1.run(Unknown Source)
at java.awt.Dialog.show(Unknown Source)

here is the code to reproduce the above exception. Exception thrown when key board arrow keys are used to navigate.
* ComboBoxProblem.java
* Created on June 15, 2006, 12:40 PM
package ComboBox;
* @author  prabus
public class ComboBoxProblem extends javax.swing.JFrame {
    /** Creates new form ComboBoxProblem */
    public ComboBoxProblem() {
        initComponents();
    /** 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.
    private void initComponents() {//GEN-BEGIN:initComponents
        java.awt.GridBagConstraints gridBagConstraints;
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
        jPanel1.setLayout(new java.awt.GridBagLayout());
        jLabel1.setText("Subjects");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 0);
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel1.add(jLabel1, gridBagConstraints);
        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "All", "New Subject" }));
        jComboBox1.setPreferredSize(new java.awt.Dimension(150, 24));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel1.add(jComboBox1, gridBagConstraints);
        jLabel2.setText("Course");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel1.add(jLabel2, gridBagConstraints);
        jTextField1.setPreferredSize(new java.awt.Dimension(150, 24));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 10);
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel1.add(jTextField1, gridBagConstraints);
        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
        jPanel2.setBorder(new javax.swing.border.EtchedBorder());
        jButton1.setText("OK");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
        jPanel2.add(jButton1);
        jButton2.setText("Cancel");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
        jPanel2.add(jButton2);
        getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
        pack();
    }//GEN-END:initComponents
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // Add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jButton2ActionPerformed
    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        // Add your handling code here:
        if((jComboBox1.getSelectedItem().toString()).equals("New Subject"))
            jComboBox1.updateUI();
            AddSubject add = new AddSubject();
            add.show();
            updateSubjectCombo();
    }//GEN-LAST:event_jComboBox1ActionPerformed
    private String newSubject = null;
    public void setNewSubject(String newsub)
        newSubject = newsub;
    private void updateSubjectCombo()
        javax.swing. DefaultComboBoxModel model = new javax.swing. DefaultComboBoxModel();
        model.addElement("All");
        model.addElement("New Subject");
        model.addElement(newSubject);
        jComboBox1.setModel(model);
        jComboBox1.setSelectedIndex(jComboBox1.getItemCount() - 1);
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // Add your handling code here:
        System.out.println(" Course : "+jTextField1.getText());
        for(int i = 0; i < jComboBox1.getItemCount(); i++)
            System.out.println(" Subject "+i+ " : " +jComboBox1.getItemAt(i));
    }//GEN-LAST:event_jButton1ActionPerformed
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        System.exit(0);
    }//GEN-LAST:event_exitForm
     * @param args the command line arguments
    public static void main(String args[]) {
        new ComboBoxProblem().show();
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables
Another Class
* AddSubject.java
* Created on June 15, 2006, 12:51 PM
package ComboBox;
* @author  prabus
public class AddSubject extends javax.swing.JFrame {
    /** Creates new form AddSubject */
    public AddSubject() {
        initComponents();
    /** 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.
    private void initComponents() {//GEN-BEGIN:initComponents
        java.awt.GridBagConstraints gridBagConstraints;
        jPanel1 = new javax.swing.JPanel();
        jLabel1 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jPanel2 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                exitForm(evt);
        jPanel1.setLayout(new java.awt.GridBagLayout());
        jLabel1.setText("Subject Name");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel1.add(jLabel1, gridBagConstraints);
        jTextField1.setPreferredSize(new java.awt.Dimension(150, 24));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        jPanel1.add(jTextField1, gridBagConstraints);
        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
        jPanel2.setBorder(new javax.swing.border.EtchedBorder());
        jButton1.setText("OK");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
        jPanel2.add(jButton1);
        jButton2.setText("Cancel");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
        jPanel2.add(jButton2);
        getContentPane().add(jPanel2, java.awt.BorderLayout.SOUTH);
        pack();
    }//GEN-END:initComponents
    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        // Add your handling code here:
        System.exit(0);
    }//GEN-LAST:event_jButton2ActionPerformed
    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        // Add your handling code here :
       String newsub = jTextField1.getText().trim();
        ComboBoxProblem prob = new ComboBoxProblem();
        prob.setNewSubject(newsub);
        System.exit(0);
    }//GEN-LAST:event_jButton1ActionPerformed
    /** Exit the Application */
    private void exitForm(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_exitForm
        System.exit(0);
    }//GEN-LAST:event_exitForm
     * @param args the command line arguments
    public static void main(String args[]) {
        new AddSubject().show();
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables
}

Similar Messages

  • Strange JComboBox problem

    I have a weird JComboBox problem that has me stumped. I am dynamically changing the contents of a JComboBox after creation. When the change function is called it removes all existing contents from the JComboBox and then repopulates it. It is really straight forward. The strange thing is that it is working perfectly under Windows 2000 with JRE build 1.3.0, but with Windows XP I end up an empty JComboBox. I don't even know where to start debugging this. Any ideas?
    Thanks

    I notice the same problem... with no solution for the moment...

  • JComboBox problem again..

    I have a problem not entirely dissimilar to Jofin's.
    My combo box is populated on 10 seconds pulses by a remote server.
    Once a value has been selected from the combobox, it auto populates two jTextFields below based on the selection made from the box.
    My problem is as soon as the 10 second pulse comes around, the JComboBox contents is refreshed/repopulated, the selected index jumps back to 0 and the text boxes below are updated based on the element at 0.
    I can't seem to get the combination of event handling right, I've tried mousePressed, but that seems to be on the jComboBox its self rather than the selected item, I've tried mouseReleased with some success but the user MUST click and hold then release on the correct item or it doesn't work.
    Any help on the matter would be very much appreciated.
    Thanks.
    Andy

    I need to select live items from an auction which are displayed in a drop down list to bid on in an auction program.
    users select an item: http://www.andywebb.me.uk/jcombobox.jpg
    item populates bid section: http://www.andywebb.me.uk/jcombobox2.jpg
    the items last a specific amount of time (this is an assignment, not a real program) and CAN disappear from the list of available items to bid on. I need a way of holding the values of the item being bidded on and a way of controlling how to display the items that are available to bid on.
    The items index in the list is irrelevant, i'm simply using the combo box item which is being clicked to populate the fields below.

  • JpopupMenu with a JComboBox problem

    Hi,
    Well I need to make a popupMenu which contains a JComboBox, when I invoke the method show(, ,) of the popupMenu, everything looks fine.
    But when I press on the comboBox to view its data, I can only see the drop list and the popupMenu disappears.
    The problem occurs after that, when I try to choose a selection from the comboBox list, it also disappears without invoking the listener.
    I believe it might be a focusing problem.
    If anyone has a solution, I'd appreciate it??
    Thanks & Regards,
    ES_Coders

    An other solution is to work use a BasicComboPopup
    - import javax.swing.plaf.basic.BasicComboPopup -
    It works quiet well
    You can use a normal JComboBox for storing the entrys.
    See the documentation of the class.
    You should only watch for the add or remove methods. Those methods must be invoked on the JComboBox not on the BasicComboPopup.
    Olek

  • Accessibility of JComboBox problem

    Hi everyone!
    I've got two applications. One of them make changes in the components of the other one through the Accessibility API. (Both are running on the same VM)
    I make changes without problem in JButton, JTextComponent...
    But I've got a JComboBox with 4 options, and the "reader/writer" application has to select the third option, and I can't get a way to do this with Accessibility.
    I can see the JComboBox and its internal structure (a Viewport, a BasicPopUp, a JPanel, ScrollButtons, a ComboList, and the four options).
    The only available action is in the JComboBox and is the togglePopUp that toggles it without problem.
    But I can't get a way to select one of the options of the toggled up pop up.
    Does anybody has an example code for doing this?
    Thank you a lot!
    AC

    Works fine for me.
    If you need further help then you will need to provide [url http://www.physci.org/codes/sscce.jsp]Simple Demo Code that demonstrates the problem.

  • JComboBox problem (another one)

    I'm using a JComboBox with a LOV.
    1) The combo-box is sized for the largest LOV. Can I have different widths for the drop-down and the combo-box itself? Is the model setting the preferredSize of my JComboBox?
    2) If the first dropdown value is rather short, then when a long selection is chosen, the value is shown truncated with ... after it. If the first dropdown value is as long as the selected one, then the value is displayed correctly.
    Regards,
    Tony Clulow

    Fliz:
    Welcome to the Apple Discussions. Yes I believe it an issue with the Helvetica Neue font. Open Font Book and deactivate the font. Then reactivate it and launch iPhoto. That should fix it.
    Do you Twango?
    TIP: For insurance against the iPhoto database corruption that many users have experienced I recommend making a backup copy of the Library6.iPhoto database file and keep it current. If problems crop up where iPhoto suddenly can't see any photos or thinks there are no photos in the library, replacing the working Library6.iPhoto file with the backup will often get the library back. By keeping it current I mean backup after each import and/or any serious editing or work on books, slideshows, calendars, cards, etc. That insures that if a problem pops up and you do need to replace the database file, you'll retain all those efforts. It doesn't take long to make the backup and it's good insurance.
    I've written an Automator workflow application (requires Tiger), iPhoto dB File Backup, that will copy the selected Library6.iPhoto file from your iPhoto Library folder to the Pictures folder, replacing any previous version of it. It's compatible with iPhoto 08 libraries. You can download it at Toad's Cellar. Be sure to read the Read Me pdf file.

  • JComboBox problem pls help me...............

    I have a JComboBox at the bottom of the screen. Depending on the value change in it i m setting that value into a table. Since the JComboBox has huge items the drop down goes out of the form. So if i select a item. It will not come to the table. If i make this drop down to come upside then the combo box will be inside the form..so that i can select an item.
    Please can any one tell me how to make the popup of the combo box to come upside????????????

    are you try to set combo ui. it would solve you problem

  • JComboBox Problem !!!!!!!!!!!!!!!! PLzzzzzzzzzz Help me out frnds...

    Hiiiiiii frmdsss...........im n deep trouble and need ur help immediately......im havin this prob with JComboBox....heres d code.....
    public void actionPerformed(ActionEvent ae)
              JButton source=(JButton)ae.getSource();
              //JComboBox source1=(JComboBox)ae.getSource();
              if(b1.equals(source))
                   cb1.setEnabled(true);
                   try
                        cb1.removeActionListener(this);
                        cb1.removeAllItems();
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                        con=DriverManager.getConnection("jdbc:odbc:MyDataSource","sa","");
                        stmt=con.createStatement();
                        rs=stmt.executeQuery("select prod_model from product where prod_type LIKE 'Mobile'");
                        while(rs.next())
                             cb1.addItem(String.valueOf(rs.getString(1)));
                        con.close();
                   }catch(ClassNotFoundException c)
                        System.out.println("Error "+c);
                   catch(SQLException e)
                        System.out.println("Exception"+e.toString());
                   cb1.addActionListener(this);
    if(ae.getSource() == cb1)
                   /*try
                   {          //cb1.removeActionListener(this);
                             //Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
                             /*con=DriverManager.getConnection("jdbc:odbc:MyDataSource","sa","");
                             String selected_id=cb1.getSelectedItem().toString();
                             stmt=con.createStatement();
                             rs=stmt.executeQuery("SELECT * FROM PRODUCT WHERE prod_model LIKE 'S%'");
                             if(rs.next())
                                  JOptionPane.showMessageDialog(fr,"USER NAME IDENTIFIED","CONFIRMATION",JOptionPane.INFORMATION_MESSAGE);
                             con.close();          
                   /*catch(ClassNotFoundException c)
                        System.out.println("Error "+c);
                   catch(SQLException e)
                        System.out.println("EXception"+e.toString());
    It gives me a huge list of errors..........
    java.lang.ClassCastException
    at Order.actionPerformed(Order.java:86)
    at javax.swing.JComboBox.fireActionEvent(Unknown Source)
    at javax.swing.JComboBox.setSelectedItem(Unknown Source)
    at javax.swing.JComboBox.setSelectedIndex(Unknown Source)
    at javax.swing.plaf.basic.BasicComboPopup$ListMouseHandler.mouseReleased
    Source)
    at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.plaf.basic.BasicComboPopup$2.processMouseEvent(Unknown So
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)...
    PLzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz help me frnds.......i hve 2 submit this prjkt on Thursdy

    The forum is fore heping out othersAnd that is exactly what I did. You won't get much help in the future if you don't change your habbits. In fact I'm surprised you got help this time.
    It's your responsibility to make a question easy to read, not to make it difficult to read by (among other things):
    a) holding the repeat key down
    b) not spelling out words
    Heck you can't even post formatted code to make it easy for people to read. Do you write your code with every line left aligned? I doubt it and we don't want to read it either.
    So learn how to use the forum properly.

  • JComboBox problem when traversing using arrow keys and it is editable

    Hello,
    The JComboBox I am using is editable and user needs to traverse the list using arrow keys as long as user is not selecting a particular item. But this is not achievable when combobox is editable. Any suggestion to get rid of that.
    regards,
    Ranjan

    Huh?import java.awt.*;
    import javax.swing.*;
    public class Test3 extends JFrame {
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        JComboBox jcb = new JComboBox(new String[] {"One","Two","Three"});
        jcb.setEditable(true);
        content.add(jcb, BorderLayout.NORTH);
        setSize(100,100);
      public static void main(String[] args) { new Test3().setVisible(true); }
    }

  • JComboBox problem? urgently needed

    hi,
    I have a combobox.. it contains a list of value.... when any one item selected, the whole list get change.. i have used action listener to perform this operation...
    but i have a problem with it... when i change the items in the combo box, again the action listener is triggered..
    i want the event to trigger only when user selects an item in the list..
    which listener to use.. i tried with itemlistener.. still the problem remain the same..
    i have used thread in my program, so that the screen doesnt look hanging.. Is it becoze of the thread?
    Thanks in advance.
    regards,
    Deepa Raghuraman

    Hi Deepa,
    I think I've a solution for ur problem. First and foremost u switch back to adding ItemListener to the combobox. The funda is; whenever u select one of the items in a combo or u try to remove/add anything to the combo the ItemListener Event is fired and the respective action is taken depending on the code snippet that u have in ur itemStateChanged() method (Provided u have added an ItemListener to that combo).
    The solution is whenever u want to add/remove anything to/from a combo, first do "urcombo.removeItemListener(ur class implementing ItemListener Interface)".Then perform the required task. After u have finished work on the combo u have to again add ItemListener to the combo.ie., "urcombo.addItemListener(ur class implementing ItemListener Interface)".
    I hope this will definately help u. Do post back with the answer after u have tried the above stunt.
    Happy Coding.
    Sachin Shanbhag

  • JButton and JComboBox problems!!!

    I have a program that has a bunch of different panels, and each of those has panels in it and soforth. Several levels down the line I add a JPanel that has a JComboBox, some JButtons and a JTextField. The textfield works fine: you can type in text, etc. However, I cannot click the JButtons (when you mouse over them, they change color appropriately, but clicking does nothing visually, and the ActionListener does not catch anything). In addition, when clicked, the JComboBox displays in a totally inappropriate area!!! (see screenshot below)
    http://www.duke.edu/~yv2/JComboBox.JPG <-- SCREENSHOT
    Any ideas?

    However, I cannot click the JButtons (when you mouse
    over them, they change color appropriately, but
    clicking does nothing visually, and the
    ActionListener does not catch anything).Make sure you have added the ActionListener to the JButton, and provide implementation for the actionPerformed() method.

  • Binding JComboBox problems

    So I'm getting an error when I try to save the changes made from a bound combobox:
    Exception Description: Missing mapping for field [GALAXYY.USER_TYPE.id].
    Descriptor: RelationalDescriptor(toast.crud.UserType --> [DatabaseTable(GALAXYY.USER_TYPE)])
    So I have my combobox bound to a JTable's column and it looks fine when I'm using it. Changes in the combo box are reflected in the jtable, but when I save I get the above error!
    Here is a snip from the USER table class....
    @JoinColumn(name = "TYPE", referencedColumnName = "ID")
    @ManyToOne
    private UserType type;The combo box is populated with values from the USER_TYPE table.
    Does anyone have any idea what is going on? Let me know if you need information! :) Thanks

    Here is the full error:
    javax.persistence.RollbackException: Exception [TOPLINK-45] (Oracle TopLink Essentials - 2.0.1 (Build b09d-fcs (12/06/2007))): oracle.toplink.essentials.exceptions.DescriptorException
    Exception Description: Missing mapping for field [GALAXYY.USER_TYPE.id].
    Descriptor: RelationalDescriptor(toast.crud.UserType --> [DatabaseTable(GALAXYY.USER_TYPE)])
    at oracle.toplink.essentials.internal.ejb.cmp3.transaction.base.EntityTransactionImpl.commit(EntityTransactionImpl.java:120)
    at oracle.toplink.essentials.internal.ejb.cmp3.transaction.EntityTransactionImpl.commit(EntityTransactionImpl.java:60)
    at toast.crud.UserCRUD.saveButtonActionPerformed(UserCRUD.java:436)
    Save Code: (generated by Netbeans)
            try {
                entityManager.getTransaction().commit();
                entityManager.getTransaction().begin();
            } catch (RollbackException rex) {
                int row = this.masterTable.getSelectedRow();
                entityManager.getTransaction().begin();
                List<toast.crud.Users> merged = new ArrayList<toast.crud.Users>(list.size());
                for (toast.crud.Users u : list) {
                    merged.add(entityManager.merge(u));
                list.clear();
                list.addAll(merged);
                rex.printStackTrace()
            }Binding Code for ComboBox:
    JComboBoxBinding jComboBoxBinding = SwingBindings.createJComboBoxBinding(AutoBinding.UpdateStrategy.READ, userTypeList, positionCombo);
    bindingGroup.addBinding(jComboBoxBinding);
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, masterTable,
          ELProperty.create("${selectedElement.type}"), positionCombo, BeanProperty.create("selectedItem"));
    bindingGroup.addBinding(binding);
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, masterTable,
          ELProperty.create("${selectedElement != null}"), positionCombo, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);Binding Code for the JTable:
    binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable,
            org.jdesktop.beansbinding.ELProperty.create("${selectedElement.color}"), colorLabel, org.jdesktop.beansbinding.BeanProperty.create("background"));
    binding.setSourceNullValue(new Color(Integer.parseInt(DB.INSTR_COLOR_DEFAULT)));
    binding.setSourceUnreadableValue(new Color(Integer.parseInt(DB.INSTR_COLOR_DEFAULT)));
    binding.setConverter(intColorConverter1);
    bindingGroup.addBinding(binding);Thanks!
    Edited by: galaxyy on Jul 22, 2008 8:22 AM
    Edited by: galaxyy on Jul 22, 2008 8:24 AM

  • About JComboBox's event

    below is resource
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class ComboBoxTest extends JFrame{
        private JLabel sqlLabel = new JLabel("SQL:");
        private JComboBox sqlComboBox = new JComboBox();
        public ComboBoxTest() {
            sqlComboBox.setEditable(true);
            sqlComboBox.addItem("");
            sqlComboBox.setBackground(Color.WHITE);
            sqlComboBox.setPreferredSize(new Dimension(500,25));
            sqlComboBox.addItemListener(new ItemListener() {
                public void itemStateChanged(ItemEvent event) {
                    if (event.getStateChange() == ItemEvent.SELECTED){
                        if(sqlComboBox.getSelectedIndex()==-1){
                            String currentSQL=(String)event.getItem();
                            System.out.println("currentSQL : "+currentSQL);
                            sqlComboBox.addItem(currentSQL);
            Container cp=getContentPane();
            cp.setLayout(new FlowLayout());
            cp.add(sqlLabel);
            cp.add(sqlComboBox);
            pack();
            setVisible(true);
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent evt) {
                    System.exit(0);
        public static void main(String[] args){
            new ComboBoxTest();
    }my intent is that let user write sql in JComboBox,this program will send sql when user click enter,and JComboBox will use addItem() to add the sql to JComboBox,
    problem is below:
    when I clicked enter one more time,why just can arosed only itemStateChanged event,I hope this program would arose itemStateChanged event when user clicked enter everytime
    another:
    when user choosed the sql that has been used addItem() to add JComboBox;
    why then clicked enter would not arose any itemStateChanged event

    1) I've answered several of your previous postings. Not once have you bothered to follow up the posting to confirm the suggestion worked, or didn't work. A simple Thank You goes a long way.
    2) Several times I've also suggested that Swing related questions should be posted on the Swing forum. (This is where the Swing experts hang out).
    3) I don't understand your question, so I can't help anyway.

  • Problem with JComboBox in a fixed JToolBar

    Hi,
    I've created a JComboBox in a JToolBar that contains all available fonts. When I click on the drop down arrow I only see the first font and a small part of the second. The JComboBox is dropped down in fact just as far as the border of the JToolbar. All the rest isn't visible to me; it seems that they are behind the other components of my JApplet. However, if I move the JToolBar from it's position (as it's a floatable component), there's no problem at all. So I'm wondering why I can't see everything when the JToolBar is docked.... Can anyone help me?
    Thanks in advance!!
    E_J

    it seems that they are behind the other components of my JApplet.Sounds like you are mixing AWT components with your Swing application. Make sure you are using JPanel, JButton ... and not Panel, Button....

  • Problem with JComboBox in aTable Cell

    I try to put JComboBox in JTableCell,
    what i want to do is something like this...
    Question | Answer |
    1. what is your favourite | a. Pizza |
    food? | b. Hot Dog |
    2. what is your favourite | a. red |
    color? | b. blue |
    Object[][] data = {
    {"1.What is your favourite food?", new AnswerChoices(new String[]{"a.Pizza","b.Hot Dog"})},
    {"2.What is your favourite color?", new AnswerChoices(new String[]{"a.red","b.blue"})}
    here my code;
    //class AnswerChoicesCellEditor
    import javax.swing.table.*;
    import javax.swing.*;
    import java.awt.Component;
    import java.awt.event.MouseEvent;
    import java.util.EventObject;
    import de.falcom.table.*;
    public class AnswerChoicesCellEditor extends AbstractCellEditor implements TableCellEditor{
         protected JComboBox mComboBox;
    public AnswerChoicesCellEditor(){
         mComboBox = new JComboBox();
         mComboBox.addActionListener(this);
         mComboBox.setEditable(false);
    public Component getTableCellEditorComponent(JTable table,Object value,boolean isSelected,int row,int column){
         if(value instanceof AnswerChoices){
              AnswerChoices a = (AnswerChoices)value;
              String[] c = a.getChoices();
              mComboBox.removeAllItems();
              for(int i=0; i < c.length; i++)
                   mComboBox.addItem(c);
                   mComboBox.setSelectedIndex(a.getAnswer());
         return mComboBox;
    public Object getCellEditorValue(){
         int nchoices = mComboBox.getItemCount();
         String[] c = new String[nchoices];
         for(int i = 0; i<nchoices; i++){
              c[i] = mComboBox.getItemAt(i).toString();
         return new AnswerChoices(c,mComboBox.getSelectedIndex());
         //return mComboBox.getSelectedItem(); //here i get but after selection there is no comboBox in tableCell
    //the Renderer class
    import javax.swing.table.TableCellRenderer;
    import javax.swing.*;
    import java.awt.Component;
    public class AnswerChoicesCellRenderer extends JComboBox implements TableCellRenderer {
         private Object curValue;
    /** Creates new AnswerChoiceCellRenderer */
    public AnswerChoicesCellRenderer() {
    setEditable(false);
    public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,int row,int column) {
    if (value instanceof AnswerChoices) {
    AnswerChoices nl = (AnswerChoices)value;
    String[] tList = nl.getChoices();
    if (tList != null) {
    removeAllItems();
    for (int i=0; i<tList.length; i++)
    addItem(tList[i]);
         setSelectedIndex(AnswerChoices.getAnswer());
         //this.setSelectedItem();
    //return this;
    //this.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
    if (table != null)
    if (table.isCellEditable(row, column))
    setForeground(CellRendererConstants.EDITABLE_COLOR);
    else
    setForeground(CellRendererConstants.UNEDITABLE_COLOR);
              setBackground(table.getBackground());
    return this;
    public class AnswerChoices {
         static int ans = 0;
         String[] choices ;
    public AnswerChoices(String[]c,int a){
              choices = c;
              ans          = a;
    public AnswerChoices(String[] c){
              this(c,0);
    public String[] getChoices(){
         return choices;
    public void setAnswer(int a){
         ans = a;
    public static int getAnswer(){
         return ans;
    //the TableModel i used in my app
    import java.awt.Color;
    import javax.swing.JTable;
    import javax.swing.ListSelectionModel;
    import javax.swing.table.DefaultTableModel;
    import javax.swing.table.TableCellEditor;
    import javax.swing.table.TableCellRenderer;
    import javax.swing.table.TableColumn;
    import javax.swing.table.TableModel;
    import javax.swing.*;
    public class FAL_Table extends JTable {
    /** Creates new FAL_Table */
    public FAL_Table(DefaultTableModel dtm) {
    super(dtm);
    setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    setRowSelectionAllowed(false);
    setColumnSelectionAllowed(false);
    setBackground(java.awt.Color.white);
    setDefaultCellEditorRenderer();
    private void setDefaultCellEditorRenderer(Class forClass, TableCellEditor editor, TableCellRenderer renderer) {
         setDefaultEditor(forClass, editor);
         setDefaultRenderer(forClass, renderer);
         private void setDefaultCellEditorRenderer() {
              // Setting default editor&renderer of Boolean
              setDefaultCellEditorRenderer(Boolean.class, new BooleanCellEditor(), new BooleanCellRenderer());
              //Setting default editor&renderer of ComboBox
              setDefaultCellEditorRenderer(JComboBox.class, new ComboBoxCellEditor( ),new ComboBoxRenderer());
              // Number class
              // Setting default editor&renderer of java.math.BigDecimal
              setDefaultCellEditorRenderer(java.math.BigDecimal.class,new NumberCellEditor(), new NumberCellRenderer());
              // Setting default editor&renderer of java.math.BigInteger
              setDefaultCellEditorRenderer(java.math.BigInteger.class,new NumberCellEditor(), new NumberCellRenderer());
              // Setting default editor&renderer of java.lang.Byte
              setDefaultCellEditorRenderer(Byte.class,new NumberCellEditor(), new NumberCellRenderer());
              // Setting default editor&renderer of Double
              setDefaultCellEditorRenderer(Double.class,new NumberCellEditor(), new NumberCellRenderer());
              // Setting default editor&renderer of Float
              setDefaultCellEditorRenderer(Float.class,new NumberCellEditor(), new NumberCellRenderer());
              // Setting default editor&renderer of Integer
              setDefaultCellEditorRenderer(Integer.class,new NumberCellEditor(), new NumberCellRenderer());
              // Setting default editor&renderer of Long
              setDefaultCellEditorRenderer(Long.class,new NumberCellEditor(), new NumberCellRenderer());
              // Setting default editor&renderer of Short
              setDefaultCellEditorRenderer(Short.class,new NumberCellEditor(), new NumberCellRenderer());
              // Setting default editor&renderer of String
              setDefaultCellEditorRenderer(String.class,new StringCellEditor(), new StringCellRenderer());
              // Setting default editor&renderer of FileName
              setDefaultCellEditorRenderer(FileName.class,new FileNameCellEditor(), new FileNameCellRenderer());
              // Setting default editor&renderer of Color
              setDefaultCellEditorRenderer(Color.class,new ColorCellEditor(), new ColorCellRenderer());
              setDefaultCellEditorRenderer(AnswerChoices.class, new AnswerChoicesCellEditor(), new AnswerChoicesCellRenderer());
              setDefaultCellEditorRenderer(JSpinner.class, new SpinnerCellEditor(), new SpinnerRenderer());
    public Class getCellClass(int row,int col) {
    TableModel model = getModel();
    if (model instanceof FAL_TableModel) {
    FAL_TableModel ptm = (FAL_TableModel)model;
    return ptm.getCellClass(row,convertColumnIndexToModel(col));
    return model.getColumnClass(convertColumnIndexToModel(col));
    public TableCellRenderer getCellRenderer(int row, int column) {
    TableColumn tableColumn = getColumnModel().getColumn(column);
    TableCellRenderer renderer = tableColumn.getCellRenderer();
    if (renderer == null) {
    renderer = getDefaultRenderer(getCellClass(row,column));
    return renderer;
    public TableCellEditor getCellEditor(int row, int column) {
    TableColumn tableColumn = getColumnModel().getColumn(column);
    TableCellEditor editor = tableColumn.getCellEditor();
    if (editor == null) {
    editor = getDefaultEditor(getCellClass(row,column));
    return editor;
    import javax.swing.table.*;
    import java.util.Vector;
    import java.awt.event.MouseEvent;
    import java.util.EventObject;
    public class FAL_TableModel extends DefaultTableModel implements TableModel {
    public FAL_TableModel() {
    this((Vector)null, 0);
    public FAL_TableModel(int numRows, int numColumns) {
    super(numRows,numColumns);
    public FAL_TableModel(Vector columnNames, int numRows) {
    super(columnNames,numRows);
    public FAL_TableModel(Object[] columnNames, int numRows) {
    super(convertToVector(columnNames), numRows);
    public FAL_TableModel(Vector data, Vector columnNames) {
    setDataVector(data, columnNames);
    public FAL_TableModel(Object[][] data, Object[] columnNames) {
    setDataVector(data, columnNames);
         public boolean isCellEditable(int row, int col) {
    //Note that the data/cell address is constant,
    //no matter where the cell appears onscreen.
    Object obj = getValueAt(row,col);
    if (col != 1){
    return false;
         }else{
              return true;
    public Class getCellClass(int row,int col) {
    Object obj = getValueAt(row,col);
    if (obj != null)
         return obj.getClass();
         else
         return Object.class;
    public Object getCellValue(int row,int col) {
    Object obj = getValueAt(row,col);
              return obj;      
    my problem is, when i select an item from one of the comboBox in the table the value of the other cells changes too and i have the same problem with JSpinner.
    please help i am stuck
    Gebi

    and when i try to get the current value oa a cell it returns the Component class like this
    AnswerChoices@bf1f20 ...

Maybe you are looking for

  • I can´t use the phone now!

    I got an error message Nr 1015 when I tried to update my Iphone to latest Itunes.What to do?I can´t use the phone now! Yours Christer Jansson

  • Oracle Login is very slow

    Hi all, I have two Windows 2000 Servers: 1. Compaq Server with one 2.4G CPU, 1G RAM and 30G harddisk 2. Acer Server with one 2.4G CPU, 1G RAM and 30G harddisk The software configuration of two server are identical, they both have: 1 Windows 2000 Serv

  • Help with hours between two dates

    Hi I need help with the below query select count(*),a.col1,max(a.dt),min(a.dt) from tab1 a where a.dt > to_date('01-JUL-08','dd-mon-yyyy') group by col1 having count(*) >=2 and (max(a.dt) - min(a.dt))* 24*60*60 > 360; I am trying to pull the records

  • How can I check the Statistics on my document?

    Such as number of word, sentences or passive sentences? I know you can do it on Word.

  • Mac-Address Different format for Authorization on Cisco ISE

    Dear All, I have problem with my Cisco ISE, This is the design : ISE ---- Core Switch ---- 3Com Switch --- PC User My Case: Authorization is based on Mac-address and Active Directory, But user with PC that connect to 3Com swtich is Deny by ISE becaus