List of usage examples for javax.swing.tree TreeSelectionModel SINGLE_TREE_SELECTION
int SINGLE_TREE_SELECTION
To view the source code for javax.swing.tree TreeSelectionModel SINGLE_TREE_SELECTION.
Click Source Link
From source file:wsattacker.plugin.intelligentdos.ui.dialog.Result_NB.java
/** * Creates new form Result_NB/*w w w . j ava 2s. co m*/ * * @param title * @param attacks */ public Result_NB(String title, ResultModel resultModel) { super(title); this.attacks = resultModel.getAttacks(); btnController = new ResultButtonController(resultModel); chart = ChartHelper.createDumyChart(); initComponents(); resultTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); }
From source file:components.TreeDemo.java
public TreeDemo() { super(new GridLayout(1, 0)); //Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);//from www . ja va 2 s.c o m //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); //Listen for when the selection changes. tree.addTreeSelectionListener(this); if (playWithLineStyle) { System.out.println("line style = " + lineStyle); tree.putClientProperty("JTree.lineStyle", lineStyle); } //Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); //Create the HTML viewing pane. htmlPane = new JEditorPane(); htmlPane.setEditable(false); initHelp(); JScrollPane htmlView = new JScrollPane(htmlPane); //Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(htmlView); Dimension minimumSize = new Dimension(100, 50); htmlView.setMinimumSize(minimumSize); treeView.setMinimumSize(minimumSize); splitPane.setDividerLocation(100); splitPane.setPreferredSize(new Dimension(500, 300)); //Add the split pane to this panel. add(splitPane); }
From source file:Main.java
public DynamicTree() { super(new GridLayout(1, 0)); treeModel.addTreeModelListener(new MyTreeModelListener()); tree = new JTree(treeModel); tree.setEditable(true);/*from w ww . ja v a 2s .c o m*/ tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setShowsRootHandles(true); JScrollPane scrollPane = new JScrollPane(tree); add(scrollPane); }
From source file:TreeIconDemo2.java
public TreeIconDemo2() { super(new GridLayout(1, 0)); //Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);/*w w w .j a v a2 s . c o m*/ //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); //Enable tool tips. ToolTipManager.sharedInstance().registerComponent(tree); //Set the icon for leaf nodes. ImageIcon tutorialIcon = createImageIcon("images/middle.gif"); if (tutorialIcon != null) { tree.setCellRenderer(new MyRenderer(tutorialIcon)); } else { System.err.println("Tutorial icon missing; using default."); } //Listen for when the selection changes. tree.addTreeSelectionListener(this); //Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); //Create the HTML viewing pane. htmlPane = new JEditorPane(); htmlPane.setEditable(false); initHelp(); JScrollPane htmlView = new JScrollPane(htmlPane); //Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(htmlView); Dimension minimumSize = new Dimension(100, 50); htmlView.setMinimumSize(minimumSize); treeView.setMinimumSize(minimumSize); splitPane.setDividerLocation(100); //XXX: ignored in some releases //of Swing. bug 4101306 //workaround for bug 4101306: //treeView.setPreferredSize(new Dimension(100, 100)); splitPane.setPreferredSize(new Dimension(500, 300)); //Add the split pane to this panel. add(splitPane); }
From source file:TreeDemo.java
public TreeDemo() { super(new GridLayout(1, 0)); //Create the nodes. DefaultMutableTreeNode top = new DefaultMutableTreeNode("The Java Series"); createNodes(top);/*from ww w. j a v a2s . c o m*/ //Create a tree that allows one selection at a time. tree = new JTree(top); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); //Listen for when the selection changes. tree.addTreeSelectionListener(this); if (playWithLineStyle) { System.out.println("line style = " + lineStyle); tree.putClientProperty("JTree.lineStyle", lineStyle); } //Create the scroll pane and add the tree to it. JScrollPane treeView = new JScrollPane(tree); //Create the HTML viewing pane. htmlPane = new JEditorPane(); htmlPane.setEditable(false); initHelp(); JScrollPane htmlView = new JScrollPane(htmlPane); //Add the scroll panes to a split pane. JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT); splitPane.setTopComponent(treeView); splitPane.setBottomComponent(htmlView); Dimension minimumSize = new Dimension(100, 50); htmlView.setMinimumSize(minimumSize); treeView.setMinimumSize(minimumSize); splitPane.setDividerLocation(100); //XXX: ignored in some releases //of Swing. bug 4101306 //workaround for bug 4101306: //treeView.setPreferredSize(new Dimension(100, 100)); splitPane.setPreferredSize(new Dimension(500, 300)); //Add the split pane to this panel. add(splitPane); }
From source file:ClassTree.java
public ClassTreeFrame() { setTitle("ClassTree"); setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT); // the root of the class tree is Object root = new DefaultMutableTreeNode(java.lang.Object.class); model = new DefaultTreeModel(root); tree = new JTree(model); // add this class to populate the tree with some data addClass(getClass());//from w w w . ja v a 2s . c om // set up node icons ClassNameTreeCellRenderer renderer = new ClassNameTreeCellRenderer(); renderer.setClosedIcon(new ImageIcon("red-ball.gif")); renderer.setOpenIcon(new ImageIcon("yellow-ball.gif")); renderer.setLeafIcon(new ImageIcon("blue-ball.gif")); tree.setCellRenderer(renderer); // set up selection mode tree.addTreeSelectionListener(new TreeSelectionListener() { public void valueChanged(TreeSelectionEvent event) { // the user selected a different node--update description TreePath path = tree.getSelectionPath(); if (path == null) return; DefaultMutableTreeNode selectedNode = (DefaultMutableTreeNode) path.getLastPathComponent(); Class<?> c = (Class<?>) selectedNode.getUserObject(); String description = getFieldDescription(c); textArea.setText(description); } }); int mode = TreeSelectionModel.SINGLE_TREE_SELECTION; tree.getSelectionModel().setSelectionMode(mode); // this text area holds the class description textArea = new JTextArea(); // add tree and text area JPanel panel = new JPanel(); panel.setLayout(new GridLayout(1, 2)); panel.add(new JScrollPane(tree)); panel.add(new JScrollPane(textArea)); add(panel, BorderLayout.CENTER); addTextField(); }
From source file:ru.develgame.jflickrorganizer.MainForm.java
@PostConstruct public void init() { jTablePhotos.setModel(tablePhotosDataModel); jTablePhotos.setRowHeight(COLUMN_PIC_MIN_HEIGHT); if (authorizer.getUser().getSyncFolder() != null) jTextFieldBackupFolder.setText(authorizer.getUser().getSyncFolder()); jTablePhotos.getTableHeader().setReorderingAllowed(false); jScrollPane2.getViewport().setBackground(jTablePhotos.getBackground()); jTreeAlbums.setModel(treeAlbumsDataModel); jTreeAlbums.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jTreeAlbums.setCellRenderer(new AlbumTreeCellRender(jTreeAlbums.getCellRenderer())); jTreeAlbums.setSelectionRow(0);//from ww w . j ava 2 s . c o m albumFilter = new AlbumFilter(null); listFilters.addCondition(albumFilter); jTreeAlbums.addTreeSelectionListener(e -> { Album selectedAlbum = ((TreeAlbumsDataModel.AlbumNode) jTreeAlbums.getLastSelectedPathComponent()) .getAlbum(); AlbumFilter newAlbumFilter = new AlbumFilter(selectedAlbum); listFilters.replaceFilter(albumFilter, newAlbumFilter); albumFilter = newAlbumFilter; tablePhotosDataModel.loadData(); // TODO - updateStatusBar }); jComboBoxVisibility.setModel(visibilityComboBoxDataModel); visibilityFilter = new VisibilityFilter((WrapperVisibility) jComboBoxVisibility.getSelectedItem()); listFilters.addCondition(visibilityFilter); jComboBoxVisibility.addItemListener(e -> { if (e.getStateChange() == ItemEvent.SELECTED) { VisibilityFilter newVisibilityFilter = new VisibilityFilter( (WrapperVisibility) jComboBoxVisibility.getSelectedItem()); listFilters.replaceFilter(visibilityFilter, newVisibilityFilter); visibilityFilter = newVisibilityFilter; tablePhotosDataModel.loadData(); } }); updateStatusBar(); tablePhotosDataModel.addTableModelListener(e -> { updateStatusBar(); }); DateTableCellRenderer dateTableCellRenderer = new DateTableCellRenderer(); jTablePhotos.getColumnModel().getColumn(COLUMN_DATE_TAKEN).setCellRenderer(dateTableCellRenderer); jTablePhotos.getColumnModel().getColumn(COLUMN_DATE_UPLOADED).setCellRenderer(dateTableCellRenderer); jButtonChooseBackupFolder.setEnabled(!authorizer.isOfflineMode()); jButtonBackup.setEnabled(!authorizer.isOfflineMode()); jTextFieldBackupFolder.setEnabled(!authorizer.isOfflineMode()); jLabelBackupFolder.setEnabled(!authorizer.isOfflineMode()); }
From source file:com.haulmont.cuba.desktop.gui.components.DesktopTree.java
public DesktopTree() { layout = new MigLayout("flowy, fill, insets 0", "", "[min!][fill]"); panel = new JPanel(layout); topPanel = new JPanel(new BorderLayout()); topPanel.setVisible(false);/*from w ww . java2s . c o m*/ panel.add(topPanel, "growx"); impl = new JTree(); treeView = new JScrollPane(impl); panel.add(treeView, "grow"); impl.setRootVisible(false); impl.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); impl.setExpandsSelectedPaths(true); impl.addMouseListener(new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { showPopup(e); } @Override public void mouseReleased(MouseEvent e) { showPopup(e); } private void showPopup(MouseEvent e) { if (e.isPopupTrigger()) { // select row Point p = e.getPoint(); TreePath treePath = impl.getPathForLocation(p.x, p.y); if (treePath != null) { TreeSelectionModel model = impl.getSelectionModel(); model.setSelectionPath(treePath); } // show popup menu createPopupMenu().show(e.getComponent(), e.getX(), e.getY()); } } }); impl.addKeyListener(new KeyAdapter() { protected static final int ENTER_CODE = 10; @Override public void keyPressed(KeyEvent e) { if (ENTER_CODE == e.getKeyCode() && e.getComponent() == DesktopTree.this.getComponent()) { if (enterPressAction != null) { enterPressAction.actionPerform(DesktopTree.this); } else { handleClickAction(); } } } }); }
From source file:ListAlgorithmsBC.java
private ListAlgorithmsBC() { super("JCE Algorithms"); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); DefaultMutableTreeNode root = new DefaultMutableTreeNode("Providers"); DefaultTreeModel treeModel = new DefaultTreeModel(root); for (Provider provider : java.security.Security.getProviders()) { DefaultMutableTreeNode providerNode = new DefaultMutableTreeNode(provider); root.add(providerNode);//from ww w.j a va 2 s.c om Set<Provider.Service> used = new HashSet<Provider.Service>(); getNodes(providerNode, provider, used, "Cipher", "cipher"); getNodes(providerNode, provider, used, "Key Agreement", "keyagreement"); getNodes(providerNode, provider, used, "Key Generator", "keygenerator"); getNodes(providerNode, provider, used, "Key Pair Generator", "keypairgenerator"); getNodes(providerNode, provider, used, "Key Factory", "keyfactory"); getNodes(providerNode, provider, used, "Secret Key Factory", "secretkeyfactory"); getNodes(providerNode, provider, used, "Mac", "mac"); getNodes(providerNode, provider, used, "Message Digest", "messagedigest"); getNodes(providerNode, provider, used, "Signature", "signature"); getNodes(providerNode, provider, used, "Algorithm Paramater", "algorithmparameters"); getNodes(providerNode, provider, used, "Algorithm Paramater Generator", "algorithmparametergenerator"); getNodes(providerNode, provider, used, "Key Store", "keystore"); getNodes(providerNode, provider, used, "Secure Random", "securerandom"); getNodes(providerNode, provider, used, "Certificate Factory", "certificatefactory"); getNodes(providerNode, provider, used, "Certificate Store", "certstore"); getNodes(providerNode, provider, used, "Key Manager Factory", "KeyManagerFactory"); getNodes(providerNode, provider, used, "Trust Manager Factory", "TrustManagerFactory"); getNodes(providerNode, provider, used, "SSL Context", "SSLContext"); getNodes(providerNode, provider, used, "Sasl Server Factory", "SaslServerFactory"); getNodes(providerNode, provider, used, "Sasl Client Factory", "SaslClientFactory"); { DefaultMutableTreeNode node = new DefaultMutableTreeNode("Other"); for (Provider.Service service : provider.getServices()) { if (!used.contains(service)) { DefaultMutableTreeNode serviceNode = new DefaultMutableTreeNode( service.getType() + " : " + service.getAlgorithm()); node.add(serviceNode); serviceNode.add(new DefaultMutableTreeNode("class : " + service.getClassName())); } } if (node.getChildCount() != 0) providerNode.add(node); } } JTree tree = new JTree(treeModel); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.setEditable(false); JScrollPane pane = new JScrollPane(tree); pane.setPreferredSize(new Dimension(200, 200)); getContentPane().add(pane); pack(); }
From source file:edu.ku.brc.specify.config.DebugLoggerDialog.java
@Override public void createUI() { super.createUI(); configureLoggers();// w w w . j a v a 2 s. c om root = new LoggerNode(null, "Root"); for (String loggerName : sortedNames) { buildTree(loggers.get(loggerName), root, StringUtils.split(loggerName, '.'), 0); } JTree tree = new JTree(root); tree.setCellRenderer(new CheckRenderer()); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); tree.putClientProperty("JTree.lineStyle", "Angled"); tree.addMouseListener(new NodeSelectionListener(tree)); contentPanel = new JScrollPane(tree); mainPanel.add(contentPanel, BorderLayout.CENTER); setSize(500, 500); }