javax.swing.JTree.setVisible()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(3.9k)|赞(0)|评价(0)|浏览(135)

本文整理了Java中javax.swing.JTree.setVisible()方法的一些代码示例,展示了JTree.setVisible()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTree.setVisible()方法的具体详情如下:
包路径:javax.swing.JTree
类名称:JTree
方法名:setVisible

JTree.setVisible介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

public static void main( String[] args ) {
 EventQueue.invokeLater( new Runnable() {
  @Override
  public void run() {
   JFrame frame = new JFrame();
   DefaultMutableTreeNode myComputer = new DefaultMutableTreeNode("My Computer");
   DefaultMutableTreeNode c = new DefaultMutableTreeNode("Local Disk(C:)");
   DefaultMutableTreeNode vinod = new DefaultMutableTreeNode("Vinod");
   DefaultMutableTreeNode swing = new DefaultMutableTreeNode("Swing");
   DefaultMutableTreeNode tr = new DefaultMutableTreeNode("Tree");
   DefaultMutableTreeNode a = new DefaultMutableTreeNode("3½ Floppy(A:)");
   DefaultMutableTreeNode e = new DefaultMutableTreeNode("New Volume(E:)");
   c.add(vinod);
   vinod.add(swing);
   swing.add(tr);
   myComputer.add(c);
   myComputer.add(a);
   myComputer.add(e);
   JTree tree = new JTree(myComputer);
   JScrollPane scrollPane = new JScrollPane(tree);
   frame.getContentPane().add(scrollPane);
   tree.setVisible(true);
   frame.setDefaultCloseOperation( WindowConstants.EXIT_ON_CLOSE );
   frame.pack();
   frame.setVisible( true );
  }
 } );
}

代码示例来源:origin: stackoverflow.com

JTree tree;
JScrollPane scrollPane;
DefaultMutableTreeNode root = new DefaultMutableTreeNode("RootNode");

public Tree()
{
  setVisible(true);
  setSize(100, 300);
  createChildNodes(root);
  tree = new JTree(root);
  tree.setVisible(true);
  tree.setSize(100, 300);
  scrollPane = new JScrollPane(tree);
  scrollPane.add(tree);
  scrollPane.setVisible(true);
  scrollPane.setSize(100, 300);
  scrollPane.setViewportView(this);
  scrollPane.setBackground(Color.red);
}

代码示例来源:origin: zolyfarkas/spf4j

measurementTree.setVisible(true);
this.startDate.setValue(new Date(startDateMillis));

代码示例来源:origin: zolyfarkas/spf4j

measurementTree.setVisible(true);
this.startDate.setValue(new Date(startDateMillis));

代码示例来源:origin: org.zaproxy/zap

public SiteNode showDialog(SiteNode defaultNode) {
  // Assume Contexts cant be selected
  this.getTreeContext().setVisible(false);
  SiteNode siteRoot = (SiteNode)Model.getSingleton().getSession().getSiteTree().getRoot();
  populateNode(siteRoot, (SiteNode)this.siteTree.getRoot(), defaultNode);
  if (selectedSiteNode != null) {
    // Found the default node, select it
    TreePath path = new TreePath(this.siteTree.getPathToRoot(selectedSiteNode));
    this.getTreeSite().setExpandsSelectedPaths(true);
    this.getTreeSite().setSelectionPath(path);
    this.getTreeSite().scrollPathToVisible(path);
    this.getTreeSite().expandPath(path);
  } else {
    // no default path, just expand the top level
    TreePath path = new TreePath(this.siteTree.getPathToRoot((TreeNode)this.siteTree.getRoot()));
    this.getTreeSite().expandPath(path);
  }
  this.setVisible(true);
  // The dialog is modal so this wont return until the dialog visibility is unset
  return selectedSiteNode;
}

代码示例来源:origin: org.zaproxy/zap

public Target showDialog(Target defaultTarget) {
  // Assume Contexts can be selected
  this.getTreeContext().setVisible(true);
  SiteNode siteRoot = (SiteNode)Model.getSingleton().getSession().getSiteTree().getRoot();
  populateContexts((SiteNode)this.contextTree.getRoot());
  if (defaultTarget != null) {
    populateNode(siteRoot, (SiteNode)this.siteTree.getRoot(), defaultTarget.getStartNode());
  } else { 
    populateNode(siteRoot, (SiteNode)this.siteTree.getRoot(), null);
  }
  if (selectedSiteNode != null) {
    // Found the default node, select it
    TreePath path = new TreePath(this.siteTree.getPathToRoot(selectedSiteNode));
    this.getTreeSite().setExpandsSelectedPaths(true);
    this.getTreeSite().setSelectionPath(path);
    this.getTreeSite().scrollPathToVisible(path);
    this.getTreeSite().expandPath(path);
  } else {
    // no default path, just expand the top level
    TreePath path = new TreePath(this.siteTree.getPathToRoot((TreeNode)this.siteTree.getRoot()));
    this.getTreeSite().expandPath(path);
  }
  this.setVisible(true);
  // The dialog is modal so this wont return until the dialog visibility is unset
  if (selectedSiteNode != null) {
    return new Target(selectedSiteNode);
  }
  return selectedTarget;
}

相关文章

JTree类方法