直接的方法是重写并重置TableUI,缺点是代价太大了
变通方法是将Table和ScrollPane封装在一起,在左边setRowHeaderView()添加一个类似表头的东西,就可以象拖动列一样拖动行了,至于那个怎么写你看看TableHeader的代码吧。原代码工作量较大,我就没时间写了。

解决方案 »

  1.   

    是啊,你要实现鼠标拖动至少得重写JTable的MouseListener响应吧或许别人有更好的办法?不过我不知道了,你问问其他的人看看。
      

  2.   

    if (DEBUG) {
                table.addMouseListener(new MouseAdapter() {
                    public void mouseClicked(MouseEvent e) {
                        printDebugData(table);
                    }
                });
            }        //Create the scroll pane and add the table to it. 
            JScrollPane scrollPane = new JScrollPane(table);        //Add the scroll pane to this window.
            getContentPane().add(scrollPane, BorderLayout.CENTER);        addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
                }
            });
        }    private void printDebugData(JTable table) {
            int numRows = table.getRowCount();
            int numCols = table.getColumnCount();
            javax.swing.table.TableModel model = table.getModel();        System.out.println("Value of data: ");
            for (int i=0; i < numRows; i++) {
                System.out.print("    row " + i + ":");
                for (int j=0; j < numCols; j++) {
                    System.out.print("  " + model.getValueAt(i, j));
                }
                System.out.println();
            }
            System.out.println("--------------------------");
        }
      

  3.   

    找找有没有现成的控件吧。to hellohong1997(question)
    什么意思??
      

  4.   

    解决了。
    监听鼠标事件,利用columnAtPoint()和rowAtPoint()定位到单元格,然后判断,交换Model的数据,更新。巨繁...