List of usage examples for javax.swing.table JTableHeader repaint
public void repaint()
From source file:finalproject.BloodGlucoseGUI.java
/** * Constructor//from w ww. ja v a 2 s .c om * Creates new form BloodGlucoseGUI */ // I would put most of it in initComponents if I could // edit that generated code. public BloodGlucoseGUI() { initComponents(); //jfc = new JFileChooser("Resources/Data"); // For "commercial" use //jfc = new JFileChooser("C:\\Program Files\\BGDataAnalysis\\Data"); jfc = new JFileChooser("C:\\BGDataAnalysis\\Data"); tabMod = new MyTableModel(); jTable2.setModel(tabMod); listMod = new DefaultListModel(); jList1.setModel(listMod); JTableHeader th = jTable2.getTableHeader(); TableColumnModel tcm = th.getColumnModel(); TableColumn tc = tcm.getColumn(0); tc.setHeaderValue("Time"); tc = tcm.getColumn(1); tc.setHeaderValue("Blood Glucose"); th.repaint(); notesTextArea.setLineWrap(true); notesTextArea.setWrapStyleWord(true); notesTextArea.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { e.consume(); ErrorGUIs.Popup pu = new ErrorGUIs.Popup(); pu.add("Please don't press the ENTER button!"); pu.display(); } } }); }
From source file:SortableTable.java
/** * When the user releases the mouse button, we attempt to sort the table. * * @param e the mouse event./*www .j a va2 s . c o m*/ */ public void mouseReleased(final MouseEvent e) { final JTableHeader header = (JTableHeader) e.getComponent(); if (header.getResizingColumn() == null) { // resizing takes precedence over sorting if (this.sortColumnIndex != -1) { final SortableTableModel model = (SortableTableModel) header.getTable().getModel(); final boolean ascending = !model.isAscending(); model.setAscending(ascending); model.sortByColumn(this.sortColumnIndex, ascending); this.renderer.setPressedColumn(-1); // clear header.repaint(); } } }
From source file:SortableTable.java
/** * Handle a mouse press event - if the user is NOT resizing a column and NOT dragging a column * then give visual feedback that the column header has been pressed. * * @param e the mouse event./* ww w. j a v a2s . c om*/ */ public void mousePressed(final MouseEvent e) { final JTableHeader header = (JTableHeader) e.getComponent(); if (header.getResizingColumn() == null) { // resizing takes precedence over sorting if (header.getDraggedDistance() < 1) { // dragging also takes precedence over sorting final int columnIndex = header.columnAtPoint(e.getPoint()); final int modelColumnIndex = header.getTable().convertColumnIndexToModel(columnIndex); if (this.model.isSortable(modelColumnIndex)) { this.sortColumnIndex = header.getTable().convertColumnIndexToModel(columnIndex); this.renderer.setPressedColumn(this.sortColumnIndex); header.repaint(); if (header.getTable().isEditing()) { header.getTable().getCellEditor().stopCellEditing(); } } else { this.sortColumnIndex = -1; } } } }