当前位置: 首页>>代码示例>>Java>>正文


Java JTree.repaint方法代码示例

本文整理汇总了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();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:RevertDeletedAction.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:CheckListener.java

示例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();
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:CheckListener.java

示例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();
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:CheckNodeListener.java

示例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();
        }
    } 
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:RevertDeletedAction.java


注:本文中的javax.swing.JTree.repaint方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。