Java Code Examples for javax.swing.JTree#repaint()
The following examples show how to use
javax.swing.JTree#repaint() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CheckListener.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void keyPressed(KeyEvent e) { if (e.getKeyChar() == ' ') { // NOI18N JTree tree = (JTree) e.getSource(); TreePath path = tree.getSelectionPath(); if (path == null) { return; } Node node = Visualizer.findNode(path.getLastPathComponent()); if (node == null) { return; } boolean isSelected = model.isNodeSelected(node); model.setNodeSelected(node, !isSelected); tree.repaint(); e.consume(); } }
Example 2
Source File: CheckListener.java From netbeans with Apache License 2.0 | 6 votes |
public void keyPressed(KeyEvent e) { if (e.getKeyChar() == ' ') { JTree tree = (JTree) e.getSource(); TreePath path = tree.getSelectionPath(); if( null == path ) return; Node node = Visualizer.findNode( path.getLastPathComponent() ); if( null == node ) return; boolean isSelected = settings.isNodeVisible( node ); settings.setNodeVisible( node, !isSelected ); tree.repaint(); e.consume(); } }
Example 3
Source File: RevertDeletedAction.java From netbeans with Apache License 2.0 | 6 votes |
@Override public void mouseClicked(MouseEvent e) { JTree tree = (JTree) e.getSource(); Point p = e.getPoint(); int row = tree.getRowForLocation(e.getX(), e.getY()); TreePath path = tree.getPathForRow(row); // if path exists and mouse is clicked exactly once if (path != null) { FileNode node = (FileNode) path.getLastPathComponent(); Rectangle chRect = DeletedListRenderer.getCheckBoxRectangle(); Rectangle rowRect = tree.getPathBounds(path); chRect.setLocation(chRect.x + rowRect.x, chRect.y + rowRect.y); if (e.getClickCount() == 1 && chRect.contains(p)) { boolean isSelected = !(node.isSelected()); node.setSelected(isSelected); ((DefaultTreeModel) tree.getModel()).nodeChanged(node); if (row == 0) { tree.revalidate(); } tree.repaint(); } } }
Example 4
Source File: CheckNodeListener.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void keyPressed(KeyEvent e) { if (e.getKeyChar() == ' ') { JTree tree = (JTree) e.getSource(); TreePath path = tree.getSelectionPath(); if (path != null) { CheckNode node = (CheckNode) path.getLastPathComponent(); node.setSelected(!node.isSelected()); tree.repaint(); e.consume(); } } }
Example 5
Source File: CheckListener.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void mouseClicked(MouseEvent e) { // todo (#pf): we need to solve problem between click and double // click - click should be possible only on the check box area // and double click should be bordered by title text. // we need a test how to detect where the mouse pointer is JTree tree = (JTree) e.getSource(); Point p = e.getPoint(); int x = e.getX(); int y = e.getY(); int row = tree.getRowForLocation(x, y); TreePath path = tree.getPathForRow(row); // if path exists and mouse is clicked exactly once if (path == null) { return; } Node node = Visualizer.findNode(path.getLastPathComponent()); if (node == null) { return; } Rectangle chRect = CheckRenderer.getCheckBoxRectangle(); Rectangle rowRect = tree.getPathBounds(path); chRect.setLocation(chRect.x + rowRect.x, chRect.y + rowRect.y); if (e.getClickCount() == 1 && chRect.contains(p)) { boolean isSelected = model.isNodeSelected(node); model.setNodeSelected(node, !isSelected); tree.repaint(); } }
Example 6
Source File: CheckListener.java From netbeans with Apache License 2.0 | 5 votes |
public void mouseClicked(MouseEvent e) { // todo (#pf): we need to solve problem between click and double // click - click should be possible only on the check box area // and double click should be bordered by title text. // we need a test how to detect where the mouse pointer is JTree tree = (JTree) e.getSource(); Point p = e.getPoint(); int x = e.getX(); int y = e.getY(); int row = tree.getRowForLocation(x, y); TreePath path = tree.getPathForRow(row); // if path exists and mouse is clicked exactly once if( null == path ) return; Node node = Visualizer.findNode( path.getLastPathComponent() ); if( null == node ) return; Rectangle chRect = CheckRenderer.getCheckBoxRectangle(); Rectangle rowRect = tree.getPathBounds(path); chRect.setLocation(chRect.x + rowRect.x, chRect.y + rowRect.y); if (e.getClickCount() == 1 && chRect.contains(p)) { boolean isSelected = settings.isNodeVisible( node ); settings.setNodeVisible( node, !isSelected ); tree.repaint(); } }
Example 7
Source File: RevertDeletedAction.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void keyPressed(KeyEvent e) { int keyCode = e.getKeyCode(); if (keyCode == KeyEvent.VK_SPACE) { JTree tree = (JTree) e.getSource(); TreePath path = tree.getSelectionPath(); if (path != null) { FileNode node = (FileNode) path.getLastPathComponent(); node.setSelected(!node.isSelected()); tree.repaint(); e.consume(); } } }