Handling events in combo box

Hello,
I'm very much confused about the handling events of JComboBox with ActionListener and ItemListener. Both are seemed similar to me. If anyone can explain me the differences, it would be helpful for me. Thanks everybody.

ActionEvents are fired each time any item is selected, ItemEvents are only fired, if the selection changes.

Similar Messages

  • Reg - 'F1' key event in Combo box

    Hi,
    Requirement:
          I have requirement that to launch a browser window on press of 'F1' key while the movie (swf) has focus. I did it and working fine for me in web application.
    Problem statement:
          When a movie had been launched and having focus in 'Combo box' (which has list of items starts with A to Z letters) control then, i pressed 'F1' key but the browser window has not been launched, instead 'Combo box's key action event get fired and the item starts with the letter 'P' has been selected in the combo box list. If now again i press 'F1' key the browser window has launched as per my requirement.
          This behavior is happening whenever the launched movie has focus in 'Combo box'; otherwise if the focus is on some other control like TextInput etc., no problem for me. One more information, if the Combo box doesn't have any item starts with the letter 'P' then no problem for me.
          I tried to understand the behavior of combo, but still i don't have any clue. Please share your knowledge/thoughts.
    Environment:
          Flex builder 3.5
          Adobe flash player 11.2
          Windows XP SP3
    Regards,
    Mani

    Hi,
    I just overridden the keydown handler function in ComboBox component to avoid its own event propagation behavior if 'F1' key is pressed and its working fine for me.
    Thanks for all,
    -Mani

  • 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

  • Dynamic Creation of list box on excel sheet and handling events

    hi all ,
    i m working on excel to sap integration application and for that i need to create dynmicaly list boxes in excel and also needs to handler events of each boxes..
    please suggest me somehting asap/
    thanks in advance,
    jigs
    helpful ans will be rewarded.

    hi all ,
    i m working on excel to sap integration application and for that i need to create dynmicaly list boxes in excel and also needs to handler events of each boxes..
    please suggest me somehting asap/
    thanks in advance,
    jigs
    helpful ans will be rewarded.

  • Need to detect when an item is clicked in a combo box in flex 3

    Hello
    I am having a check box and a combo box whenever any selection is made in combo box (current selection may be same as previous selection), I need to select the check box.
    By default the 1st item in combo box is selected and check box is unselected. Now I want that while 1st item is clicked in combo box (although it is selected) , the check box must be selected.
    I have currently used the change event of combo box to do my task. But it is not working if I click on same item as selected item in combo box.
    Also, I thought to use close event of combo box, but that event dispatches in 4 situations out of which I can distinguish only 1 situation from DropDownEvent(for close).
    Please help me regarding this.
    I am using flex sdk 3.5
    Thanks in advance.

    You can use the Close Event to distinguish it.
    To pull out which item has been selected in the combo box, you use the code (in as3)
    ComboBox(event.target).selectedItem.label
    and through the the use of an if statement
    if (ComboBox(event.target).selectedItem.label == "labelName")
    you can distinguish the single situation from the others.

  • Problem in event handling of combo box in JTable cell

    Hi,
    I have a combo box as an editor for a column cells in JTable. I have a event listener for this combo box. When ever I click on the JTable cell whose editor is combo box,
    I get the following exception,
    Exception occurred during event dispatching:
    java.lang.NullPointerException
         at javax.swing.plaf.basic.BasicTableUI$MouseInputHandler.setDispatchComponent(Unknown Source)
         at javax.swing.plaf.basic.BasicTableUI$MouseInputHandler.mousePressed(Unknown Source)
         at java.awt.AWTEventMulticaster.mousePressed(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    Can any one tell me how to over come this problem.
    Thanks,
    Raghu

    Here's an example of the model I used in my JTable. I've placed 2 comboBoxes with no problems.
    Hope this helps.
    public class FileModel5 extends AbstractTableModel
    public boolean isEditable = false;
    protected static int NUM_COLUMNS = 3;
    // initialize number of rows to start out with ...
    protected static int START_NUM_ROWS = 0;
    protected int nextEmptyRow = 0;
    protected int numRows = 0;
    static final public String file = "File";
    static final public String mailName = "Mail Id";
    static final public String postName = "Post Office Id";
    static final public String columnNames[] = {"File", "Mail Id", "Post Office Id"};
    // List of data
    protected Vector data = null;
    public FileModel5()
    data = new Vector();
    public boolean isCellEditable(int rowIndex, int columnIndex)
    // The 2nd & 3rd column or Value field is editable
    if(isEditable)
    if(columnIndex > 0)
    return true;
    return false;
    * JTable uses this method to determine the default renderer/
    * editor for each cell. If we didn't implement this method,
    * then the last column would contain text ("true"/"false"),
    * rather than a check box.
    public Class getColumnClass(int c)
    return getValueAt(0, c).getClass();
    * Retrieves number of columns
    public synchronized int getColumnCount()
    return NUM_COLUMNS;
    * Get a column name
    public String getColumnName(int col)
    return columnNames[col];
    * Retrieves number of records
    public synchronized int getRowCount()
    if (numRows < START_NUM_ROWS)
    return START_NUM_ROWS;
    else
    return numRows;
    * Returns cell information of a record at location row,column
    public synchronized Object getValueAt(int row, int column)
    try
    FileRecord5 p = (FileRecord5)data.elementAt(row);
    switch (column)
    case 0:
    return (String)p.file;
    case 1:
    return (String)p.mailName;
    case 2:
    return (String)p.postName;
    catch (Exception e)
    return "";
    public void setValueAt(Object aValue, int row, int column)
    FileRecord5 arow = (FileRecord5)data.elementAt(row);
    arow.setElementAt((String)aValue, column);
    fireTableCellUpdated(row, column);
    * Returns information of an entire record at location row
    public synchronized FileRecord5 getRecordAt(int row) throws Exception
    try
    return (FileRecord5)data.elementAt(row);
    catch (Exception e)
    throw new Exception("Record not found");
    * Used to add or update a record
    * @param tableRecord
    public synchronized void updateRecord(FileRecord5 tableRecord)
    String file = tableRecord.file;
    FileRecord5 p = null;
    int index = -1;
    boolean found = false;
    boolean addedRow = false;
    int i = 0;
    while (!found && (i < nextEmptyRow))
    p = (FileRecord5)data.elementAt(i);
    if (p.file.equals(file))
    found = true;
    index = i;
    } else
    i++;
    if (found)
    { //update
    data.setElementAt(tableRecord, index);
    else
    if (numRows <= nextEmptyRow)
    //add a row
    numRows++;
    addedRow = true;
    index = nextEmptyRow;
    data.addElement(tableRecord);
    //Notify listeners that the data changed.
    if (addedRow)
    nextEmptyRow++;
    fireTableRowsInserted(index, index);
    else
    fireTableRowsUpdated(index, index);
    * Used to delete a record
    public synchronized void deleteRecord(String file)
    FileRecord5 p = null;
    int index = -1;
    boolean found = false;
    int i = 0;
    while (!found && (i < nextEmptyRow))
    p = (FileRecord5)data.elementAt(i);
    if (p.file.equals(file))
    found = true;
    index = i;
    } else
    i++;
    if (found)
    data.removeElementAt(i);
    nextEmptyRow--;
    numRows--;
    fireTableRowsDeleted(START_NUM_ROWS, numRows);
    * Clears all records
    public synchronized void clear()
    int oldNumRows = numRows;
    numRows = START_NUM_ROWS;
    data.removeAllElements();
    nextEmptyRow = 0;
    if (oldNumRows > START_NUM_ROWS)
    fireTableRowsDeleted(START_NUM_ROWS, oldNumRows - 1);
    fireTableRowsUpdated(0, START_NUM_ROWS - 1);
    * Loads the values into the combo box within the table for mail id
    public void setUpMailColumn(JTable mapTable, ArrayList mailList)
    TableColumn col = mapTable.getColumnModel().getColumn(1);
    javax.swing.JComboBox comboMail = new javax.swing.JComboBox();
    int s = mailList.size();
    for(int i=0; i<s; i++)
    comboMail.addItem(mailList.get(i));
    col.setCellEditor(new DefaultCellEditor(comboMail));
    //Set up tool tips.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for mail Id list");
    col.setCellRenderer(renderer);
    //Set up tool tip for the mailName column header.
    TableCellRenderer headerRenderer = col.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the Mail Id to see a list of choices");
    * Loads the values into the combo box within the table for post office id
    public void setUpPostColumn(JTable mapTable, ArrayList postList)
    TableColumn col = mapTable.getColumnModel().getColumn(2);
    javax.swing.JComboBox combo = new javax.swing.JComboBox();
    int s = postList.size();
    for(int i=0; i<s; i++)
    combo.addItem(postList.get(i));
    col.setCellEditor(new DefaultCellEditor(combo));
    //Set up tool tips.
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setToolTipText("Click for post office Id list");
    col.setCellRenderer(renderer);
    //Set up tool tip for the mailName column header.
    TableCellRenderer headerRenderer = col.getHeaderRenderer();
    if (headerRenderer instanceof DefaultTableCellRenderer)
    ((DefaultTableCellRenderer)headerRenderer).setToolTipText(
    "Click the Post Office Id to see a list of choices");
    }

  • How to populate data in the data table on combo box change event

    hi
    i am deepak .
    i am very new to JSF.
    my problem is i want to populate data in the datatable on the combo box change event.
    for example ---
    combo box has name of the city. when i will select a city
    the details of the city should populate in the datatable. and if i will select another city then the datatable should change accordingly..
    its urgent
    reply as soon as possible
    thanks in advance

    i am using Rational Application Developer to develop my application.
    i am using a combo box and i am assigning cityName from the SDO.
    and i am declaring a variable in the pageCode eg.
    private String cityName;
    public void setCityName(String cityName){
    this.cityName = cityName;
    public String getCityName(){
    return cityName;
    <h:selectOneMenu id="menu1" styleClass="selectOneMenu" value="#{pc_Test1.loginID}" valueChangeListener="#{pc_Test1.handleMenu1ValueChange}">
                        <f:selectItems
                             value="#{selectitems.pc_Test1.usercombo.LOGINID.LOGINID.toArray}" />
                   </h:selectOneMenu>
                   <hx:behavior event="onchange" target="menu1" behaviorAction="get"
                        targetAction="box1"></hx:behavior>
    and also i am declaring a requestParam type variable named city;
    and at the onChangeEvent i am writing the code
    public void handleMenu1ValueChange(ValueChangeEvent valueChangedEvent) {
    FacesContext context = FacesContext.getCurrentInstance();
    Map requestScope = ext.getApplication().createValueBinding("#{requestScope}").getValue(context);
    requestScope.put("login",(String)valueChangedEvent.getNewValue());
    and also i am creating another SDO which is used to populate data in datatable and in this SDO in the where clause i am using that requestParam .
    it is assigning value in the pageCode variable and in the requestParam but it is not populating the dataTable. i don't no why??
    it is possible that i may not clear at this point.
    please send me the way how my problem can be solved.
    thanks in advance

  • Adding an event listener to combo box

    I am working on a mortgage calculator and I cannot figure out how to add an event listener to a combo box.
    I want to get the mortgage term and interest rate to calucate the mortgage using the combo cox. Here is my program.
    Modify the mortgage program to allow the user to input the amount of a mortgage
    and then select from a menu of mortgage loans: 7 year at 5.35%, 15 year at 5.50%, and
    30 year at 5.75%. Use an array for the different loans. Display the mortgage payment
    amount. Then, list the loan balance and interest paid for each payment over the term
    of the loan. Allow the user to loop back and enter a new amount and make a new
    selection, with resulting new values. Allow user to exit if running as an application
    (can't do that for an applet though).
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.event.*;
    import java.text.NumberFormat;
    import java.util.Locale;
    //creates class MortgageCalculator
    public class MortgageCalculator extends JFrame implements ActionListener {
    //creates title for calculator
         JPanel row = new JPanel();
         JLabel mortgageCalculator = new JLabel("MORTGAGE CALCULATOR", JLabel.CENTER);
    //creates labels and text fields for amount entered          
         JPanel firstRow = new JPanel(new GridLayout(3,1,1,1));
         JLabel mortgageLabel = new JLabel("Mortgage Payment $", JLabel.LEFT);
         JTextField mortgageAmount = new JTextField(10);
         JPanel secondRow = new JPanel();
         JLabel termLabel = new JLabel("Mortgage Term/Interest Rate", JLabel.LEFT);
         String[] term = {"7", "15", "30"};
         JComboBox mortgageTerm = new JComboBox(term);
         JPanel thirdRow = new JPanel();
         JLabel interestLabel = new JLabel("Interest Rate (%)", JLabel.LEFT);
         String[] interest = {"5.35", "5.50", "5.75"};
         JComboBox interestRate = new JComboBox(interest);
         JPanel fourthRow = new JPanel(new GridLayout(3, 2, 10, 10));
         JLabel paymentLabel = new JLabel("Monthly Payment $", JLabel.LEFT);
         JTextField monthlyPayment = new JTextField(10);
    //create buttons to calculate payment and clear fields
         JPanel fifthRow = new JPanel(new GridLayout(3, 2, 1, 1));
         JButton calculateButton = new JButton("CALCULATE PAYMENT");
         JButton clearButton = new JButton("CLEAR");
         JButton exitButton = new JButton("EXIT");
    //Display area
         JPanel sixthRow = new JPanel(new GridLayout(2, 2, 10, 10));
         JLabel displayArea = new JLabel(" ", JLabel.LEFT);
         JTextArea textarea = new JTextArea(" ", 8, 50);
    public MortgageCalculator() {
         super("Mortgage Calculator");                     //title of frame
         setSize(550, 350);                                             //size of frame
         setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         Container pane = getContentPane();
         GridLayout grid = new GridLayout(7, 3, 10, 10);
         pane.setLayout(grid);
         pane.add(row);
         pane.add(mortgageCalculator);
         pane.add(firstRow);
         pane.add(mortgageLabel);
         pane.add(mortgageAmount);
         pane.add(secondRow);
         pane.add(termLabel);
         pane.add(mortgageTerm);
         pane.add(thirdRow);
         pane.add(interestLabel);
         pane.add(interestRate);
         pane.add(fourthRow);
         pane.add(paymentLabel);
         pane.add(monthlyPayment);
         monthlyPayment.setEnabled(false);
         pane.add(fifthRow);
         pane.add(calculateButton);
         pane.add(clearButton);
         pane.add(exitButton);
         pane.add(sixthRow);
         pane.add(textarea); //adds texaarea to frame
         pane.add(displayArea);
         setContentPane(pane);
         setVisible(true);
         //Adds Listener to buttons
         calculateButton.addActionListener(this);
         clearButton.addActionListener(this);
         exitButton.addActionListener(this);
         mortgageTerm.addActionListener(this);
         interestRate.addActionListener(this);
    public void actionPerformed(ActionEvent event) { 
         Object command = event.getSource();
         JComboBox mortgageTerm = (JComboBox)event.getSource();
         String termYear = (String)mortgageTerm.getSelectedItem();
    if (command == calculateButton) //calculates mortgage payment
         int year = Integer.parseInt(mortgageTerm.getText());
         double rate = new Double(interestRate.getText()).doubleValue();
         double mortgage = new Double(mortgageAmount.getText()).doubleValue();
         double interest = rate /100.0 / 12.0;
         double monthly = mortgage *(interest/(1-Math.pow(interest+1,-12.0 * year)));
                   NumberFormat myCurrencyFormatter;
                   myCurrencyFormatter = NumberFormat.getCurrencyInstance(Locale.US);
                   monthlyPayment.setText(myCurrencyFormatter.format(monthly));
         if(command == clearButton) //clears all text fields
                   mortgageAmount.setText(null);
                   //mortgageTerm.setText(null);
                   //interestRate.setText(null);
                   monthlyPayment.setText(null);
              if(command == exitButton) //sets exit button
                        System.exit(0);
         public static void main(String[] arguments) {
              MortgageCalculator mor = new MortgageCalculator();

    The OP already did this to both JComboBoxes.
    mochatay, here is a new actionPerformed method for you to use.
    I've improved a few things here and there...
    1) You can't just cast the ActionEvent's source into a JComboBox!
    What if it was a JButton that fired the event? Then you would get ClassCastExceptions (I'm sure you did)
    So check for all options, what the source of the ActionEvent actually was...
    2) You can't assume the user will always type in valid data.
    So enclose the Integer and Double parse methods in try-catch brakcets.
    Then you can do something when you know that the user has entered invalid input
    (like tell him/her what a clumsy idiot they are !)
    3) As soon as user presses an item in any JComboBox, just re-calculate.
    I did this here by programmatically clicking the 'Calculate' button.
    Alternatively, you could have a 'calculate' method, which does everything inside the
    if(command==calculateButton) if-block.
    This will be called when:
    a)calculateButton is pressed
    b)when either of the JComboBoxes are pressed.
    public void actionPerformed (ActionEvent event)
            Object command = event.getSource ();
            if (command == calculateButton) //calculates mortgage payment
                int year = 0;
                double rate = 0;
                double mortgage = 0;
                double interest = 0;
                /* If user has input invalid data, tell him so
                and return (Exit from this method back to where we were before */
                try
                    year = Integer.parseInt (mortgageTerm.getSelectedItem ().toString ());
                    rate = new Double (interestRate.getSelectedItem ().toString ()).doubleValue ();
                    mortgage = new Double (mortgageAmount.getText ()).doubleValue ();
                    interest = rate / 100.0 / 12.0;
                catch (NumberFormatException nfe)
                    /* Display a message Dialogue box with a message */
                    JOptionPane.showMessageDialog (this, "Error! Invalid input!");
                    return;
                double monthly = mortgage * (interest / (1 - Math.pow (interest + 1, -12.0 * year)));
                NumberFormat myCurrencyFormatter;
                myCurrencyFormatter = NumberFormat.getCurrencyInstance (Locale.US);
                monthlyPayment.setText (myCurrencyFormatter.format (monthly));
            else if (command == clearButton) //clears all text fields
                /* Better than setting it to null (I think) */
                mortgageAmount.setText ("");
                //mortgageTerm.setText(null);
                //interestRate.setText(null);
                monthlyPayment.setText ("");
            else if (command == exitButton) //sets exit button
                System.exit (0);
            else if (command == mortgageTerm)
                /* Programmatically 'clicks' the button,
                As is user had clicked it */
                calculateButton.doClick ();
            else if (command == interestRate)
                calculateButton.doClick ();
            //JComboBox mortgageTerm = (JComboBox) event.getSource ();
            //String termYear = (String) mortgageTerm.getSelectedItem ();
        }Hope this solves your problems.
    I also hope you'll be able to learn from what I've indicated, so you can use similar things yourself
    in future!
    Regards,
    lutha

  • Combo box, ring and event to modify them runtime

    Hi,
    I attached a picture of the block diagram. Using LV 8.2.1, win XP.
    What I want : User should select from Main Selection, and that brings up new values for strings in the other menus (tried both combo box and menu ring items).
    Teh problem : This block doesn't do that. Why? Looking with probe, I see the event captured and data are ok until the property node. They are not writed and on the front panel I see no difference.
    Thanx
    Attachments:
    double box test.jpg ‏97 KB
    Test doppio ring.vi ‏21 KB

    Slyfer wrote:
    I thought that the code inside the while loop but outside the event structure wasn't care.
    So if I want to do something continuosly (for example continuosly comparing two integer values to have a real-time boolean led indicator on front panel), do I put the code in the middle? This is a bit confusing thinking about the "timeout event"....
    Use the timeout event or put in the middle (=outside event structure but inside while loop.... at which CPU rate is executed?? too fast?) ??
    Just a suggestion. The timeout event for the Event Structure [ES] is equivalent to that of providing a small delay inside the while loop.
    But it is not mandatory. If you dont wire some value to the timeout terminal, but still want to something, like comparison, you can very well put that code outside the ES but inside the while loop. It ll execute.
    Else you can wire a value like 50 or 100 to the timeout terminal [ this gives enough time for the execution of the various codes inside the various events configured for the ES], so that the ES times out for every 50 or 100 ms when none of the other events occurs. If you put your comparison code here, it ll be doing the comparison all the time or whenever the ES waits and crosses the specified ms after an event has happened.
    I hope this gives you a clear idea about eventstructures.
    See the below links for more details on Event Structures.
    http://zone.ni.com/devzone/cda/tut/p/id/3331
    http://zone.ni.com:80/reference/en-XX/help/371361B-01/lvconcepts/using_events_in_labview/
    http://zone.ni.com/reference/en-XX/help/371361B-01/lvhowto/caveatsrecmndtnsevnts/
    - Partha
    LabVIEW - Wires that catch bugs!

  • Catching COMBO BOX item changed in VALIDATE event

    Hi expert,
    I need to catch the item changed event for a combo box.
    below the code:
    <B1Listener(BoEventTypes.et_VALIDATE, False)> _
    Public Overridable Sub OnAfterValidate(ByVal pVal As ItemEvent)
                Dim form As Form = B1Connections.theAppl.Forms().Item(pVal.FormUID)
                Dim mt As Matrix = Form.Items.Item("Matrix_0").Specific
    if (pVal.ColUID.Equals("TipoList") And pVal.ItemChanged) Then
    end if
    but pVal.ItemChanged is always equal to false even if I change the value selected in combo box.
    can anyone help me?
    Thanks in advance.
    Best regards
    Andrea

    Hi Andrea,
    you can also catch the Event through
    pVal.EventType =SAPbouiCOM.BoEventTypes.et_COMBO_SELECT
    through this event, you can perform you're reuqirement.
    regards
    shiva

  • Event problem in editable combo box

    I have three editable combo box in my JDialog. I can select the value from the combo or I can enter any value. I have to perform some operation when one button is pressed after I have given the values in the three combo boxes. Here, If I select any value from the combo box, there is no problem. But if I enter the value in the combo boxes, when I press the button, in the first click nothing is happening. The First click just selects the value that entered in the last combo box and in the second click it works properly. I am not facing this problem in JDK 1.2.2 or JDK1.3. This occurs only in JDK1.4. Please let me if anyone knows the reason for this.
    Thanks.

    in the fla that contains your loadMovie() statement:
    1. drag a combobox to the stage.
    2. remove it.
    3. the combobox component will now be in your library.
    re-publish your swf and retest.

  • Cascaded Combo Box handling?

    I've two combo boxes(cascaded) if i click directly on second combo box it should display error message like "Please Select 1st Combo Box"
    Please Help  me Out
    Thank you
    Raghu
    Message was edited by: Michael Appleby

            //MIR Category DropDown
            var mirCategoryCombo= new sap.ui.commons.ComboBox({
                id:"mirCategoryCombo",
                tooltip:"Select a category",
                value:"",
                width:"100%",
                editable:false,
                change:function(){
                    if(this.getSelectedKey()==""||this.getSelectedKey()==null){
                        this.setValueState(sap.ui.core.ValueState.Error);
                        raiseNotification(5, 20014,  ""  , "", "", "", "I");
                    }else{
                        this.setValueState(sap.ui.core.ValueState.None);
                        // get all product group based on category
                        mirController.getMirProductGroupByCategory("form");
                    mirController.mirEmptyProductControls("mirCategoryCombo");
    var mirProductGroupCombo = new sap.ui.commons.ComboBox({
                id:"mirProductGroupCombo",
                width:"100%",
                editable:false,
                liveChange:function(){
                  if(sap.ui.getCore().byId("mirCategoryCombo").getValue()==""){
                      this.setValueState(sap.ui.core.ValueState.Error);
                  }else{
                      this.setValueState(sap.ui.core.ValueState.None);
                change:function(){
                    if(this.getSelectedKey()=="" || this.getSelectedKey()==null){
                        this.setValueState(sap.ui.core.ValueState.Error);
                        raiseNotification(5,20019,"","","","","I");
                    }else{
                        this.setValueState(sap.ui.core.ValueState.None);
                    mirController.mirEmptyProductControls("mirProductGroupCombo");

  • How can I make the combo box turn to the value of black.

    When the show button is pressed (and not before), a filled black square should be
    displayed in the display area. The combo box (or drop down list) that enables the user to choose the colour of
    the displayed shape and the altering should take effect immediately.When the show button is pressed,
    the image should immediately revert to the black square, the combo box should show the value that
    correspond to the black.
    Now ,the problem is: after I pressed show button, the image is reverted to the black square,but I don't know
    how can I make the combo box turn to the value of black.
    Any help or hint?Thanks a lot!
    coding 1.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class test extends JFrame {
         private JPanel buttonPanel;
         private DrawPanel myPanel;
         private JButton showButton;
         private JComboBox colorComboBox;
    private boolean isShow;
         private int shape;
         private boolean isFill=true;
    private String colorNames[] = {"black", "blue", "cyan", "darkGray", "gray",
    "green", "lightgray", "magenta", "orange",
    "pink", "red", "white", "yellow"}; // color names list in ComboBox
    private Color colors[] = {Color.black, Color.blue, Color.cyan, Color.darkGray,
                              Color.gray, Color.green, Color.lightGray, Color.magenta,
                              Color.orange, Color.pink, Color.red, Color.white, Color.yellow};
         public test() {
         super("Draw Shapes");
         // creat custom drawing panel
    myPanel = new DrawPanel(); // instantiate a DrawPanel object
    myPanel.setBackground(Color.white);
         // set up showButton
    // register an event handler for showButton's ActionEvent
    showButton = new JButton ("show");
         showButton.addActionListener(
              // anonymous inner class to handle showButton events
         new ActionListener() {
                   // draw a black filled square shape after clicking showButton
         public void actionPerformed (ActionEvent event) {
                             // call DrawPanel method setShowStatus and pass an parameter
              // to decide if show the shape
         myPanel.setShowStatus(true);
                   isShow = myPanel.getShowStatus();
                                            shape = DrawPanel.SQUARE;
                        // call DrawPanel method setShape to indicate shape to draw
                                            myPanel.setShape(shape);
                        // call DrawPanel method setFill to indicate to draw a filled shape
                                            myPanel.setFill(true);
                        // call DrawPanel method draw
                                            myPanel.draw();
                             myPanel.setFill(true);
                             myPanel.setForeground(Color.black);
                   }// end anonymous inner class
         );// end call to addActionListener
    // set up colorComboBox
    // register event handlers for colorComboBox's ItemEvent
    colorComboBox = new JComboBox(colorNames);
    colorComboBox.setMaximumRowCount(5);
    colorComboBox.addItemListener(
         // anonymous inner class to handle colorComboBox events
         new ItemListener() {
         // select shape's color
         public void itemStateChanged(ItemEvent event) {
         if(event.getStateChange() == ItemEvent.SELECTED)
         // call DrawPanel method setForeground
         // and pass an element value of colors array
         myPanel.setForeground(colors[colorComboBox.getSelectedIndex()]);
    myPanel.draw();
    }// end anonymous inner class
    ); // end call to addItemListener
    // set up panel containing buttons
         buttonPanel = new JPanel();
    buttonPanel.setLayout(new GridLayout(4, 1, 0, 50));
         buttonPanel.add(showButton);
    buttonPanel.add(colorComboBox);
    JPanel radioButtonPanel = new JPanel();
    radioButtonPanel.setLayout(new GridLayout(2, 1, 0, 20));
    Container container = getContentPane();
    container.setLayout(new BorderLayout(10,10));
    container.add(myPanel, BorderLayout.CENTER);
         container.add(buttonPanel, BorderLayout.EAST);
    setSize(500, 400);
         setVisible(true);
         public static void main(String args[]) {
         test application = new test();
         application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    coding 2
    import java.awt.*;
    import javax.swing.*;
    public class DrawPanel extends JPanel {
         public final static int CIRCLE = 1, SQUARE = 2;
         private int shape;
         private boolean fill;
         private boolean showStatus;
    private int shapeSize = 100;
    private Color foreground;
         // draw a specified shape
    public void paintComponent (Graphics g){
              super.paintComponent(g);
              // find center
    int x=(getSize().width-shapeSize)/2;
              int y=(getSize().height-shapeSize)/2;
              if (shape == CIRCLE) {
         if (fill == true){
         g.setColor(foreground);
              g.fillOval(x, y, shapeSize, shapeSize);
    else{
                   g.setColor(foreground);
    g.drawOval(x, y, shapeSize, shapeSize);
              else if (shape == SQUARE){
         if (fill == true){
         g.setColor(foreground);
                        g.fillRect(x, y, shapeSize, shapeSize);
    else{
                        g.setColor(foreground);
    g.drawRect(x, y, shapeSize, shapeSize);
    // set showStatus value
    public void setShowStatus (boolean s) {
              showStatus = s;
         // return showstatus value
    public boolean getShowStatus () {
              return showStatus;
         // set fill value
    public void setFill(boolean isFill) {
              fill = isFill;
         // set shape value
    public void setShape(int shapeToDraw) {
              shape = shapeToDraw;
    // set shapeSize value
    public void setShapeSize(int newShapeSize) {
              shapeSize = newShapeSize;
    // set foreground value
    public void setForeground(Color newColor) {
              foreground = newColor;
         // repaint DrawPanel
    public void draw (){
              if(showStatus == true)
              repaint();

    Hello,
    does setSelectedIndex(int anIndex)
    do what you need?
    See Java Doc for JComboBox.

  • SBO 2005 combo box does not update value at first time

    Hi!I developed an addon for sbo 2004 with a combo box populated with the months of the year, and it works. The same code run on SBO 2005 works only after the second selection. Has anyone found the same problem?

    definition of the item:
    item = form.Items.Add("oMese", SAPbouiCOM.BoFormItemTypes.it_COMBO_BOX)
                    item.Left = 245
                    item.Top = 5
                    item.Width = 80
                    item.DisplayDesc = True
                    combo = item.Specific
                    combo.DataBind.SetBound(True, "", "uMese")
                    combo.ValidValues.Add(1, "Gennaio")
                    combo.ValidValues.Add(2, "Febbraio")
    event handling:
    inside ItemEvent in case the item is selected
    Case SAPbouiCOM.BoEventTypes.et_COMBO_SELECT
                        Select Case pVal.FormUID
                            Case "PRG_UFM_0002_RegIVAAcq"
                                retCode = oTy_RACQ.FormComboSelect(pVal, BubbleEvent)
      Public Shared Function FormComboSelect(ByVal pVal As SAPbouiCOM.ItemEvent, _
                                               ByRef BubbleEvent As Boolean, _
                                               ByRef funCaller As Object, _
                                               ByVal funCallerID As Integer, _
                                               ByRef aForm As SAPbouiCOM.Form) _
                                               As Integer
            Dim msg As String
            Dim edt As SAPbouiCOM.EditText
            Dim cmb As SAPbouiCOM.ComboBox
            Dim obt As SAPbouiCOM.OptionBtn
            Dim cbx As SAPbouiCOM.CheckBox
            Dim mtx As SAPbouiCOM.Matrix
            Try
                If pVal.Before_Action = True Then
                    Select Case pVal.ItemUID
                        Case "oMese"
                            Dim stre As New strEstremi
                            cmb = aForm.Items.Item("oMese").Specific
                            edt = aForm.Items.Item("anno").Specific
                            If Not cmb.Selected Is Nothing Then
                                GetEstremiPeriod(edt.Value, cmb.Selected.Value, "M", stre)
                                edt = aForm.Items.Item("dtFrom").Specific
                                edt.String = stre.dtFrom
                                edt = aForm.Items.Item("dtTo").Specific
                                edt.String = stre.dtTo
                            End If
    end function
    thank you I hope is enough otherwise please tell me

  • Problem with combo boxes and the reset button in certain situations

    Hi Everyone,
    i have a problem to make the reset-button function properly in an what-if analysis dashboard.
    The dashboard uses two combo boxes that are not visible at the same time. In my application the second combo box only appears when a dedicated menu (label based menu button) has been activated.
    So i have combo box 1 when menu A is active an dand combo box 2 when menu 2 is active.
    After starting the dashboard initial values are fine. If you then directly change to menu 2 (seeing combo box 2 with
    the correct default value) and press the reset button, the dashboard returns to the initial view, showing
    the menu 1 with the correct default value. If you now switch back  to menu 2, you will see, that the combo box 2
    is empty (i.e. nothing selected).
    I also tracked the destination cells for the combo box value results as well as the source cells for the "selected item" and the
    destination cells for the "Insert Selected Item". All this values seem to be correct. Therefore i assume that
    this is an issue of event handling. Maybe the combo box 2 does not refresh its selected value because it is already
    invisible when the values are restored.
    This case can easily be simulated by placing two combo boxes and a push button (that changes the visibility of
    the combo boxes) and the reset button on the canvas.
    Maybe someone can help. I am able to provide a test xlf, if neccessary.
    Thanks,
    Oliver
    P.S. I am using Xcelsius SP4 (Version 5.4.0.0)

    Hello Debjit_Singha_86,
    thank you for your support. At the moment i have the following setting:
    label based menu
    - General: Insertion Type "value" from a list of ID's for the menu-items to a dedicated cell (current menu ID, say tab1!$A$1)
    - Behavior: Selected item (position) fixted to item 1
    hidden combo box
    - General: Insertion Type "position" to a dedicated cell with the current choice (say tab1!$B$1)
    - Behavior: Selected item (position) to the same cell (tab1!$B$1)
    Can you give me a hint on how to connect the two components according to your solution, so that the label based menu sets the default for the hidden combox box only in case, that the reset button is pressed?
    Thanks,
    Oliver

Maybe you are looking for

  • Jdeveloper - Process exited with exit code 128.

    Oracle, I downloaded Jdeveloper from Oracle website. I tried to create simple helloworld jsp & tried to run from jdeveloper. I set project properties->compiler->use Javac also, but still it gives same error message in "Running Embedded OC4j server Lo

  • Chance of getting a contract with no credit

    Hi, so I recently ordered a 2 year contract along with a phone a couple hours ago. I also got the confirmation e-mail with the order number and everything included. But someone told me that there is a credit check, which I completely forgot about. Wh

  • New install HTMLDB in 9.2.0.2 - no access

    I started with a new 9.2.0.4 instance on Redhat and installed HTML DB from a Windows client. Install log list no unusual issues, but trying to go to http://host:7777/pls/htmldb gives the following error: Service Temporarily Unavailable The server is

  • My iphone 3g stuck in apple logo how can i fix this ?

    in the middle of jailbreak my iphone 3g is stuck in apple logo then i turn off my iphone and its not fixed please help how can i fix this problem and it is not connect in computer and itune ?

  • Elements 10 missing albums and keyword tags

    I just upgraded to elements 10 and now have no albums or tags in the new organizer. Any idea why or how to get them?