本文整理汇总了Java中javax.swing.JTree.repaint方法的典型用法代码示例。如果您正苦于以下问题:Java JTree.repaint方法的具体用法?Java JTree.repaint怎么用?Java JTree.repaint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JTree
的用法示例。
在下文中一共展示了JTree.repaint方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mouseClicked
import javax.swing.JTree; //导入方法依赖的package包/类
@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();
}
}
}
示例2: keyPressed
import javax.swing.JTree; //导入方法依赖的package包/类
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();
}
}
示例3: mouseClicked
import javax.swing.JTree; //导入方法依赖的package包/类
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();
}
}
示例4: keyPressed
import javax.swing.JTree; //导入方法依赖的package包/类
@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();
}
}
}
示例5: keyPressed
import javax.swing.JTree; //导入方法依赖的package包/类
@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();
}
}
}