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

Key events ('SPACE', 'UP', 'DOWN') aren't blocked if mouse is kept in 'PRESSED' state for List, XAWT

XMLWordPrintable

    • b45
    • other, x86
    • linux, solaris_2.5.1
    • Verified

       OPERATING SYSTEM(S):
      SuSE SLES9 for IA32

      FULL JDK VERSION(S):
      java version "1.5.0_03"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_03-b07)
      Java HotSpot(TM) Server VM (build 1.5.0_03-b07, mixed mode)

      DESCRIPTION:
      On XAWT, Single-Selection List component can accept Multi-Selection.
      Actually visual feedback is not correct, it looks like Multi-Selection.

      Test instruction is as follows:
      1. Compile and run test program (ListSelectionTest.java) on C locale
         $ java ListSelectionTest
      2. Move mouse cursor on "Sunday" and press mouse left button and keep it.
         At this moment, "Sunday" seems to be selected because of visual feedback
      3. Press space key then "January", it seems to be also selected because of visual feedback.
         ("January" and "Sunday" are reversed)
      4. Release mouse left button.
         At this moment, Press "Print Selected Items" button, only "January" is selected
      5. If you want to do it again, click "Sunday" then click "January" then try step 2 - 4
      6. The other thing, click "Sunday" and press mouse left button and keep it.
      7. Press Up or Down key, selected item is moved
      8. Press "Print Selected Items" button, "Sunday" is not printed

      === ListSelectionTest.java =====================================================
      import java.awt.*;
      import java.awt.event.*;
      import java.text.DateFormatSymbols;

      class ListSelectionTest extends Frame implements ActionListener {
          List list;
          ListSelectionTest(Boolean multi) {
              list = new List();
              list.setMultipleMode(multi);
              Button btn = new Button("Print Selected Items");
              btn.addActionListener(this);
              DateFormatSymbols d = new DateFormatSymbols();
              String[] months = d.getMonths();
              for (int i = 0; i < months.length ; i++) {
                  if (months[i].equals("")) continue;
                  list.add(months[i]);
              }
              String[] weekdays = d.getWeekdays();
              for (int i = 0; i < weekdays.length ; i++) {
                  if (weekdays[i].equals("")) continue;
                  list.add(weekdays[i]);
              }
              setLayout(new BorderLayout());
              add(list, BorderLayout.CENTER);
              add(btn, BorderLayout.SOUTH);
          }
          public void actionPerformed(ActionEvent e) {
              String[] selected = list.getSelectedItems();
              for(int i=0; i<selected.length; i++) {
                  System.out.println("["+i+"]:"+selected[i]);
              }
          }
          public static void main(String[] args) {
              ListSelectionTest f = new ListSelectionTest(args.length > 0);
              f.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent event) { System.exit(0); }
              });
              f.setSize(300, 300);
              f.setVisible(true);
          }
      }
      ###@###.### 2005-07-01 12:50:56 GMT

            dcherepanov Dmitry Cherepanov
            elarsen Erik Larsen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: