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

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

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

JTree.<init>介绍

暂无

代码示例

代码示例来源:origin: skylot/jadx

tree = new JTree(treeModel);
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addMouseListener(new MouseAdapter() {
leftPane.add(new JScrollPane(tree), BorderLayout.CENTER);
leftPane.add(progressPane, BorderLayout.PAGE_END);
splitPane.setLeftComponent(leftPane);

代码示例来源:origin: SonarSource/sonarqube

frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(splitPane, BorderLayout.CENTER);
splitPane.setRightComponent(tabbedPane);
componentDetailsTab = new JScrollPane();
tabbedPane.addTab("Component details", null, componentDetailsTab, null);
componentDetailsTab.setViewportView(componentEditor);
sourceTab = new JScrollPane();
tabbedPane.addTab("Source", null, sourceTab, null);
sourceTab.setRowHeaderView(textLineNumber);
highlightingTab = new JScrollPane();
tabbedPane.addTab("Highlighting", null, highlightingTab, null);
splitPane.setLeftComponent(treeScrollPane);
componentTree = new JTree();
componentTree.setModel(new DefaultTreeModel(
 new DefaultMutableTreeNode("empty") {

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

gui.add(container, BorderLayout.CENTER);
container.add(tb, BorderLayout.NORTH);
for (int ii=0; ii<3; ii++) {
  tb.add(new JButton("Button"));
JTree tree = new JTree();
tree.setVisibleRowCount(6);
container.add(new JScrollPane(tree), BorderLayout.WEST);
container.add(new JTextArea(5,20), BorderLayout.CENTER);

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

public static void main(String[] args) {

  JScrollPane scroll = new JScrollPane(new JTree());
  scroll.setViewportBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));

  JFrame frame = new JFrame("Test");
  frame.add(scroll);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.pack();
  frame.setVisible(true);
}

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

add(checkBox, BorderLayout.WEST); 
    add(renderer, BorderLayout.CENTER);     
private JTree tree = new JTree();

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

Runnable r = new Runnable() {
 public void run() {
  final JFrame f = new JFrame("Test Screenshot");
  p.add( new JScrollPane(new JTree()),
   BorderLayout.WEST );
  p.add( new JScrollPane( new JTextArea(HELP,10,30) ),
   BorderLayout.CENTER );
  f.pack();
  f.setLocationRelativeTo(null);
  f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  f.setVisible(true);

代码示例来源:origin: pmd/pmd

private void init() {
  model.addViewerModelListener(this);
  setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), NLS.nls("AST.PANEL.TITLE")));
  setLayout(new BorderLayout());
  tree = new JTree((TreeNode) null);
  tree.addTreeSelectionListener(this);
  tree.addMouseListener(new MouseAdapter() {
    @Override
    public void mouseReleased(MouseEvent e) {
      if (e.isPopupTrigger()) {
        TreePath path = tree.getClosestPathForLocation(e.getX(), e.getY());
        tree.setSelectionPath(path);
        JPopupMenu menu = new ASTNodePopupMenu(model, (Node) path.getLastPathComponent());
        menu.show(tree, e.getX(), e.getY());
      }
    }
  });
  add(new JScrollPane(tree), BorderLayout.CENTER);
}

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

add(p);
    validate();
panel.add(output, BorderLayout.SOUTH);
JScrollPane tableScroll = new JScrollPane(table);
Dimension d = tableScroll.getPreferredSize();
d = new Dimension(450,d.height);
tableScroll.setPreferredSize(d);
panel.add( tableScroll, BorderLayout.CENTER );
tree = new JTree(treeModel);
tree.setRootVisible(false);
tree.getSelectionModel().setSelectionMode
panel.add(new JScrollPane(tree),BorderLayout.WEST);

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

public static void main(String[] args) {

  JTree tree = new JTree();
  tree.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

  JFrame frame = new JFrame("Test");
  frame.add(new JScrollPane(tree));
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.pack();
  frame.setVisible(true);
}

代码示例来源:origin: org.xworker/xworker_core

public static JTree create(ActionContext actionContext){
  //变量
  Thing self = (Thing) actionContext.get("self");
  Container parent = (Container) actionContext.get("parent");
  
  //创建
  JTree comp = new JTree();
  if(parent != null){
    parent.add(comp);
  }
  
  //初始化
  init(comp, self, null, actionContext);
  
  //创建子节点
  try{
    actionContext.push().put("parent", comp);
    for(Thing child : self.getChilds()){
      child.doAction("create", actionContext);
    }
  }finally{
    actionContext.pop();
  }
  
  //放置和返回变量
  actionContext.getScope(0).put(self.getMetadata().getName(), comp);
  return comp;
}

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

border = new EmptyBorder(0,0,0,0);
JTree tree = new JTree();
tree.setVisibleRowCount(10);
for (int ii = tree.getRowCount(); ii>-1; ii--) {
  tree.expandRow(ii);
gui.add(new JScrollPane(
    tree, 
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), 
    BorderLayout.LINE_START);
gui.add(new JScrollPane(new JTextArea(10,30)));
gui.add(buttonPanel, BorderLayout.PAGE_START);
buttonPanel.add(new JLabel("H Gap"));
  JFrame f = new JFrame("White (OK Red) Space");
  f.add(gui);
  f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
  f.setVisible(true);

代码示例来源:origin: stanfordnlp/CoreNLP

private FilePanel() {
 //data stuff
 FileTreeNode root = new FileTreeNode();
 treeModel = new FileTreeModel(root);
 tree = new JTree(treeModel);
 tree.setCellRenderer(new FileTreeCellRenderer());
 tree.setRootVisible(false);
 tree.setShowsRootHandles(true);
 tree.addMouseListener(new MouseAdapter() {
  @Override
  public void mouseClicked(MouseEvent e) {
   TreePath path = tree.getPathForLocation(e.getX(), e.getY());
   int nActiveTreebanks = getActiveTreebanks().size();
   //Tdiff
   boolean canActivate = (! TregexGUI.getInstance().isTdiffEnabled() || nActiveTreebanks < TregexGUI.MAX_TDIFF_TREEBANKS);
   if(path != null) {
    FileTreeNode node = (FileTreeNode) path.getLastPathComponent();
    if(canActivate || node.isActive())
     node.setActive(!node.isActive());
   }
  }
 });
 //layout/panel stuff
 this.setLayout(new BorderLayout());
 this.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(),"Tree files: "));
 JScrollPane scroller = new JScrollPane(tree);
 this.add(scroller, BorderLayout.CENTER);
}

代码示例来源:origin: sc.fiji/3D_Viewer

public static void showTree(final Node root) {
  final JTree tree = new JTree(new J3DNode(root, null));
  final JFrame parent = null;
  final JDialog dialog = new JDialog(parent, "Scenegraph");
  final JScrollPane scroll = new JScrollPane(tree);
  dialog.getContentPane().add(scroll);
  dialog.pack();
  dialog.setVisible(true);
}

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

JTree tree = new JTree();
tree.setEditable(true);
tree.setCellRenderer(new ButtonCellRenderer());
tree.setCellEditor(new ButtonCellEditor());
JFrame test = new JFrame();
test.add(new JScrollPane(tree));
test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
test.setSize(500, 500);
test.setLocationRelativeTo(null);

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

JTree tree = new JTree();
tree.setDragEnabled(true);
tree.setDropMode(DropMode.ON_OR_INSERT);
    TreeSelectionModel.CONTIGUOUS_TREE_SELECTION);
expandTree(tree);
return new JScrollPane(tree);
JFrame f = new JFrame();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.add(new TreeDragAndDrop().getContent());
f.setSize(400,400);
f.setLocation(200,200);
f.setVisible(true);

代码示例来源:origin: runelite/runelite

widgetTree = new JTree(new DefaultMutableTreeNode());
widgetTree.setRootVisible(false);
widgetTree.setShowsRootHandles(true);
final JScrollPane treeScrollPane = new JScrollPane(widgetTree);
treeScrollPane.setPreferredSize(new Dimension(200, 400));
final JScrollPane infoScrollPane = new JScrollPane(widgetInfo);
infoScrollPane.setPreferredSize(new Dimension(400, 400));

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

//<applet code='Apletas' width='600' height='400'></applet>
import java.awt.BorderLayout;
import javax.swing.*;
import javax.swing.border.EmptyBorder;

public class Apletas extends JApplet {

  private JTextField inputLine;

  public Apletas()
  {
    inputLine = new JTextField(20);

    JPanel mainGui = new JPanel(new BorderLayout(20,20));
    mainGui.setBorder(new EmptyBorder(80,80,80,80));

    mainGui.add(inputLine, BorderLayout.NORTH);

    mainGui.add(new JScrollPane(new JTextArea(20,10)), BorderLayout.CENTER);
    JTree tree = new JTree();
    tree.expandRow(2);
    mainGui.add(new JScrollPane(tree), BorderLayout.WEST);

    setContentPane(mainGui);
    validate();
  }
}

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

JFrame f=new JFrame("Disabling via JLayer");
final JLayer<JTree> layer = new JLayer<JTree>(new JTree(), new LayerUI<JTree>() {
 @Override
 public void eventDispatched(AWTEvent e, JLayer<? extends JTree> l) {
  if(e instanceof InputEvent) ((InputEvent)e).consume();
 }
 @Override
 public void paint(Graphics g, JComponent c) {
  super.paint(g, c);
  Graphics2D g2d = (Graphics2D) g.create();
  g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f));
  g2d.setColor(Color.BLACK);
  g2d.fillRect(0, 0, c.getWidth(), c.getHeight());
  g2d.dispose();
 }
});
f.setContentPane(layer);
layer.setLayerEventMask(~0);
f.pack();
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true);

代码示例来源:origin: geotools/geotools

/**
   * Display the given tree in a Swing frame. This is a convenience method for debugging purpose
   * only.
   *
   * @param tree The tree to display in a Swing frame.
   * @param title The frame title, or {@code null} if none.
   * @since 2.5
   */
  public static void show(final TreeModel tree, final String title) {
    final JFrame frame = new JFrame(title);
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    frame.add(new JScrollPane(new JTree(tree)));
    frame.pack();
    frame.setVisible(true);
  }
}

代码示例来源:origin: deathmarine/Luyten

tree = new JTree();
tree.setModel(new DefaultTreeModel(null));
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
panel2.setLayout(new BoxLayout(panel2, 1));
panel2.setBorder(BorderFactory.createTitledBorder("Structure"));
panel2.add(new JScrollPane(tree));

相关文章

JTree类方法