Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8106179

SwingComboBox mouse event problems

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: javafx
    • Environment:

      JavaFX 1.0
      NetBeans IDE 6.5
      Windows XP

      Description

      To resume the issue here is an example code (explanation on bottom):

      package example;

      import javafx.stage.Stage;
      import javafx.scene.Scene;
      import javafx.ext.swing.SwingComboBox;
      import javafx.ext.swing.SwingComboBoxItem;
      import javafx.scene.shape.Rectangle;
      import javafx.scene.paint.Color;
      import javafx.scene.input.MouseEvent;

      var blueColor:Color = Color.BLUE;
      var redColor:Color = Color.RED;
      var rectangleColor:Color = redColor;

      //Changes the color or the rectangle from red to blue and from blue to red
      function mousePressed(evt:MouseEvent):Void{
          if (rectangleColor == blueColor){
              rectangleColor = redColor;
          }
              else{
                rectangleColor = blueColor;
          }
      }

      Stage {
          title: "Application title"
          width: 250
          height: 300
          scene: Scene {
              content: [
                  Rectangle{
                      height: 20
                      width: 200
                      y: 45
                      x: 3
                      fill: bind rectangleColor;
                      onMousePressed: mousePressed;
                  }
                  SwingComboBox{
                      items: [
                          SwingComboBoxItem{text:"Item number 1" }
                          SwingComboBoxItem{text:"Item number 2"}
                          SwingComboBoxItem{text:"Item number 3"}
                          SwingComboBoxItem{text:"Item number 4"}
                          SwingComboBoxItem{text:"Item number 5"}
                          SwingComboBoxItem{text:"Item number 6"}
                          SwingComboBoxItem{text:"Item number 7"}
                      ]
                      selectedIndex: 0
                      blocksMouse: true
                  }
              ]
          }
      }

      If you compile and execute this code you can see that if you select the item number 2 from the combobox by clicking your mouse, the rectangle thats behind it will change color due to the onMousePressed event on the rectangle. This doesnt make sense since in the expected behavior the event of the rectangle shouldnt trigger.

        Attachments

          Activity

            People

            • Assignee:
              kcr Kevin Rushforth
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: