JComboBox fires an event only after changed selection?!

I have added a JComboBox to my application, combined with an ActionListener which is added to the combobox just after initialization. It works fine, but there is one problem left:
Generally, an event for the ActionListener is initially only fired by a combobox, if the user selects a different item than the last selected one. But I need an event that is fired by the combobox each time an item will be selected, even if it is the same item as the last selected one.
I tried to use an ItemChangeListener, but it gave no success (and sense), it fires an event each time the user wants to select an item from the combobox' item list, that is no solution.
Best way to solve this problem? I thought about a adding a MouseListener, but that might be the longest way. There seems to be no special method in JComboBox class to set this desired property?
Any suggestions?

Hello,
thank you for your answer so far. Well, here is a trivial source code with the problem that still exists (see also my text at the end of this post). This one has been tested using Java 2 SDK V1.4, even using the newest SDK version did not change anything on the behaviour:
import javax.swing.*;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
* JComboBox-Test: using Java 2 SDK V1.4, ActionEvent is only fired by combobox, if
* a different item than the previous one is selected from combobox;
public class Forum3 extends JFrame implements ActionListener {
    String[] CB_ITEMS = {
        "item 1",
        "item 2",
        "item 3",
    public Forum3 () {
        super();
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setLayout(new FlowLayout());
        JComboBox cb = new JComboBox(CB_ITEMS);
        cb.addActionListener(this);
        getContentPane().add(cb);
    public void actionPerformed (ActionEvent e) {
        System.out.println("action!");
    public static void main (String[] argv) {
        Forum3 test = new Forum3();
        test.setSize(300,200);
        test.setVisible(true);
}If you start this program (I am also using Windows XP), you see the JFrame window including the JComboBox. "item 1" is selected by default. If you click again on "item 1", no event will be fired. An event will be fired only, if you choose "item 2" or "item 3". You can try this with any other of the given items. An event will be only fired, if you choose a different item than the last one.
What I need, is a routine that fires an event each time any item is selected!
I would be grateful for a helpful hint, how to solve this in a "clean" way :-)

Similar Messages

  • Which event dispatched after text selection done on spark text area in Apple iPad using Adobe Flex 4

    I need to know which event triggered after text selection done in Apple iPad. This way i have done in desktop air app code (mouse events)
    protected function txtEditor_mouseUpHandler(event:MouseEvent):void
                if(txtEditor.selectionAnchorPosition != txtEditor.selectionActivePosition){
                    showNoteToolBar(event);
                    txtEditor.focusEnabled = true;
                    txtEditor.setFocus();
    But in Apple iPad how to achieve through "Touch Event" ? And also i need how to hide all context menu on Spaek TextArea?. Why Touch.End event is not fired after place cursor on text area ?
    Please help me !

    Ok, so I finally got it working but this is not ideal at all. Adobe really needs to give us some direction on how to properly deal with font embedding and TLF now that the release build breaks all functionality with loading runtime fonts and TLF.
    Problem:
    I am embedding collections of fonts (faces) into single family classes. Each individual face is registered with Font.registerFont(). I need to do this because I have to have mixed fonts within text flows - at least according to Alex H's recent blog post.
    Fonts do not display in TLF without doing the following:
    1. GlobalSettings.resolveFontLookupFunction = null;
    2. editor.textFlow.flowComposer.swfContext = ISWFContext(this.getFontContext("AnyFamilyNameFromAnyFontEmbedded", false, false, FontLookup.EMBEDDED_CFF));
    3. Instead of #2, use editor.textFlow.invalidateAllFormats();
    Either #2 or #3 need to be performed. If I have a spark richEditableText control in MXML with defined familes from the loaded fonts. I even tried placing the control into a separate state so it wasn't created until after the fonts were loaded... I still needed to invalidate the formats or set the context.
    The "AnyFamilyNameFromAnyFontEmbedded" does not need to be all of the embedded family names. It only needs to be one of them. Once one is used, all embedded fonts work. Also, I have to use the internal namespace to even get access to getFontContext, another oddity that, in my humble opinion, should never be necessary to create mixed style TLF content.
    My questions are then:
    1. Why am I required to use ISWFContext if I am using Font.registerFont()?
    2. Why is GlobalSettings.resolveFontLookupFunction = null; also required for this to work?
    3. What is the recommended workflow to embed fonts from multiple SWF files into the release build and have it work without having to jump through all these hoops?

  • Fire an event automatically after reading line from file

    Hi all
    I am writing a programe in which i need to fire an event automatically after reading each line (i.e. on every EOL) from the file.
    Thanks
    jon

    jonhill wrote:
    ..I am writing a programe in which i need to fire an event automatically after reading each line (i.e. on every EOL) from the file.Thanks for sharing that with us. Let us know how it goes. If you have any questions, feel free to ask them.
    BTW - sounds like a very weird requirement.

  • Report to run only after prompt selection

    Hi all,
    we are using obiee 11.1.13, We have a required prompt (with property require user input checked), only after selecting the prompt the report should run, how do we make this work.
    Thanks,
    Sreekanth

    Hi Sreekanth,
    Don't create the prompt separately. Instead create the prompt while creating the report itself (Third tab in the Create report section) . Then add this report to dashboard. Make the default selection of the prompt "None" and "Enable User Input required". Try this and let me know.
    Thanks,
    Arul
    Edited by: Arul on Jul 25, 2011 2:42 AM

  • SelectBooleanCheckbox read-only after setting selection

    Hello!
    I'm trying to set the selection of an adf selectBooleanCheckbox!
    When I set it by the pull-down menu (true, false) in the Property Inspector, everything is ok!
    But when I set the selection depending on an ADF binding, the value is set correct,
    but the checkbox is read-only and a change of the selection is impossible!
    Here's the very simpel code of the Box:
    <af:selectBooleanCheckbox
    label="myLabel"
    value="#{bindings.SomeValue.inputValue != null}"/>
    Can anyone help me, how to enable the checkbox for selection?
    Thank you very much!
    Sebastian
    PS: I'm using JDeveloper 10.1.3.3!

    hi..
    the previous error is ok now..
    below is the script, the status is when click on 'Add new row' button, it will pass status = 'ADD_ROW' and set the startdate read only = False.
    my question now is...
    e.g i've a multiple rows (can display up to 10 rows) display in table form in the page....i query 3 rows of records, then i click 'Add new row' button,
    how to make sure the 3 rows queried early is having startdate read only = Yes and for the new row startdate read only = False?
    with the below codes it will set all rows startdate read only = False (including those queried data)... pls help...
    public void setReadonly(String status)
    OAViewObjectImpl vo = (OAViewObjectImpl)findViewObject("SeaoeAutoMosPVO1");
    OARow row = (OARow)vo.first();
    OAViewObject SeaoeAutoMosSummaryVO = (OAViewObject)findViewObject("SeaoeAutoMosSummaryVO1");
    OARow SeaoeAutoMosSummaryRow = (OARow)SeaoeAutoMosSummaryVO.getCurrentRow();
    if (status=="ADD_ROW")
    row.setAttribute("StartDateRender", Boolean.FALSE);
    else
    row.setAttribute("StartDateRender", Boolean.TRUE);
    }

  • JFrame content displayed only after changing frame size

    Hello everybody,
    could someone explain to me why the content in this frame:
    public class PHPTableReport extends JFrame {
         public PHPTableReport() {
              getContentPane().setLayout(null);
              final JLabel newAppletLabel = new JLabel();
              newFrameLabel.setBorder(new BevelBorder(BevelBorder.LOWERED));
              newFrameLabel.setBackground(Color.BLUE);
              newFrameLabel.setText("New Frame");
              newFrameLabel.setBounds(10, 10, 50, 58);
              getContentPane().add(newAppletLabel);
         }when invoked like this (in a JApplet):
    PHPTableReport pHPTFrame =  new PHPTableReport();
    pHPTFrame.setVisible (true);
    pHPTFrame.setBounds(300, 300, 800, 600);only displays after dragging the window/frame bigger or smaller?
    Thanks in advance again
    Jan

    Change this :
    pHPTFrame.setVisible (true);
    pHPTFrame.setBounds(300, 300, 800, 600);To:
    pHPTFrame.setBounds(300, 300, 800, 600);
    pHPTFrame.setVisible (true);

  • Changing a Record to Read-Only after an event.

    I have a Developer application that needs to be modified. This
    application includes several fields as well as a comments
    field. I'd like to change all updatable fields (not to included
    the comments field) to READ-ONLY after a certain event. Then
    after a certain date, I'd like to make the comments field READ-
    ONLY.
    Do you have any suggestions?
    Regina Grimes
    919/874-3140
    null

    Dear Regina,
    Have you tried to set_block_property in pre-record trigger to update allowed/not allowed depending on the event. And in post-record update not allowed. These triggers must be on block level. Also on item level to the item 'Comment' define pre-item trigger where take a new decision whether you want to open the entire block or not, the same way as on block level triggers. But in post-item trigger always make the entire block read-only again.
    Regards
    Jan Kramle

  • Some, but not all, podcasts existing on the iPod no longer appear in iTunes. Different podcasts have been affected at different times, after changes in the state of the iPod. Only podcasts are affected.

    I have not seen this precise issue addressed anywhere. I don’t know if it’s an iTunes or an iPod problem:
    - Some, but not all, podcasts existing on the iPod no longer appear in iTunes;
      this, after normal behavior for more than a year since purchase of the iPod.
    - Different podcasts have been affected at different times, after changes in the state of the iPod.
    - Only podcasts are affected.
    - This concerns an iPod nano 6th gen. and iTunes 11.0.2 (26) on System 10.6.8
    - The only change to iTunes, the Mac, or the iPod is that just before this condition began
      I’d begun syncing an iPhone via iTunes.
    I sync manually (“manually manage music and videos”). The first time this happened, I wanted to delete seventeen podcast episodes (all belonging to one podcast) existing on the iPod — but they didn’t show up in iTunes. I tried re-downloading them and re-syncing, to see if the new versions would somehow “re-link” to iTunes. They didn’t. Only one — new — episode appeared in iTunes.
    I ultimately reset the iPod and manually resynced all the podcasts I currently had on iTunes. That worked, though I had to painstakingly add in all the other content deleted by the reset.
    So: after that reset and manual sync, all podcasts and episodes on the iPod were visible to iTunes and I was able to delete the podcast and its — now 18 — episodes I’d wanted to get rid of to begin with. But the next time I connected the iPod, only 8 podcast episodes out of 21 episodes total existing on the iPod were visible to iTunes. These are different podcasts; I’d deleted the original “invisible” ones.
    By “visible,” I mean in the “Podcasts” list view under “[name]’s iPod” in the iTunes sidebar. If I select “[name]’s” iPod in the iTunes sidebar and the “Podcasts” tab, all podcasts and episodes are visible, though greyed out because I’m set to sync manually. It’s unclear to me if these are the podcasts on the iPod or those currently in iTunes, as they are currently the same. If I switch to syncing automatically, all content on the iPod will be lost again, so I’m not up to trying it at the moment.
    As I said,  this involves only podcasts. All other content on the iPod does appear in iTunes.

    I have the same problem- i see my movies in the ipod section in itunes and they even show as mpeg4 in the 'kind' section but they dont have that small TV icon next to them. if i play these in itunes, they play fine- but try playing them on the ipod and all you hear is the sound and no picture. All videos that i manually transfer work fine in the beginning- its when i hook up the ipod to the comp again and start itunes- they start showing up without the 'tv' icon!! i have to again transfer them from the itunes library to activate them as videos.
    Need Help!!!

  • How can I fire an event case on the value change of an indicator, or a network variable?

    Hi!  I have an event structure setup to look for a value change of an indicator on the front panel.  The indicator is updated by the value of a boolean network-published shared variable through a seperate parallel loop that is polling all of the network-published shared variables.  The event, however, does not fire when the indicator changes value.  I have switched the indicator to a control and tested it with user interaction and that works just fine.
    I want to use the event structure space for my code exectution because it seems logical that that is where it would go, and it will help keep my block diagram tity.  The code is also something I would like executed with the front pannel temperarily disabled.  I would rather not have the code in my network-variable polling loop because again the tity issue.   I would also rather not use a notification VI wired to an independent loop for this particular code.
    Is there a way to have an event structure fire an event with the value change of an indicator, or a network variable directly?
    Thanks for your input.
    LV 8.5
    -Nic

    Thanks for the reply.
    I went about things a little differently, but got them to work so..... .  It really was not my desire to have a boolean indicator on the front panel.  As previously stated, my ultimate goal was to have an event fire on the change of a network variable, which I had to poll for anyway but that is tucked away in a section where I am handling all my network variables.  I ended up using that Create User Event, Register User Event, and Generate User Event SubVIs to handle the task.
    I've read the help for all of those SubVI's and it is not entirely clear to me if the event fires every time the "Generate User Event" receives some inputs, or if it only fires when the value changes.  I could do a test to find out.  It wouldn't be too difficult to add a shift register or a feedback node and place the Generate User Event in a case structure so that it is only fired when the input changes state.

  • How to get the only the changed or newly added entries in AFTER SAVE.

    I have created table maintenance generated for a table,I want to get the newly added or changed entries while saving thats why im using AFTER SAVE event for the same,can anyone please tell me how to get the only the changed or newly added entries in AFTER SAVE.

    Hi,
    Welcome you post on the forum.
    I have moved your thread here because it is in English and should not in the language specific forum. What is your system version?
    Thanks,
    Gordon

  • Concerning Epson Printer 4880: after changing the Ink from Photo Black to Matte Black I'm not getting the Epson Software in Photoshop and Lightroom. I can not select the paper medium, I don't see my profiles. What is wrong?

    Concerning Epson Printer 4880: after changing the Ink from Photo Black to Matte Black I'm not getting the Epson Software in Photoshop and Lightroom. I can not select the paper medium, I don't see my profiles. What is wrong?

    That is priceless!!!  Thanks!  I sure needed a good laugh after spending/wasting hours & days trying to either get my c6280 to give up on its Ink System Failure fixation, or find a decent replacement.  Unfortunately I need the Smart Web Printing feature that I guess only HP has, or I'd try a different brand. And now even HP has very few models with that available.
     My error msg is a little different from those previously stated, but close:  0xc18a0201.  Even tho there were frustrations with my c6280, I did like several of its unique features which are hard to find now under $100.  I hate how HP (& I suppose other brands also) are CONSTANTLY changing models & then of course ink cartridges.
    Oh heavens, I've had the c6280 a whopping 2 1/2 years!   I'm sure they want us poor slobs to have to buy a new one every year & a day!  To say nothing of the exorbitant prices for ink.  And now if this one is really dead in the water, I have SIX unused #02 ink cartridges which I cannot return---I got them in a combo pack, & for some reason have wound up with THREE lite pink & THREE lite blue cartridges, while having to buy extras of the other colors, that ran out before the others!!!   Yeah, & what's with that not being able to print in BLACK if a color runs out????
    Anyway I really loved your essay!   It's a classic!  And says it all!  I hate that we have to be 'slaves' to the electronic 'wonders'!!!

  • Why does the menu option change to "save as" after I select the print button?

    why does the menu option change to "save as" after I select the print button?

    >>The print command is selected in the File pull down menu, the print menu page pops up, I can then select my networked printer (which incidentally is confirmed to work with other software), the print command is in the bottom right hand corner and finally after depressing this print button a "save as" pop-up menu appears and then it only re-saves the file. Is this an issue with the pdf reader install?  

  • Changes commited to the database only after I update OracledataAdapter twice

    Hi. I am using oracledataadapter to manage the data which is eventually displayed in winform datagridview (Visual Studio 2012)
    everything works fine , but I have to click "Save" buttin twice to see the changes in the database (Oracle express 11g)
    Can you please advice....
    Here is my code
    it is very simple
    1. Obtain connection
    2. Create dataadapter
    3. Create commands
    4. Fill the datatable and dataset
    public partial class Concordance : Form
            OracleDataAdapter setupAdapter;
            DataSet projDataset;
            OracleConnection conn;
            //binding sources
            BindingSource setupBindingSource = new BindingSource();
            DataTable setupTable;
            public Concordance()
                InitializeComponent();
                //load tables
                loadSetup();
            //setup table
            private void loadSetup()
                string oradb = ConfigurationManager.ConnectionStrings["OpenU"].ConnectionString;
                conn = new OracleConnection(oradb);
                try
                   // using (conn = new OracleConnection(oradb))
                    setupAdapter = new OracleDataAdapter("select * from ou_setup", conn);
                        OracleCommandBuilder builder = new OracleCommandBuilder(setupAdapter);
                        projDataset = new DataSet("Concordia");
                        setupTable = new DataTable("Setup");
                        projDataset.Tables.Add(setupTable);
                        setupAdapter.Fill(projDataset,"Setup");
                        //bind the gataGridView
                        this.setupGrid.DataSource = projDataset.Tables["Setup"];
                        this.setupBindingSource.DataSource = projDataset.Tables["Setup"];
                        this.setupNavigator.BindingSource = this.setupBindingSource;
                catch (Exception ex)
                    string error = ex.Message;
                    MessageBox.Show(error);
            private void saveSetupBtn_Click(object sender, EventArgs e)
               // only after sabe button clicked for the second time the changes are commited into the database
                this.setupAdapter.Update(projDataset.Tables["Setup"]);
                MessageBox.Show("saved");

    How are you reading in the object initially? The problem is likely that you are modifying an object from the session cache. When you then read in the object from the uow, it uses the object in the session cache as the back up. So there will not appear to be any changes to persist to the database.
    You will need to make a copy of the object for modification, or use the copy from the unitofwork to make the changes instead of working directly on the object in the session. Disabling the cache means there is no copy in the session cache to use as a back up, so the uow read has to build an object from the database.
    Best Regards,
    Chris

  • How to response the value change of slide bar only after mouse released

    Hi, all
    When I used the slide bar to control my device, I response the value change of slide bar and set the new value to my device. But it will generate response constantly when I use the mouse to drag the pointer, which is not my wanted. I just need to response only after the mouse released. How can I implement this function? 
    Hope your suggestion, thanks a lot.
    Solved!
    Go to Solution.

    No, not if you use the right event under "Mouse".
    “A child of five could understand this. Send someone to fetch a child of five.”
    ― Groucho Marx

  • Can I switch calendars (Ex. "night shift" to "day shift" cal) with a repeating event, but ONLY for that one event??  It asks "for all events or only this event" if i change the time.  But it changes ALL events when i try and switch calendars.  Any help??

    I have 2 calendars set up for my work schedule, a "night shift" and "day shift" calendar.  I've set up repeating events fro Fri/Sat/Sun 3-11pm "night shifts" and Mon/Tues 7am-3pm "day shifts".  But lets say for example that I swap shifts and instead of working nights on Saturday like I normally would, I am now working days.  I want to change that in my calendar.  When I go to change the event, if i change the TIME it asks if i want to change all event or ONLY this event.  no problem....just this single event.  but when i go to change the event from the "night shift" calendar to the "day shift" calendar, it changes ALL the repeating events, and not just that one single event.   can anyone help with this???  am i doing something wrong?  is there a way to do this or not with the new iCal program???  i used to do this and never had any problems.    Thank you!

    You need to follow iPhoto terms since we only know what you tell us
    what are you calling folders - in iPhoto folders can not hold photos - albums hold photos and folders hold albums or other folders
    The basic default view of photo is by event (iPhoto '08 and later)
    Exactly what you you trying to do?
    LN

Maybe you are looking for

  • DNS Scavenging - Which Record are scavenged?

    I am about to enable scavenging in a domain that has never had scavenging enabled properly.  There are hundreds of records with old time stamps.  We have done our due diligence in researching records to disable deleting the old record if it has an ol

  • IGS - UNIX Some Words are Illegible

    Hello,   I have a great problem. I possess IGS version UNIX installed in development and quality and the IGS version Windows installed in production.    IGS in the version Unix the sources don't appear in a correct way. I make alteration in WebApplic

  • Installed Boot Camp drivers for Windows 7, now black screen!

    I have a question--I have a late 2009 iMac with the ATI card, followed Apple's procedure for avoiding the black screen while installing Windows 7 on the partitioned HD, and found I could not update to Boot Camp 3.1 without already having Boot Camp 3.

  • Adding audio to still Photos

    Is there a way to add audio to a photo and send it via MMS?

  • How do you draw a road?

    How do you draw a road? Looking to draw a road as part of a header for a courier website. I am using pse 9