WidgetRunning2

hey everyone, need some help here im trying to create this(in the picture shown) but the problem im having is when i select the item from the combobox i want to show the price in the text field as shown but im not sure how i would go by doing this. along with the spinner; when i change the value i want the value in the total price to be updated.

forgot to mention that i need to use the StateChanged event for the Spinner and the ItemStateChanged event for the ComboBox.

In that case use those events rather than the action event, but remember that you will need to check exactly which state changes you are receiving and ignore some (eg item de-selected)

Im not sure how to even start doing this my i really need a refresher on java.

  private void spnQuantityStateChanged(javax.swing.event.ChangeEvent evt) {                                         
        // 
        getPrice();



    }                                        

    private void cbxWidgetItemStateChanged(java.awt.event.ItemEvent evt) {                                           
        // 
        getPrice();


    }                                          

    private void getPrice(){
        int index;
        int quantity;
        int price;
        int total;


       quantity = Integer.parseInt(spnQuantity.getValue().toString());

       index = cbxWidget.getSelectedIndex();
         if (index == 0)
        {
            price = 1;
        }
         else if (index == 1)
         {
             price = 2;
         }
         else if (index == 2)
         {
             price = 3;
         }


    }

This is what i have any suggestions? is there a better way of doing it?

What is the code supposed to do? I don't see any comments in the posted code describing what it does.

This article has been dead for over six months. Start a new discussion instead.