Uploaded image for project: 'NetBeans'
  1. NetBeans
  2. NETBEANS-2274

Options Dialog - Panel "Fonts & Colors" - Syntax Pane relies on undocumented ActionEvent#getModifiers behavior

    XMLWordPrintableJSON

Details

    Description

      In the Options Dialog, the Panel "Fonts & Colors" and there the subpanel Syntax Pane relies on undocumented ActionEvent#getModifiers behavior.

      The constructor of ActionEvent:

      https://docs.oracle.com/javase/8/docs/api/java/awt/event/ActionEvent.html#ActionEvent-java.lang.Object-int-java.lang.String-int-

      Only talks about modifier keys as parameter options:

      modifiers - The modifier keys down during event (shift, ctrl, alt, meta). Passing negative parameter is not recommended. Zero value means that no modifiers were passed

      The code in the panel checks for the mask for mouse button 1:

                  if(evt.getModifiers() == InputEvent.BUTTON1_MASK) { // mouse clicked
                      updateLanguageCombobox();
                  }

      On Ubuntu 18.10, OpenJDK 1.8u191:

      openjdk version "1.8.0_191"
      OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.18.10.1-b12)
      OpenJDK 64-Bit Server VM (build 25.191-b12, mixed mode)

      As the keyboard handling for the ComboBox is also explicitly coded in the panel:

              cbLanguage.addKeyListener(new java.awt.event.KeyAdapter() {
                  @Override
                  public void keyReleased(KeyEvent evt) {
                      if (evt.getKeyCode() == KeyEvent.VK_ENTER || evt.getKeyCode() == KeyEvent.VK_SPACE) {
                          updateLanguageCombobox();
                      }
                  }
              });

      Both special cases should be removed and replaced with the default combobox behavior.

      The attached screenshot shows the broken state (combobox content for language does not match displayed language).

       

      Attachments

        1. Bildschirmfoto_2019-03-18_21-59-36.png
          82 kB
          Matthias Bläsing

        Activity

          People

            matthiasblaesing Matthias Bläsing
            matthiasblaesing Matthias Bläsing
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 0.5h
                0.5h