Search in sources :

Example 1 with RowHeaderTable

use of com.alibaba.druid.support.jconsole.model.RowHeaderTable in project druid by alibaba.

the class DruidSQLPanel method tableDataProcess.

@Override
protected void tableDataProcess(ArrayList<LinkedHashMap<String, Object>> data) {
    table = new JTable() {

        private static final long serialVersionUID = 1L;

        @Override
        protected JTableHeader createDefaultTableHeader() {
            return new GroupableTableHeader(columnModel);
        }
    };
    data = preProcess(data);
    // System.out.println(SHOW_LIST);
    tableModel = new DruidTableModel(data, REAL_SHOW_LIST);
    // System.out.println(data.toString());
    table.setModel(tableModel);
    table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    addTableGroup();
    table.addMouseListener(new MouseAdapter() {

        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                // 点击几次,这里是双击事件
                int row = table.getSelectedRow();
                String id = ids.get(row);
                new DruidSqlDetailFrame(id, conn);
            }
        }
    });
    RowHeaderTable header = new RowHeaderTable(table, 20);
    scrollPane.setRowHeaderView(header);
    scrollPane.setViewportView(table);
    JLabel jb = new JLabel("N", SwingConstants.CENTER);
    jb.setBorder(new BevelBorder(BevelBorder.RAISED, null, null, null, null));
    scrollPane.setCorner(JScrollPane.UPPER_LEFT_CORNER, jb);
}
Also used : MouseEvent(java.awt.event.MouseEvent) BevelBorder(javax.swing.border.BevelBorder) MouseAdapter(java.awt.event.MouseAdapter) JTableHeader(javax.swing.table.JTableHeader) JLabel(javax.swing.JLabel) RowHeaderTable(com.alibaba.druid.support.jconsole.model.RowHeaderTable) JTable(javax.swing.JTable) DruidTableModel(com.alibaba.druid.support.jconsole.model.DruidTableModel) GroupableTableHeader(com.alibaba.druid.support.jconsole.model.GroupableTableHeader)

Aggregations

DruidTableModel (com.alibaba.druid.support.jconsole.model.DruidTableModel)1 GroupableTableHeader (com.alibaba.druid.support.jconsole.model.GroupableTableHeader)1 RowHeaderTable (com.alibaba.druid.support.jconsole.model.RowHeaderTable)1 MouseAdapter (java.awt.event.MouseAdapter)1 MouseEvent (java.awt.event.MouseEvent)1 JLabel (javax.swing.JLabel)1 JTable (javax.swing.JTable)1 BevelBorder (javax.swing.border.BevelBorder)1 JTableHeader (javax.swing.table.JTableHeader)1