public void mouseClicked(MouseEvent e) { JTableHeader h = (JTableHeader) e.getSource(); TableColumnModel columnModel = h.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int column = columnModel.getColumn(viewColumn).getModelIndex(); if (column != -1) { sorting_column = column; // 0 == priority icon column // 4 == priority text column if (column == 0) sorting_column = 4; if (e.isControlDown()) sorting_column = -1; else opposite = !opposite; TaskTable treetable = ((TaskTable) h.getTable()); // java.util.Collection expanded = treetable.getExpandedTreeNodes(); treetable.tableChanged(); // treetable.setExpandedTreeNodes(expanded); // h.updateUI(); h.resizeAndRepaint(); } }
public void mousePressed(MouseEvent e) { int col = header.columnAtPoint(e.getPoint()); int sortCol = header.getTable().convertColumnIndexToModel(col); renderer.setPressedColumn(col); renderer.setSelectedColumn(col); header.repaint(); if (header.getTable().isEditing()) { header.getTable().getCellEditor().stopCellEditing(); } boolean isAscent; if (SortButtonRenderer.DOWN == renderer.getState(col)) { isAscent = true; } else { isAscent = false; } ((SortableTableModel) header.getTable().getModel()).sortByColumn(sortCol, isAscent); }
private void maybeShowPopup(MouseEvent e) { if (e.isPopupTrigger()) { final Component component = e.getComponent(); if (component instanceof javax.swing.table.JTableHeader) { javax.swing.table.JTableHeader jTableHeader = (javax.swing.table.JTableHeader) component; final JTable jTable1 = jTableHeader.getTable(); getMyTableColumnSelectionPopupMenu(jTable1, e.getX()).show(component, e.getX(), e.getY()); } } }
public void mouseMoved(MouseEvent evt) { JTableHeader header = (JTableHeader) evt.getSource(); JTable table = header.getTable(); TableColumnModel colModel = table.getColumnModel(); int vColIndex = colModel.getColumnIndexAtX(evt.getX()); if (vColIndex != this.index && vColIndex >= 0) { header.setToolTipText(listModel.getColumnName(vColIndex)); } this.index = vColIndex; }
protected void handleClickEvent(MouseEvent e) { if (mousePressed) { mousePressed = false; JTableHeader header = (JTableHeader) (e.getSource()); JTable tableView = header.getTable(); TableColumnModel columnModel = tableView.getColumnModel(); int viewColumn = columnModel.getColumnIndexAtX(e.getX()); int _column = tableView.convertColumnIndexToModel(viewColumn); if (viewColumn == this.column && e.getClickCount() == 1 && _column != -1) { doClick(); } } }
private void selectTable(Component component, Point point) throws AssertionError { int componentCount = getComponentCount(); for (int i = componentCount; i > 0; ) { remove(--i); } if (component instanceof AttributeTable) { table = (AttributeTable) component; row = table.rowAtPoint(point); if (table.getValueAt(row, 0).equals("")) { row--; } int selectedRow = table.getSelectedRow(); } else if (component instanceof JTableHeader) { JTableHeader header = (JTableHeader) component; table = (AttributeTable) header.getTable(); row = -1; } else { throw new AssertionError(); } table.requestFocus(); }
@Override public void mouseMoved(MouseEvent evt) { JTableHeader header = (JTableHeader) evt.getSource(); JTable table = header.getTable(); TableColumnModel colModel = table.getColumnModel(); int vColIndex = colModel.getColumnIndexAtX(evt.getX()); TableColumn col = null; if (vColIndex >= 0) { col = colModel.getColumn(table.convertColumnIndexToModel(vColIndex)); } if (table.convertColumnIndexToModel(vColIndex) != curCol) { if (col != null) { MageFrame.getInstance().getBalloonTip().setAttachedComponent(header); JLabel content = new JLabel(tips.get(table.convertColumnIndexToModel(vColIndex))); content.setFont(GUISizeHelper.tooltipFont); MageFrame.getInstance().getBalloonTip().setContents(content); ToolTipUtils.balloonToToolTip(MageFrame.getInstance().getBalloonTip(), 600, 10000); } else { MageFrame.getInstance().getBalloonTip().setTextContents(""); } curCol = table.convertColumnIndexToModel(vColIndex); } }