Complete a JComboBox in netbeans

Hi!
I need to complete the info that a JCombobox shows when it is click?
How do i do that?
I tried:
jComboBox1.addItem("Host Master Key");
jComboBox1.addItem("Main Communication Key");
jComboBox1.setSelectedIndex(0);
But it doesn�t work, when i execute it, it doesn�'t show "Host Master Key"or "Main Communication Key"
can you help me?

can you help me? Based on 3 lines of code we have no idea whats wrong.
So here is a link to the Swing tutorial on "How to Use Combo Boxes":
http://java.sun.com/docs/books/tutorial/uiswing/components/combobox.html
It has working examples which you can compare to your own code.

Similar Messages

  • Netbeans 6.5 doesn't detect Sun Java Wireless 2.5.2 for CLDC

    I have netbeans 6.5 installed on my system and the Sun Java (TM) Wireless Toolkit 2.5.2 for CLDC is located in the usual folder i.e C:\Program Files\NetBeans 6.5\mobility8\WTK2.5.2
    It was working fine for some time but since yesterday it has stopped working suddenly although nothing has been modified in the installation folders
    The WTK 2.5.2 is not accessible in netbeans IDE anymore. I have tried to add it from "Java Platform Manager" but netbeans does not seem to work
    The procedure I do is
    One in Netbeans IDE
    1. Open Java Platform Manager
    2. Add Java Platform
    3. Select "Java ME MIDP Platform Emulator"
    4. Click "Next"
    nothing happens... just stays at this screen
    I tried to uninstalled and reinstalled netbeans 4 times nothing seems to work.
    Can any one help me out.

    Found the solution.... The Configuration folders for NetBeans were not getting deleted by unInstaller.
    This is what you have to do to get it working
    1. Completely un install the NetBeans IDE. (to be on the safe side you can uninstall jdk as well)
    2. Delete all left over registry entries, if any.
    3. Go to your user profile folder. that is C:\Documents and Settings\myusername\
    4. There will be 4/5 folders for NetBeans.. delete all of them. (1 of them is called nbi)
    5. back up the contents of your workspace folder,. and delete it.
    6. Reinstall NetBeans 6.5 IDE.
    7. Now It will detect J2ME..
    So the conculsion is the Netbeans uninstaller should delete (or at least provide option) these configuration folders...

  • Problem with netbeans UML module

    I have downloaded the UML module from the plug-in section. While it was installing it couldn't find several files related to UML module and when I try to activate the UML module it gives an error like:
    Activation failed. Not all requested modules can be enabled. [StandardModule:org.netbeans.modules.uml.kit jarFile: C:\Program Files\NetBeans 6.0.1\uml4\modules\org-netbeans-modules-uml-kit.jar]
    Required modules for plugin UML to complete activation:
    module org.netbeans.modules.uml/1 > 1.1
    module org.netbeans.modules.uml/1 > 1.2
    module org.netbeans.modules.uml/1 > 1.2.2
    How can I solve this problem?

    Hi ,
    Iam using the following code
    WA_MAILDATA-obj_descr = IS_BACKMON-Message_Subject.
    *Collect the mailid and reciver type to send an email
      WA_RECEIVER-receiver = 'Emailid'.
       WA_RECEIVER-rec_type  = 'U'.
       WA_RECEIVER-com_type = 'INT'.
       APPEND WA_RECEIVER to i_RECEIVER.
    *Display the context of the message
      is_contents_txt = IS_BACKMON-Message_Body.
      APPEND is_contents_txt to i_contents_txt.
      clear is_contents_txt.
    *Send an Email to a Particular person
      call function 'SO_NEW_DOCUMENT_SEND_API1'
           exporting
                document_data              =  WA_MAILDATA
               document_type              = 'HTM'
                put_in_outbox              = c_flag
                commit_work                = c_flag
           tables
               object_header              = I_MESSAGE
                OBJECT_CONTENT              = i_contents_txt
                receivers                  = i_RECEIVER
           exceptions
                too_many_receivers         = 1
                document_not_sent          = 2
                document_type_not_exist    = 3
                operation_no_authorization = 4
                parameter_error            = 5
                x_error                    = 6
                enqueue_error              = 7
                others                     = 8.
      if sy-subrc  eq 0.
    *Submit after the function module is successful
        SUBMIT rsconn01 WITH mode = c_int
                       WITH output = ' '
                       AND RETURN.

  • [SOLVED] netbeans 7.3 pop-up menu not working

    Hi all,
    few month ago i updated my netbeans from 7.2.1 to 7.3. Then i noticed that autocompletion is not working (in c++ project with/without jvi)  and netbeans shows me warning message:
    java.lang.NoClassDefFoundError: org/netbeans/modules/editor/completion/ScreenBoundsProvider
    at org.netbeans.modules.editor.completion.CompletionLayoutPopup.getPreferredSize(CompletionLayoutPopup.java:166)
    at org.netbeans.modules.editor.completion.CompletionLayout$CompletionPopup.show(CompletionLayout.java:383)
    at org.netbeans.modules.editor.completion.CompletionLayout.showCompletion(CompletionLayout.java:143)
    at org.netbeans.modules.editor.completion.CompletionImpl$7.run(CompletionImpl.java:1016)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:727)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:688)
    at java.awt.EventQueue$3.run(EventQueue.java:686)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:697)
    at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:159)
    [catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
    I have not found any suitable solution by myself. As i had no time to fix that issue i moved back to older version of netbeans(that is very bad solution, but i could not wait) and added to ignorepkg. Now i want to solve this problem. Can anyone help me?
    PS. I understand that solution may be obvious or i have not noticed relevant topict, but i am stuck.
    Last edited by ewaller (2013-05-13 15:23:07)

    Solution of this problem was at this page (Comment 14 solved everything).
    Problem was in jvi plugin.
    You should perform all described actions and then install plugin from: http://plugins.netbeans.org/plugin/3891 … ate-center to enable jvi support.
    Solved!

  • Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException

    Hello everyone ... sorry for my English but I am an Italian boy with a problem that is not answered.
    I had to create a web application-service (created in Java with NetBeans 6.7) which is connected to a database postgresql (8.3.5) and for connection to the server using tomcat (3.2.4) through SOAP messages (2_2).
    OPERATING SYSTEM: WINXP
    I have created classes ... I created the database ... completed the project in NetBeans without any errors ... implemented the necessary libraries in the project (also ).... 8.3.604.jar jdbc tomcat configured and soap ... .. and set the environment variables (soap, mail, send in xerces )...... run the application on the NetBeans appears the login screen of my web service .....
    enter username and password (exactly!) and the NetBeans gives me an Exception:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
            at Intro.loginActionPerformed(Intro.java:522)
            at Intro.access$100(Intro.java:21)
            at Intro$2.actionPerformed(Intro.java:111)
            at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
            at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
            at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
            at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
            at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
            at java.awt.Component.processMouseEvent(Component.java:6263)
            at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
            at java.awt.Component.processEvent(Component.java:6028)
            at java.awt.Container.processEvent(Container.java:2041)
            at java.awt.Component.dispatchEventImpl(Component.java:4630)
            at java.awt.Container.dispatchEventImpl(Container.java:2099)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4574)
            at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4238)
            at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4168)
            at java.awt.Container.dispatchEventImpl(Container.java:2085)
            at java.awt.Window.dispatchEventImpl(Window.java:2475)
            at java.awt.Component.dispatchEvent(Component.java:4460)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
    Java Result: 1
    BUILD SUCCESSFUL (total time: 31 seconds)  The line 522 Intro class is as follows:
    private void loginActionPerformed(java.awt.event.ActionEvent evt) {                                     
            try {
                URL address= new URL("http://"+ip+":8080/soap/servlet/rpcrouter");
                //Costruzione della chiamata
                Call chiamata = new Call();
                chiamata.setTargetObjectURI("urn:server");
                chiamata.setMethodName("controllaAgenzia");
                chiamata.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);
                //creazione parametri che dovro' passare al soap
                Vector<Parameter> params = new Vector<Parameter>();
                String u = user.getText();
                String p = String.valueOf(password.getPassword());
                params.addElement(new Parameter("user", String.class, u, null));
                params.addElement(new Parameter("password", String.class, p, null));
                chiamata.setParams(params);//parametri passati al soap
                try {
                    //Invocazione RPC
                    Response respons = chiamata.invoke(address, "");
                    //qui ho la risposta inviata dal server
                    *Parameter par = respons.getReturnValue();*
                    Object value = par.getValue();
                    String REP = String.valueOf(value);
                    System.out.println(REP);
                    if (REP.equals("ACK_agenzia")) {
                        new MainAgenzia(ip);
                        this.dispose();
                    } else if (REP.equals("NACK_agenzia")) {
                        JOptionPane.showMessageDialog(null, "I dati inseriti non sono corretti", "Errore", JOptionPane.ERROR_MESSAGE);
                        password.setText("");
                        user.setText("");
                    } The strange thing is that this web service was running just finished the project.
    After 4-5 days of its operation has stopped, creandomi this problem.
    I think the answer is, the server that is not the case.
    I thought all I thought was jdbc, but I can connect to the database, so I do not know what to do and how to proceed.
    thanks to all, and thanks to my translator. :P

    Parameter par = respons.getReturnValue();There is only one possible reason, "respons" is null.

  • Oracle Forms PJCs/Java Beans

    In 10g is it possible to use Oracle Forms PJCs/Java Beans in tabular form ?
    I wanna use an "auto completion" Swing JComboBox.

    Thanks François,
    could you suggest me what can be done if I need 10 rows with 12 fields of combobox's
    which has a display value of char datatype and return value of numeric to database
    - LT

  • Graphics Program

    I am thinking about writing a calculator in java. The thing is, I wanted to know if there was some software I could download so that I wouldn't have to type the code for the buttons of the calculator. All I'd do is assemble the calculator (graphically) and the program would generate the code (sort of like FrontPage) is there such a program.

    well, I use forte its very simple and intuitive to use, and have all the components to use from awt to swing. you can also manage the buttons events easily just by 2 clicks. netbeans also have a feature to ass components graphically but is not as complete as forte. Netbeans can be downloaded for free but forte no.

  • Is there any way to fix the slow code completion in Netbeans 5.5+

    Netbeans 5.5 or Netbeans 5.5.1
    Is there any possible fix for the slow code completion within the editor? I've googled this issue and haven't found much of anything relevant.
    While, not used all the time - a faster than what it is now code completion would be helpful.
    Thanks,
    --Todd                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    helloWorld
    Thanks for the response and useful response.
    :P
    I'm not a decent machine now and I guess I'll just keep on typing.
    --Todd                                                                                                                                                                                                                                                                                       

  • Netbeans 6.0 - code completion of method parameters

    I just updated to NetBeans 6.0 and I find the code completion of method parameters very annoying and counter productive.
    It inserts the parameters as keywords when choosing a method from the list after pressing CTRL+SPACE.
    How can I switch this off?
    I searched the options and also the forum but didn't find a solution.

    I know that pressing space or whatever replaces the selected parameter. For a method with a single parameter is not a big problem but this is a poor workaround if a method has more parameters, like eg
    public static String formatDate(Date myDate, String myFormat)
    When typing
    Str.form<CTRL+SPACE,choose method, ENTER>
    it looks like
    Str.formatDate(myDate, errorMessage)
    Although myDate is selected and I can overwrite it, I have to proceed to the next parameter with CTRL+M instead of simply typing a comma. This is very annoying if a method has more parameters and as this annoyance occurs approx. every 5 lines that accumulates.

  • NetBeans 6.0 code completion without old code

    Hi,
    I've simple question for code completion in NetBeans 6.0.
    for ex. if I've this simple code:
    int aaa = 0;
    int bbb = 1;
    int ccc = aaa;
    and now I want change ccc = bbb
    just I use code completion (Ctrl-SPACE)
    int ccc = Ctrl-SPACE-ENTERaaa;
    why reason's
    int ccc = bbbaaa;
    why isn't
    int ccc = bbb;
    Any simple idea how can I accomplish it?
    Thx. Paul

    Please post only Java language questions in these forums. They do not provide support for NetBeans (or other IDEs), you might try the NetBeans site mailing list.

  • Code completion problem in netbeans 5.0

    Hi-
    I just recently switched from using ConTEXT to using netbeans 5.0. However, I cannot seem to get code compeletion to work properly (the main reason I switched).
    It doesn't work at all if I open a .java file on its own even though it's enabled.
    However, if I copy and paste the code into a <new project> then code completion works.
    Is there a way to get code completion to work without generating an entire new project? I just want a simple editor that has code completion. Is this possible with netbeans?
    Thanks!

    Never mind it took a while to find but I figured it out...
    <Ctrl>space or <Ctrl>\ opens up the code completion window
    and as an added bonus Alt+P pops up that ultra cool yellow window that tells you the formal parameters of the function as you enter arguments.
    Me loves the netbeans. Still though I have to have it in a project for it to work so the question still stands...can you use this without creating a project as to use it in a glorified editor fashion?

  • Netbeans Code Completion

    I installed netbeans two days ago, and I'm really impressed! Since then, I have had to reinstall windows 2000 on my PC, and after reinstalling the J2SE 1.4.1 SDK and NetBeans 3.5, the javadoc part of the code completion doesn't work. I've tried everything I can think of, but it always says
    "JavaDoc not found. Either javadoc documentation for this item does not exist or you have not mounted a filesystem that contains the source for this class. The javadoc documentation that is displayed in this box is generated from source files, not from compiled javadoc documentation."
    Sounded simple enough, but I have tried mounting every set of source files I can find, to no avail. This is especially irritating as this worked automatically when I installed it the first time.
    Browsing through the help located the following information:
    "To see documentation for Java SDK classes, you must have the Java SDK sources mounted. If you are running version 1.4 of the J2SE platform, the IDE mounts the SDK sources automatically the first time you use code completion on a JDK class."
    Well, I am running a later version that 1.4, but this does not seem to have happened. I have tried following the instructions to manually mount the SDK, but this has also had no effect.
    Please can anyone offer any advise, as this is getting really frustrating.

    I have the docs in a docs folder in JAVA_HOME. I have just tried mounting this directory specifically but it didn't work. The part of the error message that says
    "The javadoc documentation that is displayed in this box is generated from source files, not from compiled javadoc documentation."
    indicates that this is not the right approach.
    The part that seems to be going wrong is the SDK mounting - this was supposed to be automatic, but although it worked the first time, does not appear to have happened.
    Does anyone know what might cause this to fail, or how the SDK should be set up for NetBeans to locate it?

  • How is Netbeans code auto popup completion window implemented?

    Hello,
    I'd like to implement an auto completion popup window like the one in netbeans/eclipse. I perhaps could figure it out, but was wondering if anyone knows in which class of the code I should look into (to copy), or if some one has useful insights about it.

    Hello,
    I'd like to implement an auto completion popup window like the one in netbeans/eclipse. I perhaps could figure it out, but was wondering if anyone knows in which class of the code I should look into (to copy), or if some one has useful insights about it.

  • JComboBox, JTable, cellRendering CHALLENGE

    Hi all,
    I would like to ask a question of the resident guru concerning a Netbeans/MYSQL application. I based it on a tutorial found here: [http://www.netbeans.org/kb/61/java/gui-db-custom.html].
    I have two seperate JDialogs that write data to a master table. One of the JDialogs is called "Customer Editor" and it contains various text fields bound to cells on the masterTable, no big deal.
    Also in the "Customer Editor" JDialog there is a JComboBox that has a list of four values to choose from which are "Good", "Standby", "Failed", and "Complete".
    I would like the data selected from the JComboBox to color itself when it writes to the JTable row/cell on the masterTable. For example if the user selects "Good" from the list, in the masterTable the font color of the String will be GREEN. Similarly, if the user selects "Failed" from the JComboBox I would like the String to return RED...following on "Standby" - BLUE, "Complete" - no color change.
    Question: How do I write code that allows me to change the color of text in a cell when it comes from a JComboBox list?
    If anyone out there picks up this thread, I will of course supply the code I have so far. I won't do it now as I am not sure even where the code should go. I think it would go in the source code for the masterTable view but I am not certain.
    Any Java masters out there?
    David

    Thanks for the reply. I have been writing different cell renderers to get it working. Where should the code reside?
    This is my operations view class. Should it be in here.
    /CODE/
    package operationsrecords;
    import org.jdesktop.application.Action;
    import org.jdesktop.application.ResourceMap;
    import org.jdesktop.application.SingleFrameApplication;
    import org.jdesktop.application.FrameView;
    import org.jdesktop.application.TaskMonitor;
    import org.jdesktop.application.Task;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    import java.util.Collection;
    import java.util.Iterator;
    import java.util.LinkedList;
    import java.util.List;
    import javax.persistence.RollbackException;
    import javax.swing.Timer;
    import javax.swing.Icon;
    import javax.swing.JDialog;
    import javax.swing.JFrame;
    import javax.swing.JOptionPane;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import org.jdesktop.beansbinding.AbstractBindingListener;
    import org.jdesktop.beansbinding.Binding;
    import org.jdesktop.beansbinding.PropertyStateEvent;
    * The application's main frame.
    public class OperationsRecordsView extends FrameView {
    public OperationsRecordsView(SingleFrameApplication app) {
    super(app);
    initComponents();
    // status bar initialization - message timeout, idle icon and busy animation, etc
    ResourceMap resourceMap = getResourceMap();
    int messageTimeout = resourceMap.getInteger("StatusBar.messageTimeout");
         messageTimer = new Timer(messageTimeout, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    statusMessageLabel.setText("");
         messageTimer.setRepeats(false);
    int busyAnimationRate = resourceMap.getInteger("StatusBar.busyAnimationRate");
    for (int i = 0; i < busyIcons.length; i++) {
    busyIcons[i] = resourceMap.getIcon("StatusBar.busyIcons[" + i + "]");
    busyIconTimer = new Timer(busyAnimationRate, new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    busyIconIndex = (busyIconIndex + 1) % busyIcons.length;
    statusAnimationLabel.setIcon(busyIcons[busyIconIndex]);
    idleIcon = resourceMap.getIcon("StatusBar.idleIcon");
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);
    // connecting action tasks to status bar via TaskMonitor
    TaskMonitor taskMonitor = new TaskMonitor(getApplication().getContext());
    taskMonitor.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
    public void propertyChange(java.beans.PropertyChangeEvent evt) {
    String propertyName = evt.getPropertyName();
    if ("started".equals(propertyName)) {
    if (!busyIconTimer.isRunning()) {
    statusAnimationLabel.setIcon(busyIcons[0]);
    busyIconIndex = 0;
    busyIconTimer.start();
    progressBar.setVisible(true);
    progressBar.setIndeterminate(true);
    } else if ("done".equals(propertyName)) {
    busyIconTimer.stop();
    statusAnimationLabel.setIcon(idleIcon);
    progressBar.setVisible(false);
    progressBar.setValue(0);
    } else if ("message".equals(propertyName)) {
    String text = (String)(evt.getNewValue());
    statusMessageLabel.setText((text == null) ? "" : text);
    messageTimer.restart();
    } else if ("progress".equals(propertyName)) {
    int value = (Integer)(evt.getNewValue());
    progressBar.setVisible(true);
    progressBar.setIndeterminate(false);
    progressBar.setValue(value);
    // tracking table selection
    masterTable.getSelectionModel().addListSelectionListener(
    new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    firePropertyChange("recordSelected", !isRecordSelected(), isRecordSelected());
    detailTable.getSelectionModel().addListSelectionListener(
    new ListSelectionListener() {
    public void valueChanged(ListSelectionEvent e) {
    firePropertyChange("detailRecordSelected", !isDetailRecordSelected(), isDetailRecordSelected());
    // tracking changes to save
    bindingGroup.addBindingListener(new AbstractBindingListener() {
    @Override
    public void targetChanged(Binding binding, PropertyStateEvent event) {
    // save action observes saveNeeded property
    setSaveNeeded(true);
    // have a transaction started
    entityManager.getTransaction().begin();
    public boolean isSaveNeeded() {
    return saveNeeded;
    private void setSaveNeeded(boolean saveNeeded) {
    if (saveNeeded != this.saveNeeded) {
    this.saveNeeded = saveNeeded;
    firePropertyChange("saveNeeded", !saveNeeded, saveNeeded);
    public boolean isRecordSelected() {
    return masterTable.getSelectedRow() != -1;
    public boolean isDetailRecordSelected() {
    return detailTable.getSelectedRow() != -1;
    @Action
    public void newRecord() {
    operationsrecords.Customers c = new operationsrecords.Customers();
    entityManager.persist(c);
    list.add(c);
    int row = masterTable.getRowCount() - 1;
    masterTable.setRowSelectionInterval(row, row);
    masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));
    setSaveNeeded(true);
    JFrame mainFrame = OperationsRecordsApp.getApplication().getMainFrame();
    CustomerEditor ce = new CustomerEditor(mainFrame, false);
    ce.setCurrentRecord(c);
    ce.setVisible(true);
    if (ce.isCustomerConfirmed()) {
    save().run();
    } else {
    refresh().run();
    @Action(enabledProperty = "recordSelected")
    public void deleteRecord() {
    Object[] options = {"OK", "Cancel"};
    int n = JOptionPane.showConfirmDialog(null, "Delete the records permanently?", "Warning",
    JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null);
    if (n == JOptionPane.YES_OPTION) {
    int[] selected = masterTable.getSelectedRows();
    List<operationsrecords.Customers> toRemove = new ArrayList<operationsrecords.Customers>(selected.length);
    for (int idx = 0; idx < selected.length; idx++) {
    operationsrecords.Customers c = list.get(masterTable.convertRowIndexToModel(selected[idx]));
    toRemove.add(c);
    entityManager.remove(c);
    list.removeAll(toRemove);
    save().run();
    } else {
    refresh().run();
    @Action(enabledProperty = "recordSelected")
    public void newDetailRecord() {
    int index = masterTable.getSelectedRow();
    operationsrecords.Customers c = list.get(masterTable.convertRowIndexToModel(index));
    Collection<operationsrecords.Orders> os = c.getOrdersCollection();
    if (os == null) {
    os = new LinkedList<operationsrecords.Orders>();
    c.setOrdersCollection(os);
    operationsrecords.Orders o = new operationsrecords.Orders();
    o.setShipDate(new java.util.Date());
    entityManager.persist(o);
    o.setCustomerId(c);
    os.add(o);
    masterTable.clearSelection();
    masterTable.setRowSelectionInterval(index, index);
    int row = os.size()-1;
    detailTable.setRowSelectionInterval(row, row);
    detailTable.scrollRectToVisible(detailTable.getCellRect(row, 0, true));
    setSaveNeeded(true);
    JFrame mainFrame = OperationsRecordsApp.getApplication().getMainFrame();
    OrderEditor oe = new OrderEditor(mainFrame, false);
    oe.setCurrentOrderRecord(o);
    oe.setVisible(true);
    if (oe.isOrderConfirmed()) {
    save().run();
    } else {
    refresh().run();
    @Action(enabledProperty = "detailRecordSelected")
    public void deleteDetailRecord() {
    Object[] options = {"OK", "Cancel"};
    int n = JOptionPane.showConfirmDialog(null, "Delete the records permanently?", "Warning",
    JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE, null);
    if (n == JOptionPane.YES_OPTION) {
    int index = masterTable.getSelectedRow();
    operationsrecords.Customers c = list.get(masterTable.convertRowIndexToModel(index));
    Collection<operationsrecords.Orders> os = c.getOrdersCollection();
    int[] selected = detailTable.getSelectedRows();
    List<operationsrecords.Orders> toRemove = new ArrayList<operationsrecords.Orders>(selected.length);
    for (int idx = 0; idx < selected.length; idx++) {
    selected[idx] = detailTable.convertRowIndexToModel(selected[idx]);
    int count = 0;
    Iterator<operationsrecords.Orders> iter = os.iterator();
    while (count++ < selected[idx]) {
    iter.next();
    operationsrecords.Orders o = iter.next();
    toRemove.add(o);
    entityManager.remove(o);
    os.removeAll(toRemove);
    masterTable.clearSelection();
    masterTable.setRowSelectionInterval(index, index);
    list.removeAll(toRemove);
    save().run();
    } else {
    refresh().run();
    @Action(enabledProperty = "saveNeeded")
    public Task save() {
    return new SaveTask(getApplication());
    private class SaveTask extends Task {
    SaveTask(org.jdesktop.application.Application app) {
    super(app);
    @Override protected Void doInBackground() {
    try {
    entityManager.getTransaction().commit();
    entityManager.getTransaction().begin();
    } catch (RollbackException rex) {
    rex.printStackTrace();
    entityManager.getTransaction().begin();
    List<operationsrecords.Customers> merged = new ArrayList<operationsrecords.Customers>(list.size());
    for (operationsrecords.Customers c : list) {
    merged.add(entityManager.merge(c));
    list.clear();
    list.addAll(merged);
    return null;
    @Override protected void finished() {
    setSaveNeeded(false);
    * An example action method showing how to create asynchronous tasks
    * (running on background) and how to show their progress. Note the
    * artificial 'Thread.sleep' calls making the task long enough to see the
    * progress visualization - remove the sleeps for real application.
    @Action
    public Task refresh() {
    return new RefreshTask(getApplication());
    private class RefreshTask extends Task {
    RefreshTask(org.jdesktop.application.Application app) {
    super(app);
    @SuppressWarnings("unchecked")
    @Override protected Void doInBackground() {
    setProgress(0, 0, 4);
    setMessage("Rolling back the current changes...");
    setProgress(1, 0, 4);
    entityManager.getTransaction().rollback();
    setProgress(2, 0, 4);
    setMessage("Starting a new transaction...");
    entityManager.getTransaction().begin();
    setProgress(3, 0, 4);
    setMessage("Fetching new data...");
    java.util.Collection data = query.getResultList();
    for (Object entity : data) {
    entityManager.refresh(entity);
    setProgress(4, 0, 4);
    list.clear();
    list.addAll(data);
    return null;
    @Override protected void finished() {
    setMessage("Done.");
    setSaveNeeded(false);
    @Action
    public void showAboutBox() {
    if (aboutBox == null) {
    JFrame mainFrame = OperationsRecordsApp.getApplication().getMainFrame();
    aboutBox = new OperationsRecordsAboutBox(mainFrame);
    aboutBox.setLocationRelativeTo(mainFrame);
    OperationsRecordsApp.getApplication().show(aboutBox);
    /** 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.
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">
    private void initComponents() {
    bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
    mainPanel = new javax.swing.JPanel();
    masterScrollPane = new javax.swing.JScrollPane();
    masterTable = new javax.swing.JTable();
    newButton = new javax.swing.JButton();
    deleteButton = new javax.swing.JButton();
    detailScrollPane = new javax.swing.JScrollPane();
    detailTable = new javax.swing.JTable();
    deleteDetailButton = new javax.swing.JButton();
    newDetailButton = new javax.swing.JButton();
    jButton1 = new javax.swing.JButton();
    jButton2 = new javax.swing.JButton();
    jLabel1 = new javax.swing.JLabel();
    jTextField1 = new javax.swing.JTextField();
    jLabel2 = new javax.swing.JLabel();
    menuBar = new javax.swing.JMenuBar();
    javax.swing.JMenu fileMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem newRecordMenuItem = new javax.swing.JMenuItem();
    javax.swing.JMenuItem deleteRecordMenuItem = new javax.swing.JMenuItem();
    jSeparator1 = new javax.swing.JSeparator();
    javax.swing.JMenuItem saveMenuItem = new javax.swing.JMenuItem();
    javax.swing.JMenuItem refreshMenuItem = new javax.swing.JMenuItem();
    jSeparator2 = new javax.swing.JSeparator();
    javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
    javax.swing.JMenu helpMenu = new javax.swing.JMenu();
    javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();
    statusPanel = new javax.swing.JPanel();
    javax.swing.JSeparator statusPanelSeparator = new javax.swing.JSeparator();
    statusMessageLabel = new javax.swing.JLabel();
    statusAnimationLabel = new javax.swing.JLabel();
    progressBar = new javax.swing.JProgressBar();
    entityManager = java.beans.Beans.isDesignTime() ? null : javax.persistence.Persistence.createEntityManagerFactory("OperationsRecordsPU").createEntityManager();
    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(operationsrecords.OperationsRecordsApp.class).getContext().getResourceMap(OperationsRecordsView.class);
    query = java.beans.Beans.isDesignTime() ? null : entityManager.createQuery(resourceMap.getString("query.query")); // NOI18N
    list = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : org.jdesktop.observablecollections.ObservableCollections.observableList(query.getResultList());
    rowSorterToStringConverter1 = new operationsrecords.RowSorterToStringConverter();
    mainPanel.setBackground(resourceMap.getColor("mainPanel.background")); // NOI18N
    mainPanel.setName("mainPanel"); // NOI18N
    masterScrollPane.setName("masterScrollPane"); // NOI18N
    masterTable.setBackground(resourceMap.getColor("masterTable.background")); // NOI18N
    masterTable.setGridColor(resourceMap.getColor("masterTable.gridColor")); // NOI18N
    masterTable.setName("masterTable"); // NOI18N
    masterTable.setShowVerticalLines(false);
    org.jdesktop.swingbinding.JTableBinding jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, list, masterTable);
    org.jdesktop.swingbinding.JTableBinding.ColumnBinding columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${jobId}"));
    columnBinding.setColumnName("Job Id");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${statusId.status}"));
    columnBinding.setColumnName("Status Id.status");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${company}"));
    columnBinding.setColumnName("Company");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${rig}"));
    columnBinding.setColumnName("Rig");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${well}"));
    columnBinding.setColumnName("Well");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${county}"));
    columnBinding.setColumnName("County");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${state}"));
    columnBinding.setColumnName("State");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${companyMan}"));
    columnBinding.setColumnName("Company Man");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${phone}"));
    columnBinding.setColumnName("Phone");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${fax}"));
    columnBinding.setColumnName("Fax");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${emailAddress}"));
    columnBinding.setColumnName("Email Address");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    bindingGroup.addBinding(jTableBinding);
    jTableBinding.bind();
    masterScrollPane.setViewportView(masterTable);
    masterTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("masterTable.columnModel.title0")); // NOI18N
    masterTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("masterTable.columnModel.title1")); // NOI18N
    masterTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("masterTable.columnModel.title2")); // NOI18N
    masterTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("masterTable.columnModel.title3")); // NOI18N
    masterTable.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("masterTable.columnModel.title4")); // NOI18N
    masterTable.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("masterTable.columnModel.title5")); // NOI18N
    masterTable.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("masterTable.columnModel.title6")); // NOI18N
    masterTable.getColumnModel().getColumn(7).setHeaderValue(resourceMap.getString("masterTable.columnModel.title7")); // NOI18N
    masterTable.getColumnModel().getColumn(8).setHeaderValue(resourceMap.getString("masterTable.columnModel.title8")); // NOI18N
    masterTable.getColumnModel().getColumn(9).setHeaderValue(resourceMap.getString("masterTable.columnModel.title9")); // NOI18N
    masterTable.getColumnModel().getColumn(10).setHeaderValue(resourceMap.getString("masterTable.columnModel.title10")); // NOI18N
    javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(operationsrecords.OperationsRecordsApp.class).getContext().getActionMap(OperationsRecordsView.class, this);
    newButton.setAction(actionMap.get("newRecord")); // NOI18N
    newButton.setBackground(resourceMap.getColor("newButton.background")); // NOI18N
    newButton.setName("newButton"); // NOI18N
    deleteButton.setAction(actionMap.get("deleteRecord")); // NOI18N
    deleteButton.setBackground(resourceMap.getColor("jButton1.background")); // NOI18N
    deleteButton.setName("deleteButton"); // NOI18N
    detailScrollPane.setName("detailScrollPane"); // NOI18N
    detailTable.setGridColor(resourceMap.getColor("detailTable.gridColor")); // NOI18N
    detailTable.setName("detailTable"); // NOI18N
    detailTable.setShowVerticalLines(false);
    detailTable.getTableHeader().setReorderingAllowed(false);
    org.jdesktop.beansbinding.ELProperty eLProperty = org.jdesktop.beansbinding.ELProperty.create("${selectedElement.ordersCollection}");
    jTableBinding = org.jdesktop.swingbinding.SwingBindings.createJTableBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, eLProperty, detailTable);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${shipDate}"));
    columnBinding.setColumnName("Ship Date");
    columnBinding.setColumnClass(java.util.Date.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${tool}"));
    columnBinding.setColumnName("Tool");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${collar}"));
    columnBinding.setColumnName("Collar");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${xo}"));
    columnBinding.setColumnName("Xo");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${xo2}"));
    columnBinding.setColumnName("Xo2");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${surfaceKit}"));
    columnBinding.setColumnName("Surface Kit");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${comments}"));
    columnBinding.setColumnName("Comments");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    columnBinding = jTableBinding.addColumnBinding(org.jdesktop.beansbinding.ELProperty.create("${directions}"));
    columnBinding.setColumnName("Directions");
    columnBinding.setColumnClass(String.class);
    columnBinding.setEditable(false);
    jTableBinding.setSourceUnreadableValue(java.util.Collections.emptyList());
    bindingGroup.addBinding(jTableBinding);
    jTableBinding.bind();
    detailScrollPane.setViewportView(detailTable);
    detailTable.getColumnModel().getColumn(0).setResizable(false);
    detailTable.getColumnModel().getColumn(0).setPreferredWidth(10);
    detailTable.getColumnModel().getColumn(0).setHeaderValue(resourceMap.getString("detailTable.columnModel.title0")); // NOI18N
    detailTable.getColumnModel().getColumn(1).setResizable(false);
    detailTable.getColumnModel().getColumn(1).setPreferredWidth(5);
    detailTable.getColumnModel().getColumn(1).setHeaderValue(resourceMap.getString("detailTable.columnModel.title1")); // NOI18N
    detailTable.getColumnModel().getColumn(2).setResizable(false);
    detailTable.getColumnModel().getColumn(2).setPreferredWidth(5);
    detailTable.getColumnModel().getColumn(2).setHeaderValue(resourceMap.getString("detailTable.columnModel.title2")); // NOI18N
    detailTable.getColumnModel().getColumn(3).setResizable(false);
    detailTable.getColumnModel().getColumn(3).setPreferredWidth(5);
    detailTable.getColumnModel().getColumn(3).setHeaderValue(resourceMap.getString("detailTable.columnModel.title3")); // NOI18N
    detailTable.getColumnModel().getColumn(4).setResizable(false);
    detailTable.getColumnModel().getColumn(4).setPreferredWidth(5);
    detailTable.getColumnModel().getColumn(4).setHeaderValue(resourceMap.getString("detailTable.columnModel.title4")); // NOI18N
    detailTable.getColumnModel().getColumn(5).setResizable(false);
    detailTable.getColumnModel().getColumn(5).setPreferredWidth(5);
    detailTable.getColumnModel().getColumn(5).setHeaderValue(resourceMap.getString("detailTable.columnModel.title5")); // NOI18N
    detailTable.getColumnModel().getColumn(6).setResizable(false);
    detailTable.getColumnModel().getColumn(6).setPreferredWidth(300);
    detailTable.getColumnModel().getColumn(6).setHeaderValue(resourceMap.getString("detailTable.columnModel.title6")); // NOI18N
    detailTable.getColumnModel().getColumn(7).setResizable(false);
    detailTable.getColumnModel().getColumn(7).setPreferredWidth(300);
    detailTable.getColumnModel().getColumn(7).setHeaderValue(resourceMap.getString("detailTable.columnModel.title7")); // NOI18N
    deleteDetailButton.setAction(actionMap.get("deleteDetailRecord")); // NOI18N
    deleteDetailButton.setBackground(resourceMap.getColor("jButton1.background")); // NOI18N
    deleteDetailButton.setName("deleteDetailButton"); // NOI18N
    newDetailButton.setAction(actionMap.get("newDetailRecord")); // NOI18N
    newDetailButton.setBackground(resourceMap.getColor("jButton1.background")); // NOI18N
    newDetailButton.setName("newDetailButton"); // NOI18N
    jButton1.setAction(actionMap.get("editCustomer")); // NOI18N
    jButton1.setBackground(resourceMap.getColor("jButton1.background")); // NOI18N
    jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
    jButton1.setName("jButton1"); // NOI18N
    jButton2.setAction(actionMap.get("editOrder")); // NOI18N
    jButton2.setBackground(resourceMap.getColor("jButton1.background")); // NOI18N
    jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
    jButton2.setName("jButton2"); // NOI18N
    jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
    jLabel1.setName("jLabel1"); // NOI18N
    jTextField1.setName("jTextField1"); // NOI18N
    org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, masterTable, org.jdesktop.beansbinding.ELProperty.create("${rowSorter}"), jTextField1, org.jdesktop.beansbinding.BeanProperty.create("text"));
    binding.setConverter(rowSorterToStringConverter1);
    bindingGroup.addBinding(binding);
    jLabel2.setIcon(resourceMap.getIcon("jLabel2.icon")); // NOI18N
    jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
    jLabel2.setName("jLabel2"); // NOI18N
    javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
    mainPanel.setLayout(mainPanelLayout);
    mainPanelLayout.setHorizontalGroup(
    mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addGroup(mainPanelLayout.createSequentialGroup()
    .addContainerGap()
    .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
    .addComponent(detailScrollPane, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 1057, Short.MAX_VALUE)
    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainPanelLayout.createSequentialGroup()
    .addComponent(newDetailButton)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(jButton2)
    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
    .addComponent(deleteDetailButton))
    .addComponent(masterScrollPane, javax.swing.GroupLayout.DEFAULT

  • JTable with editable JComboBoxes

    For some reason once I added editable JComboBoxes to a JTable I can no longer tab among the fields in the table. If I just select a cell, I can tab to the other cells in that row, and then to proceeding rows as I reach the end of each. However if I double click the cell and enter data or select from the combobox. I no longer can tab to the next cell. At that point once I do hit tab, I am taken to the next table. Not the next cell in the row, or the next row in the current table.
    I have tried messing with a bunch of listeners, but I am not using the right listener on the right object? What listerner and object should the listener belong to? Table, model, cell editor, combobox, jpanel, jframe ? I hope this is not to vague.

    Well I am starting to think it's an implementation issue. Like I am not doing it how I should. I am basically doing
    JComboBox jcb = new JComboBox();
    jcb.setEditable(true);
    column.setCellEditor(new DefaultCellEditor(jcb));
    When I think I should be inheriting, and creating my own editor and/or renderer? Now my combobox vars are globally available in the class, so I can set and clear their contents. It does not matter that each row in the table has the same content in the combo boxes, that's basically what I want. User to be able to select an existing entry or make a new one.
    What I am trying to do is on tables have a drop down box that shows up when a user types a matching entry. If no entry matches, no popup box. If entry matches, box pops up and shows possible entries starting with what they are typing. Like code completion in IDE's like Netbeans. However I am doing this in a table. I thought a JComboBox would be a good widget to start with?

Maybe you are looking for