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

JTable sorting behavior: Double clicking on header does not sort.

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b76
    • CPU:
      x86
    • OS:
      windows_xp
    • Verification:
      Verified

      Description

      Steps to reroduce:
      Compile and run the attached testcase.
      Double clik on the header of the table, multiple times.
      Observed behavior
      Nothing happens, the table is not sorted.
      Note:This behavior can sometimes be slightly itermittent, depending on the clicking speed of the user.
      Expected behavior
      The table should get sorted.
      on Windows, in the windows file explorer, double cliking sorts the file view.
      The end user would expect the same in Jtable. One of the motivation of this table feature was to allow sorting through java api as in an explorer and thereby get closer to native behavior.
      ----------BEGIN SOURCE----------

      import java.awt.*;
      import javax.swing.*;
      import javax.swing.table.*;
      import javax.swing.table.TableCellEditor.*;
      import java.awt.event.*;
      import java.awt.event.KeyEvent.*;
      class IAMATEST extends JPanel {
      public IAMATEST() {
       String table_data[][] = { {"Comedy", "Kindergarten Cop", "1990"},
       {"SciFi", "Total Recall", "1990"},
       {"Action", "Eraser", "1996"} };
       String column_headers[] = {"Genre", "Title", "Year"};
       String combo_items[] = {"Stallone","Schwarzenegger"};
       DefaultTableModel dft = new DefaultTableModel(table_data, column_headers);
       JTable tbl_movies = new JTable(new DefaultTableModel(table_data, column_headers));
       tbl_movies.setColumnSelectionAllowed(false);
       tbl_movies.setRowSelectionAllowed(false);
       tbl_movies.setCellSelectionEnabled(true);
       tbl_movies.setRowHeight(25);
       tbl_movies.setRowSorter(new TableRowSorter(dft));
       JScrollPane jsp = new JScrollPane();
       jsp.getViewport().add(tbl_movies);
       jsp.setSize(600, 250);
       this.add(jsp);
      }
      public static void main(String args[]) {
       JFrame jf = new JFrame();
       jf.add(new IAMATEST());
       jf.setSize(800, 400);
       jf.setVisible(true);
      }
      }

      ----------END SOURCE------------

        Attachments

          Activity

            People

            Assignee:
            svioletsunw Scott Violet (Inactive)
            Reporter:
            smandalisunw Srinivas Mandalika (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: