JComboBox Action Event problems

I have a complex UI with which I am having action event issues. Basically, the panel displays info about an object, which can be selected from within the panel through a button/popup window mechanism. A JComboBox (#1) selection determines the contents of another JComboBox (#2) on the same panel. Currently an ActionEvent fires when the user makes a selection using #1 that updates #2. This fuctions correctly with repeated testing so long as a new object is not selected.
When a new object is selected from within this panel this ActionEvent no longer fires. JComboBox #1 will be updated correctly and #2 will reflect the initial selection in #1, but user selections in #1 will not fire the ActionEvent and thus #2 is never updated.
Any help is appreciated. I feel like I'm missing something basic here, but I've stared at it for long enough...

By the way, the workaround is to use the ItemListener as the ItemStateChanged Event is fired reliably.

Similar Messages

  • Action Event Problem On Mobile Device (BlackBerry 8800)/NW2004s

    Hi all,
    I have created a simple Test Application with to views.
    The first view contains a button, which triggers an event - firing an Outbound plug to the second view.
    In the web browser (Internet Explorer) the "application" works fine, on Blackberry
    nothing happens -> the first view remains on screen.
    Can anybody help?!
    Thanks and regards,
    Thomas

    Hai,
    this example application may help you
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/398c6a9f-0701-0010-ada4-c5a51b1b2bde
    regards,
    Naga

  • Problem with action events........ :(

    hi all,
    there is a strange problem which me and my colleagues are facing now-a-days......
    For some odd and unknown reason, the links on the page suddenly stops woking... it goes like this....
    we write events (buttons or action links) .... we test them and they are working fine...... than we write some other piece of code and than run the program and links work no more... The program never goes in the action event for the component...... and surprisingly it also dont show an error.... It just keeps on refreshing itself again and again....... (this thing is also verified by using debugger that actions events just stop being called....) it happens for random situations ...... Once i thought that maybe its has to do something with beforeRenderResponse() method... but it happens even in beans without beforeRenderResponse() method.....
    Can anyone tell me whats going on around here???? we are extremely confused here with dead lines approaching fast........
    regards

    I've had this same problem....links were working fine yesterday. I added more functionality which didn't even affect the links, and now they're not working. Unfortunately, I don't have a solution either.
    Has anybody been able to access the logging in the facescontext or application to see what the lifecycle is doing before it stops???

  • h:CommandLink : Action event not called on the first click

    Hi,
    I am facing a problem here.
    I have a JSF page:
    When I first load the page, I have few text boxes and dropdowns. With out doing anything If I click the <h:commandLink I call an action in my pagecode.
    But the problem is on the very first load of the page, without doing anything if I click on the command link action event in my pagecode is not called, but If I click on the link the second timethe pagecode actionevent is called.
    So I think tried submitting the form in the JSF page onclik of the commandlink it works in my Local IBM RAD. But doesnot work in the WebSphere Portal.
    So can you tell me if I can submit the form atleast once when the page loads for the first time
    This is my command link:
    <tr>
    <td colspan="2" align="center">
    <h:commandLink styleClass="commandLink" id="lnkBtnCreateUser" action="#{pc_Createuser.doLnkBtnCreateUserAction}">
    <hx:graphicImageEx styleClass="graphicImageEx" id="imgBtnCreateUser" value="/theme/images/btnCreateUser.gif" style="border:0;cursor:pointer" onclick="return onFormSubmit();"></hx:graphicImageEx>
    </h:commandLink>
    </td>
    </tr>
    function onFormSubmit(){
    //enabling all the disable components
    So can anybody please help me on this. Why exactly the pageCode action event is not called for the very first click ???

    seems that a prependID="false" attribute in the respective form was causing the trouble. At least it's working now that I've deleted it.
    I introduced it, because last time the component ID's messed up the output of the error/success messages ("j_id:xxx isn't that of a usefull information to the enduser).
    Edited by: stger on Apr 9, 2008 5:41 PM

  • JDK1.6 JComboBox: No event sent on same selection

    Hi,
    In JDK1.5, with a combobox, when selecting from the dropdown list the item already selected, it sends an ActionEvent, but no ItemEvent.
    In JDK1.6.0_01, no event ActionEvent is sent!
    When the combobox is taken as a table cell editor, selecting the same item does not make automatically the cell quit the edition mode!, as the change is based on the ActionEvent listening!
    We have to click somewhere else to make the edition stop!
    Can someone explain this event strategy change between 1.5 and 1.6?
    And how to make the combobox disappear from the table cell?
    Just below a simple piece of code to check the combobox event sending.
    Herve.
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    public class ComboActionEvent extends JFrame {
         private void run() {
              JComboBox cb = new JComboBox(new String[]{"a", "b", "c", "d"});
              cb.addActionListener(new ActionListener() {
                   public void actionPerformed(ActionEvent e) {
                        System.out.println ("Action event!");
              getContentPane().add (cb);
              pack();
              setVisible(true);
         public static void main (String[] arg) {
              new ComboActionEvent().run();
    }

    Hmmm
    http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6481977
    and there are various threads in the forums about this, for example:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=5116064

  • ********  Need to add any button activated ACTION EVENT***********

    Can anyone help me add any type of ACTION EVENT /ACTION LISTENER TO THIS CODE
    PLEASE REVIEW AND COMPILE IF NECESSARY. Ensure that it compiles without errors. Currently it compiles without errors. It opens up as a GUI window that accepts a password. If anyone could just add a button to it that will do just about anything, time check, date check whatever it would be great!!!!! THIS WAS COMPILED WITH THE JGRASP COMPILER JAVA ACCEPTED
    Thank you all,
    ********************** Bruce's Code*****************************
    import java.awt.*;
    public class TimeEntryForm extends Panel
    private Panel tallPanel = new Panel();
    private Panel tallPanel2= new Panel();
    public TimeEntryForm()
    tallPanel.setLayout(new GridLayout(3, 1));
    tallPanel.add(new Label("Hrs Total"));
    tallPanel.add(new Label("Any"));
    tallPanel.add(new Label("One"));
    tallPanel2.setLayout(new GridLayout(3,1));
    tallPanel2.add(new Label("Personal Leave "));
    tallPanel2.add(new Label("Hrs Total "));
    tallPanel2.add(new Label("Pay Calc "));
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0; c.gridy = 2;
    add(new Label("Social Security # "), c);
    c.gridx = 1; c.gridy = 0;
    add(new Label("TIME ENTRY FORM"), c);
    c.gridx = 1;c.gridy = 1;
    add(new Label("Enter Date Here "), c);
    c.gridx = 3;c.gridy = 2;
    add(new Label("Employee Name "), c);
    c.gridx = 3;c.gridy = 4;
    add(new Label("Sick Time "), c);
    c.gridx = 0; c.gridy = 3;
    add(new Label("IN OUT "), c);
    c.gridx = 0; c.gridy = 4;
    add(new Label("IN OUT "), c);
    c.gridx = 0; c.gridy = 5;
    add(new Label("IN OUT "), c);
    c.gridx = 0; c.gridy = 6;
    add(new Label("IN OUT "), c);
    c.gridx = 0; c.gridy = 7;
    add(new Label("IN OUT "), c);
    c.gridx = 0; c.gridy = 8;
    add(new Label("IN OUT "), c);
    c.gridx = 0; c.gridy = 9;
    add(tallPanel2, c);
    c.gridx = 1;c.gridy = 11; //note, sets y
    add(new Label("Hrs Worked Today "), c);
    c.gridx = 1;c.gridy = 12;
    add(new Label("Pay Earned Today "), c);
    c.gridx = 2;
    add(tallPanel2, c);
    public static void main(String args[])
    Frame f = new Frame("Time Entry Form");
    f.add(new TimeEntryForm());
    f.pack();
    f.setVisible(true);
    }

    Hi java-luv,
    I am not sure if I understand the problem. But I was able to add a JButton to your code (using the JBuilder designer). The button just exists the application. Please check the listing below. Hope this helps.
    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class TimeEntryForm extends Panel
    private Panel tallPanel = new Panel();
    private Panel tallPanel2 = new Panel();
    private JButton jButton1 = new JButton();
    public TimeEntryForm() {
    tallPanel.setLayout(new GridLayout(3, 1));
    tallPanel.add(new Label("Hrs Total"));
    tallPanel.add(new Label("Any"));
    tallPanel.add(new Label("One"));
    tallPanel2.setLayout(new GridLayout(3, 1));
    tallPanel2.add(new Label("Personal Leave "));
    tallPanel2.add(new Label("Hrs Total "));
    tallPanel2.add(new Label("Pay Calc "));
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 2;
    add(new Label("Social Security # "), c);
    c.gridx = 1;
    c.gridy = 0;
    add(new Label("TIME ENTRY FORM"), c);
    c.gridx = 1;
    c.gridy = 1;
    add(new Label("Enter Date Here "), c);
    c.gridx = 3;
    c.gridy = 2;
    add(new Label("Employee Name "), c);
    c.gridx = 3;
    c.gridy = 4;
    add(new Label("Sick Time "), c);
    c.gridx = 0;
    c.gridy = 3;
    add(new Label("IN OUT "), c);
    c.gridx = 0;
    c.gridy = 4;
    add(new Label("IN OUT "), c);
    c.gridx = 0;
    c.gridy = 5;
    add(new Label("IN OUT "), c);
    c.gridx = 0;
    c.gridy = 6;
    add(new Label("IN OUT "), c);
    c.gridx = 0;
    c.gridy = 7;
    add(new Label("IN OUT "), c);
    c.gridx = 0;
    c.gridy = 8;
    add(new Label("IN OUT "), c);
    c.gridx = 0;
    c.gridy = 9;
    add(tallPanel2, c);
    c.gridx = 1;
    c.gridy = 11; //note, sets y
    add(new Label("Hrs Worked Today "), c);
    c.gridx = 1;
    c.gridy = 12;
    add(new Label("Pay Earned Today "), c);
    c.gridx = 2;
    add(tallPanel2, c);
    jbInit();
    public static void main(String args[]) {
    Frame f = new Frame("Time Entry Form");
    f.add(new TimeEntryForm());
    f.pack();
    f.setVisible(true);
    private void jbInit() {
    jButton1.setText("Exit");
    jButton1.addActionListener(new TimeEntryForm_jButton1_actionAdapter(this));
    this.add(jButton1, null);
    void jButton1_actionPerformed(ActionEvent e) {
    System.exit(0);
    class TimeEntryForm_jButton1_actionAdapter implements java.awt.event.ActionListener {
    TimeEntryForm adaptee;
    TimeEntryForm_jButton1_actionAdapter(TimeEntryForm adaptee) {
    this.adaptee = adaptee;
    public void actionPerformed(ActionEvent e) {
    adaptee.jButton1_actionPerformed(e);

  • Action event automatically triggered for combo box

    Hi all,
    I am facing a typical event handling problem for combo box in Swing(Using Net Beans 5.0, jdk 1.4.2)
    While adding items to combo box it is firing action event twice instead of once irrespective of no. of items added to it.
    For eg if there are 1 or more than 1 item added to combo box it is triggerring action event twice(one just after when first item is added and one again when rest all items are added)
    and if there is no item then also it is triggering once.
    Can you please help me out.
    Thanks

    post the SSCCE code, then only it is easy to find the problem

  • Button action event not call in dataprovider

    hi,
    i have JSF table and it's bound to Mysql database table. when i bound the table and run it's working properly but it's button action event is not call action. when i use static jsf table then it's table action event work properly.
    my jsp code is
    <ui:table binding="#{search.search_table}" id="search_table" lite="true" selectMultipleButton="true" sortPanelToggleButton="true"
                                style="height: 70px; left: 240px; top: 240px; position: absolute; width: 600px" title="Search Text :" visible="true" width="600">
                                <ui:tableRowGroup binding="#{search.tableRowGroup1}" id="tableRowGroup1" rows="5" sourceData="#{search.srch_tablevalDataProvider1}" sourceVar="currentRow">
                                    <!--    <ui:tableColumn headerText="Script" id="tableColumn2" width="700">
                                        <ui:staticText id="staticText4" text="#{currentRow.value['search_script']}"/>
                                    </ui:tableColumn>-->
                                    <ui:tableColumn binding="#{search.tableColumn13}" headerText="Search Word" id="tableColumn13" style="#{search.columnStyle}">
                                        <ui:staticText binding="#{search.search_word1}" id="search_word1" text="#{search.search_word1}"/>
                                    </ui:tableColumn>
                                    <ui:tableColumn binding="#{search.tableColumn4}" headerText="#{search_lang['search.contentName']}" height="39" id="tableColumn4"
                                        style="#{search.columnStyle}" width="100">
                                        <ui:staticText id="staticText1" onMouseOver="play_video(this);" text="#{currentRow.value['name']}"/>
                                    </ui:tableColumn>
                                    <ui:tableColumn binding="#{search.tableColumn6}" headerText="#{search_lang['search.srchTag']}" id="tableColumn6"
                                        sort="search_tags" style="#{search.columnStyle}">
                                        <ui:staticText id="staticText3" text="#{currentRow.value['search_tags']}"/>
                                    </ui:tableColumn>
                                    <ui:tableColumn binding="#{search.tableColumn5}" headerText="#{search_lang['search.tpDetail']}" id="tableColumn5" style="#{search.columnStyle}">
                                        <ui:imageHyperlink action="#{search.action}" id="imageHyperlink1" text="#{currentRow.value['details']}"/>
                                        <ui:button action="#{search.button2_action}" id="button2" text="Button"/>
                                    </ui:tableColumn>
                                </ui:tableRowGroup>
                             </ui:table>and back bean code is
    public String button2_action() {
            // TODO: Process the button click action. Return value is a navigation
            // case name where null will return to the same page.
            System.out.println("Invoke");
            return null;
        }i don't know what is problem there if found any solution, help me.

    You need to make sure that the getter of the datatable value returns exactly the same list in the apply request values phase of the form submit as it did during the render response phase of the initial display. Only this way JSF can find out which action which row was been invoked. Alternatively you can also place the data bean in session scope (which may have more impact), or use for example Tomahawk's t:dataTable with preserveDataModel attribute set to "true".

  • JComboBox action listener

    I have registered an action listener on a JComboBox.. I change the selected value of this combobox from another component's actions also.. My question is how can i distinguish between an action event in which an item was selected using the combo box directly and an event in which the selected value in the combo box was set by different comopnent.. the actionEvent.getSource gives the combo box itself..
    Is using a mouselistener the only way out??

    You can't and its a bad design to attempt to do so.dont know about bad design but.. in my case its required. I have to make a file chooser type User interface for browsing an ftp site.. So the combo box needs to be updated when the user changes a directory by double clicking on the directory.. Could i do something else?? please suggest anything u can
    >
    Is using a mouselistener the only way out?? What about if the user uses the key board to select
    the item from the combo box? Would you also need to
    write your own KeyListener? Getting very ugly.good point.. didnt think about this....now i understand why they used action listener
    >
    As a workaround, you could add code to your "other"
    compnent:
    comboBox.removeActionListener(...);
    comboBox.setSelectedItem(...);
    comboBox.addActionListener(...);thanks, does this have a significant performance penalty.. I mean it does not look good does it??

  • Action Event

    Hi,
    Slight problem with an action event, have a workaround but want to make sure there isnt another way!
    Basically I have 2 combo boxes, Make and Model. When an item is selected in one of them the following happens:
    Gets the value selected, runs a query on a data base, clears the other combobox, and inserts the data returned in the other combo box.
    The problem is that clearing the other combobox registers as an actionPerformed on that box, and so does adding the data to that box.
    Can I consume that event?? i.e. make the latter 2 actions not register as events???
    I have worked around it using a boolean, but am looking for another way.
    I dont have the code off hand to show it!!
    Thanks
    Ciara

    I have worked around it using a boolean, but am looking for another way.If the MakeActionListener fiddle-diddles with the Model, it's the first ones responsibility
    that the second one doesn't get spurious events fired towards its general direction. A boolean, as
    you describe, solves the problem but then its the ModelActionListener that's got to check it.
    Would it be possible that the MakeActionListener temporarily removes the other listener from
    the notification list and re-install it after it has performed its dirty deeds?
    kind regards,
    Jos

  • Action event of combobox

    Hi all..
    I have three combo boxes.
    the second combobox values are loaded when a element from first combobox is chosen.
    the third combobox values are loaded when a element from second combobox is chosen.
    it works fine the first time.
    but when i rechoose an element from the first combobox, the action event for the second combobox is fired without me clicking the second combobox and hence throws an null pointer exception.
    i have the functions written according to the action events.
    should i use any things with respect to the mouse click or something??

    Hi again..
    i used itemListener as u suggested but still face problem..
    the third combo box is not getting loaded.. ie the loadcurrent() is not getting called.
    below is the code..
    public void itemStateChanged(ItemEvent ie)
              Object source=ie.getItemSelectable();
              if(source==tname)
                   System.out.println("combo tname");
                   loadstd();
              else if(source==stdfile)
                   System.out.println("combo stdfile");
                   loadcurrent();
              else if(source==curfile)
                   System.out.println("combo curfile");
         }

  • Info needed on multiload action event

    Hi Everyone,
    i have problem with multiload action event.
    i want to execute some event like startmapprocess (import process) for multiload, i would like to know the similar event that is used for multiload file(multiload action)
    i think startmapprocess event is for importing single period load.
    i am trying to use all event for 12 period text load gven in API but this is not recognized by fdm. does the file should definitely have 12 periods in it to use Multiload Import Process (Text 12 Period) Process.
    i have tried using BefImportText,AftImportText,BefValidate these events but none of them are working or have no impact on the multiload import process. please clarify
    Thanks
    Tm

    Try something like this:
    Sub MultiLoadAction(strEventName, objLSItem)
         ' DO NOT LIMIT EXECUTION TO ANY MULTILOADACTION EVENT
         ' PURPOSE IS TO DETERMINE ALL STREVENTNAME EXECUTED DURING MULTILOAD
         ' THIS CODE MUST BE INSERTED BEFORE EXISTING If LCase(strEventName) = ...
         strPath = "\\NEDHYPFDMDEV1\FDMApps\2TITAN_DEV\Inbox\"
         strFileName = "MultiLoadActionEvents.txt"
         strFilePath = strPath & strFileName
         ' Create file system object used for file operations
         Set fso = CreateObject("Scripting.FileSystemObject")
         Set fsoFile = fso.OpenTextFile(strFilePath, 8, True, 0)' Open the file for appending in ASCII format
         fsoFile.WriteLine strEventName
         fsoFile.Close
         Set fsoFile = Nothing
         Set fso = Nothing
         ' Include existing MultiLoadAction code here:
         If LCase(strEventName) = "aftcopyfiles"
         End If
    End Sub

  • How to pass params to Action Event handler in treeNode?

    Trying to use Tree in portlet I found impossible to determine selected node. (bug # 6354989).
    But I can (despite what is written in manual) use Action Event Handler. It works now (at least, I hope so).
    But I generate tree dynamically and cannot write event handlers for all its nodes. May be there's a way to write one event handler but distinguish node that triggered it? May be by passing additional params to handler?

    The tree component does not work well in portlets. This is a known problem.
    It uses cookies to pass the value of the selected node, but cookies do not work inside of portlets. So, the methods that would normally tell you which node is selected, return nothing. There are also no javascript properties which would allow you to output javascript to store the value somewhere in the page.
    Unfortunately there is no workaround for the bug you mentioned so far so far.
    Rose

  • Event problem on two different panels

    I have an application which has a main JFrame.
    It has two panels north and south
    The one in the south has buttons that listens for events.
    The events are action events. The events on this panel works if I don't include the events for my other panel i.e
    PersonalDataPanel as described below.
    The noth panel uses card layout. Inside this layout has two panels.
    One panel is called PersonalDataPanel.
    Inside PersonalDataPanel are components.
    One is a group of radio buttons that listens for events
    the events are again action events and if one is choosen from the group it is written to a file.
    I have testdriver for this which works.
    My porblem occurs when I include the code for PersonalDataPanel to listen for events and the main JFrame also to listen for events.
    How should I handle this dilemma??

    Why does the JFrame also have to listen for events? If its only button events surely it doesn't need to be involved and could be causing the problem.
    Have you tried using different event handlers for the different panels...?

  • How to add to viewPlatformBehavior an Action Event - a button press

    And the main problem I have is to by pressing buttons to change the Viewing Platform?
    I made same transformation to object, which reacts to key pressin:
    public class LewoPrawo extends Behavior{
        private TransformGroup targetLP;
        private Transform3D wysuwanie = new Transform3D();
        private float krok2 = (float) 0.0;
         // create LewoPrawo
        LewoPrawo(TransformGroup targetLP){
        this.targetLP = targetLP;
         public void initialize(){           
                this. wakeupOn(new WakeupOnAWTEvent(AWTEvent.KEY_EVENT_MASK));
        public void processStimulus(Enumeration enumeration){
            this.wakeupOn(new WakeupOnAWTEvent(AWTEvent.KEY_EVENT_MASK));
                KeyEvent event = (KeyEvent) ((WakeupOnAWTEvent) enumeration.nextElement()).getAWTEvent()[0];
               if (event.getKeyCode() == KeyEvent.VK_Q) {
                   krok2 += 0.01;
               if (event.getKeyCode() == KeyEvent.VK_W) {
                   krok2 -= 0.01;
               wysuwanie.set(new Vector3f(krok2, 0.0f, 0.0f));
               wysuwanie.mul(przewrocenie);
               targetLP.setTransform(wysuwanie);
        }And this is the one that I made up to move the viewing platform, but it doesn't work!!!
    public class Perspektywa extends ViewPlatformBehavior{
    private TransformGroup targetVP;
    private Transform3D obrot_obserwatora = new Transform3D();
    private double kat=0.0;
    //create Perspektywa
         Perspektywa(){
         public void initialize(){
         this.wakeupOn(new WakeupOnAWTEvent(AWTEvent.ACTION_EVENT_MASK));
         public void processStimulus(Enumeration enumeration){
         this.wakeupOn(new WakeupOnAWTEvent(AWTEvent.ACTION_EVENT_MASK));
    ActionEvent event = (ActionEvent) ((WakeupOnAWTEvent) enumeration.nextElement()).getAWTEvent()[0];
         if (event.getSource()== przyciski[0])  {
               kat += 0.1;
           if (event.getSource() == przyciski[3]) {
               kat -= 0.1;
            obrot_obserwatora.rotY(kat);
            TransformGroup targetVP =
                simpleU.getViewingPlatform().getViewPlatformTransform();
            targetVP.getTransform( obrot_obserwatora);
    }And what's worse, action events doesnt even work when i replace key events with them, but i don;t know why ;(

    The section from the Swing tutorial on "General Rules for Using Text Components" has a sample program that does this:
    http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html
    Or, you can create a new Action using DefaultEditorKit.CopyAction

Maybe you are looking for