List of usage examples for javax.swing.tree DefaultTreeModel DefaultTreeModel
@ConstructorProperties({ "root" }) public DefaultTreeModel(TreeNode root)
From source file:dataviewer.DataViewer.java
private void fill_tree() { txt_count.setText(""); DefaultTreeModel tm = (DefaultTreeModel) tr_files.getModel(); DefaultMutableTreeNode top;//ww w.j a va 2 s . c om cur_path = new File(cur_path).getAbsolutePath(); if (cur_path.charAt(cur_path.length() - 1) == '.') { cur_path = cur_path.substring(0, cur_path.length() - 1); } if (cur_path.charAt(cur_path.length() - 1) == File.separatorChar) { cur_path = cur_path.substring(0, cur_path.length() - 1); } if (tm != null) { top = (DefaultMutableTreeNode) tm.getRoot(); top.removeAllChildren(); top.setUserObject(cur_path); } else { top = new DefaultMutableTreeNode(cur_path); } // get all children nodes and remove them // rename the user object ArrayList<String> files = this.getAllFileNames(cur_path); Collections.sort(files); int j = 1; int selected_index = -1; for (String f : files) { String ex = this.getExtension(f); boolean is_folder = (new File(cur_path + File.separator + f)).isDirectory(); if (is_folder || ex.equals(".txt") || ex.equals(".dat") || ex.equals(".csv") || ex.equals(".tsv")) { DefaultMutableTreeNode node = new DefaultMutableTreeNode(f); top.add(node); if (f.equals(selected_file)) { selected_index = j; } j++; } } //DefaultTreeModel treeModel = new DefaultTreeModel(top); //tr_files.setModel(treeModel); if (tm == null) { tr_files.setModel(new DefaultTreeModel(top)); } else { try { tm.reload(); } catch (Exception e) { tm.reload(); } } if (selected_index > -1) { tr_files.setSelectionRow(selected_index); } tr_files.grabFocus(); }
From source file:com.pironet.tda.TDA.java
protected void createTree() { //Create a tree that allows multiple selection at a time. if (topNodes.size() == 1) { treeModel = new DefaultTreeModel((DefaultMutableTreeNode) topNodes.get(0)); tree = new JTree(treeModel); tree.setRootVisible(!runningAsJConsolePlugin && !runningAsVisualVMPlugin); addTreeListener(tree);/* w w w. j av a2s . c om*/ if (!runningAsJConsolePlugin && !runningAsVisualVMPlugin) { frame.setTitle("TDA - Thread Dumps of " + dumpFile); } } else { DefaultMutableTreeNode root = new DefaultMutableTreeNode("Thread Dump Nodes"); treeModel = new DefaultTreeModel(root); for (Object topNode : topNodes) { root.add((DefaultMutableTreeNode) topNode); } tree = new JTree(root); tree.setRootVisible(false); addTreeListener(tree); if (!runningAsJConsolePlugin && !runningAsVisualVMPlugin) { if (!frame.getTitle().endsWith("...")) { frame.setTitle(frame.getTitle() + " ..."); } } } tree.setShowsRootHandles(true); tree.getSelectionModel().setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION); tree.setCellRenderer(new TreeRenderer()); //Create the scroll pane and add the tree to it. ViewScrollPane treeView = new ViewScrollPane(tree, runningAsVisualVMPlugin); topSplitPane.setLeftComponent(treeView); Dimension minimumSize = new Dimension(200, 50); treeView.setMinimumSize(minimumSize); //Listen for when the selection changes. tree.addTreeSelectionListener(this); if (!runningAsJConsolePlugin && !runningAsVisualVMPlugin) { dt = new DropTarget(tree, new FileDropTargetListener()); } createPopupMenu(); }
From source file:edu.harvard.i2b2.previousquery.ui.PreviousQueryPanel.java
/** * This method is called from within the constructor to initialize the form. *///from w ww. j av a 2 s . com private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; System.setProperty("PQSortByTimeCheckBox", "true"); System.setProperty("QueryToolMaxQueryNumber", "20"); System.setProperty("PQMaxPatientsNumber", "200"); System.setProperty("PQSortByNameCheckBox", "false"); jPanel1 = new javax.swing.JPanel(); jContainComboBox = new javax.swing.JComboBox(); jCategoryComboBox = new javax.swing.JComboBox(); jSearchStringTextField = new javax.swing.JTextField(); jFindButton = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTree1 = new javax.swing.JTree(); jPanel2 = new javax.swing.JPanel(); jStartTimeTextField = new javax.swing.JTextField(); jBackwardButton = new javax.swing.JButton(); jForwardButton = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); //setLayout(new java.awt.BorderLayout()); setLayout(new java.awt.BorderLayout(20, 4)); jPanel1.setLayout(new java.awt.GridBagLayout()); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Search By Name")); jPanel1.setMinimumSize(new java.awt.Dimension(0, 50)); jPanel1.setPreferredSize(new java.awt.Dimension(400, 80)); jContainComboBox.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "Containing", "Start With", "End With", "Exact" })); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridBagConstraints.gridheight = 2; gridBagConstraints.ipadx = 32; gridBagConstraints.ipady = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.01; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 2); jPanel1.add(jContainComboBox, gridBagConstraints); jCategoryComboBox.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "Any Category", "Previous Query", "Previous Query Result", "Patient" })); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.ipadx = 14; gridBagConstraints.ipady = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.6; gridBagConstraints.insets = new java.awt.Insets(4, 2, 0, 2); jPanel1.add(jCategoryComboBox, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 11; gridBagConstraints.ipady = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.9; gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2); jPanel1.add(jSearchStringTextField, gridBagConstraints); jFindButton.setText("Find"); jFindButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jFindButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridBagConstraints.gridheight = 2; gridBagConstraints.ipadx = 19; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.01; gridBagConstraints.insets = new java.awt.Insets(4, 4, 2, 2); jPanel1.add(jFindButton, gridBagConstraints); add(jPanel1, java.awt.BorderLayout.NORTH); QueryMasterData tmpData = new QueryMasterData(); tmpData.name("Queries by " + UserInfoBean.getInstance().getUserName()); tmpData.tooltip("Previous query runs"); tmpData.visualAttribute("CA"); top = new DefaultMutableTreeNode(tmpData); // top = new DefaultMutableTreeNode("Root Node"); treeModel = new DefaultTreeModel(top); // treeModel.addTreeModelListener(new MyTreeModelListener()); jTree1 = new JTree(treeModel); jTree1.setEditable(false); // jTree1.getSelectionModel().setSelectionMode // (TreeSelectionModel.SINGLE_TREE_SELECTION); jTree1.setShowsRootHandles(true); // JScrollPane treeView = new JScrollPane(jTree1); jTree1.setRootVisible(false); jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jTree1.setCellRenderer(new MyRenderer()); ToolTipManager.sharedInstance().registerComponent(jTree1); if (cellStatus.equalsIgnoreCase("CellDown")) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode("Data Repository Cell is unavailable"); treeModel.insertNodeInto(childNode, top, top.getChildCount()); // Make sure the user can see the lovely new node. jTree1.expandPath(new TreePath(top.getPath())); } ArrayList<QueryMasterData> queries = previousQueries; if (queries != null) { for (int i = 0; i < queries.size(); i++) { addNode(queries.get(i)); } } jScrollPane1.setViewportView(jTree1); add(jScrollPane1, java.awt.BorderLayout.CENTER); jTree1.setTransferHandler(new NodeCopyTransferHandler()); jTree1.addTreeExpansionListener(this); jTree1.addTreeWillExpandListener(this); jPanel2.setLayout(new java.awt.GridBagLayout()); jPanel2.setMinimumSize(new java.awt.Dimension(92, 20)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 244; gridBagConstraints.ipady = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.9; gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0); jPanel2.add(jStartTimeTextField, gridBagConstraints); jBackwardButton.setText("<"); jBackwardButton.setMaximumSize(new java.awt.Dimension(43, 22)); jBackwardButton.setMinimumSize(new java.awt.Dimension(43, 22)); jBackwardButton.setPreferredSize(new java.awt.Dimension(43, 22)); jBackwardButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBackwardButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.01; gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 2); jPanel2.add(jBackwardButton, gridBagConstraints); jForwardButton.setText(">"); jForwardButton.setMaximumSize(new java.awt.Dimension(43, 22)); jForwardButton.setMinimumSize(new java.awt.Dimension(43, 22)); jForwardButton.setPreferredSize(new java.awt.Dimension(43, 22)); jForwardButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jForwardButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 3; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.01; gridBagConstraints.insets = new java.awt.Insets(0, 43, 0, 3); jPanel2.add(jForwardButton, gridBagConstraints); jLabel2.setText("Begin:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.01; gridBagConstraints.insets = new java.awt.Insets(3, 7, 0, 2); jPanel2.add(jLabel2, gridBagConstraints); add(jPanel2, java.awt.BorderLayout.SOUTH); }
From source file:net.sf.jabref.groups.GroupSelector.java
private void setGroups(GroupTreeNode groupsRoot) { groupsTree.setModel(groupsTreeModel = new DefaultTreeModel(groupsRoot)); this.groupsRoot = groupsRoot; if (Globals.prefs.getBoolean(JabRefPreferences.GROUP_EXPAND_TREE)) { groupsTree.expandSubtree(groupsRoot); }//from ww w . j av a2s . c om }
From source file:net.sf.jabref.gui.FindUnlinkedFilesDialog.java
/** * Creates the tree view, that holds the data structure. <br> * <br>//from ww w. java2 s . c om * Initially, the root node is <b>not</b> visible, so that the tree appears empty at the beginning. */ private void createTree() { /** * Mouse listener to listen for mouse events on the tree. <br> * This will mark the selected tree entry as "selected" or "unselected", * which will cause this nodes checkbox to appear as either "checked" or * "unchecked". */ treeMouseListener = new MouseAdapter() { @Override public void mousePressed(MouseEvent e) { int x = e.getX(); int y = e.getY(); int row = tree.getRowForLocation(x, y); TreePath path = tree.getPathForRow(row); if (path != null) { CheckableTreeNode node = (CheckableTreeNode) path.getLastPathComponent(); if (e.getClickCount() == 2) { Object userObject = node.getUserObject(); if ((userObject instanceof FileNodeWrapper) && node.isLeaf()) { FileNodeWrapper fnw = (FileNodeWrapper) userObject; try { JabRefDesktop.openExternalViewer( JabRefGUI.getMainFrame().getCurrentBasePanel().getBibDatabaseContext(), fnw.file.getAbsolutePath(), "pdf"); } catch (IOException e1) { LOGGER.info("Error opening file", e1); } } } else { node.check(); tree.invalidate(); tree.repaint(); } } } }; CheckableTreeNode startNode = new CheckableTreeNode("ROOT"); DefaultTreeModel model = new DefaultTreeModel(startNode); tree.setModel(model); tree.setRootVisible(false); DefaultTreeCellRenderer renderer = new CheckboxTreeCellRenderer(); tree.setCellRenderer(renderer); tree.addMouseListener(treeMouseListener); }
From source file:eu.crisis_economics.abm.dashboard.GASearchHandler.java
public void addParameter(final ParameterOrGene parameterOrGene) throws ModelInformationException { if (chromosomeTree == null) { chromosomeTree = new DefaultTreeModel(new DefaultMutableTreeNode()); genes = null;// w w w .j a v a 2 s . co m } final DefaultMutableTreeNode newNode = new DefaultMutableTreeNode(parameterOrGene); final DefaultMutableTreeNode root = (DefaultMutableTreeNode) chromosomeTree.getRoot(); chromosomeTree.insertNodeInto(newNode, root, root.getChildCount()); if (parameterOrGene.info instanceof SubmodelInfo) { final SubmodelInfo ssInfo = (SubmodelInfo) parameterOrGene.info; if (ssInfo.getActualType() != null) addSubmodelParameter(ssInfo, newNode); } for (final ModelListener listener : listeners) listener.parameterAdded(); }
From source file:edu.harvard.i2b2.patientSet.ui.PatientSetJPanel.java
/** * This method is called from within the constructor to initialize the form. *///from w w w. j av a 2s .c om private void initComponents() { java.awt.GridBagConstraints gridBagConstraints; System.setProperty("PQSortByTimeCheckBox", "true"); System.setProperty("PatientSetMaxQueryNumber", "20"); System.setProperty("PatientSetMaxPatientsNumber", "200"); System.setProperty("PQSortByNameCheckBox", "false"); jPanel1 = new javax.swing.JPanel(); jContainComboBox = new javax.swing.JComboBox(); jCategoryComboBox = new javax.swing.JComboBox(); jSearchStringTextField = new javax.swing.JTextField(); jFindButton = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTree1 = new javax.swing.JTree(); jPanel2 = new javax.swing.JPanel(); jStartTimeTextField = new javax.swing.JTextField(); jBackwardButton = new javax.swing.JButton(); jForwardButton = new javax.swing.JButton(); jLabel2 = new javax.swing.JLabel(); setLayout(new java.awt.BorderLayout(20, 10)); jPanel1.setLayout(new java.awt.GridBagLayout()); jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Search By Name")); jPanel1.setMinimumSize(new java.awt.Dimension(0, 50)); jPanel1.setPreferredSize(new java.awt.Dimension(400, 80)); jContainComboBox.setModel(new javax.swing.DefaultComboBoxModel( new String[] { "Containing", "Start With", "End With", "Exact" })); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridBagConstraints.gridheight = 2; gridBagConstraints.ipadx = 32; gridBagConstraints.ipady = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.01; gridBagConstraints.insets = new java.awt.Insets(0, 5, 0, 2); jPanel1.add(jContainComboBox, gridBagConstraints); jCategoryComboBox.setModel( new javax.swing.DefaultComboBoxModel(new String[] { "Any Category", "Patient Set", "Patient" })); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.ipadx = 14; gridBagConstraints.ipady = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.6; gridBagConstraints.insets = new java.awt.Insets(4, 2, 0, 2); jPanel1.add(jCategoryComboBox, gridBagConstraints); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 11; gridBagConstraints.ipady = 3; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.9; gridBagConstraints.insets = new java.awt.Insets(0, 2, 0, 2); jPanel1.add(jSearchStringTextField, gridBagConstraints); jFindButton.setText("Find"); jFindButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jFindButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 2; gridBagConstraints.gridwidth = java.awt.GridBagConstraints.RELATIVE; gridBagConstraints.gridheight = 2; gridBagConstraints.ipadx = 19; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.01; gridBagConstraints.insets = new java.awt.Insets(4, 4, 2, 2); jPanel1.add(jFindButton, gridBagConstraints); add(jPanel1, java.awt.BorderLayout.NORTH); QueryResultData tmpData = new QueryResultData(); tmpData.name("Pateint Sets by " + UserInfoBean.getInstance().getUserName()); tmpData.tooltip("Patient Sets"); tmpData.visualAttribute("CA"); tmpData.type("PATIENTSET"); top = new DefaultMutableTreeNode(tmpData); // top = new DefaultMutableTreeNode("Root Node"); treeModel = new DefaultTreeModel(top); // treeModel.addTreeModelListener(new MyTreeModelListener()); jTree1 = new JTree(treeModel); jTree1.setEditable(false); // jTree1.getSelectionModel().setSelectionMode // (TreeSelectionModel.SINGLE_TREE_SELECTION); jTree1.setShowsRootHandles(true); // JScrollPane treeView = new JScrollPane(jTree1); jTree1.setRootVisible(false); jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jTree1.setCellRenderer(new MyRenderer()); ToolTipManager.sharedInstance().registerComponent(jTree1); if (cellStatus.equalsIgnoreCase("CellDown")) { DefaultMutableTreeNode childNode = new DefaultMutableTreeNode("Data Repository Cell is unavailable"); treeModel.insertNodeInto(childNode, top, top.getChildCount()); // Make sure the user can see the lovely new node. jTree1.expandPath(new TreePath(top.getPath())); } ArrayList<QueryResultData> queries = patientSets; if (queries != null) { for (int i = 0; i < queries.size(); i++) { addNode(patientSets.get(i)); } } jScrollPane1.setViewportView(jTree1); add(jScrollPane1, java.awt.BorderLayout.CENTER); jTree1.setTransferHandler(new NodeCopyTransferHandler()); jTree1.addTreeExpansionListener(this); jTree1.addTreeWillExpandListener(this); jPanel2.setLayout(new java.awt.GridBagLayout()); jPanel2.setMinimumSize(new java.awt.Dimension(92, 20)); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 1; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints.ipadx = 244; gridBagConstraints.ipady = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.9; gridBagConstraints.insets = new java.awt.Insets(0, 3, 0, 0); jPanel2.add(jStartTimeTextField, gridBagConstraints); jBackwardButton.setText("<"); jBackwardButton.setMaximumSize(new java.awt.Dimension(43, 22)); jBackwardButton.setMinimumSize(new java.awt.Dimension(43, 22)); jBackwardButton.setPreferredSize(new java.awt.Dimension(43, 22)); jBackwardButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jBackwardButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.01; gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 2); jPanel2.add(jBackwardButton, gridBagConstraints); jForwardButton.setText(">"); jForwardButton.setMaximumSize(new java.awt.Dimension(43, 22)); jForwardButton.setMinimumSize(new java.awt.Dimension(43, 22)); jForwardButton.setPreferredSize(new java.awt.Dimension(43, 22)); jForwardButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jForwardButtonActionPerformed(evt); } }); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 2; gridBagConstraints.gridy = 0; gridBagConstraints.gridwidth = 3; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.01; gridBagConstraints.insets = new java.awt.Insets(0, 43, 0, 3); jPanel2.add(jForwardButton, gridBagConstraints); jLabel2.setText("Begin:"); gridBagConstraints = new java.awt.GridBagConstraints(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy = 0; gridBagConstraints.gridheight = 2; gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; gridBagConstraints.weightx = 0.01; gridBagConstraints.insets = new java.awt.Insets(3, 7, 0, 2); jPanel2.add(jLabel2, gridBagConstraints); add(jPanel2, java.awt.BorderLayout.SOUTH); }
From source file:GUI.MainWindow.java
private void ImportScanScreenWindowActivated(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_ImportScanScreenWindowActivated Object obj = ImportFile.getModel().getElementAt(0); if (obj != null && obj instanceof ImportFile) { ImportFile imFile = (ImportFile) obj; System.out.println("Importing File: " + imFile.getAbsolutePath()); ProgressBar.setIndeterminate(true); ImportScanTask ist = new ImportScanTask(ProgressBar, imFile, ImportScanScreen); ist.addPropertyChangeListener(new PropertyChangeListener() { @Override/*www. j a v a 2 s . c o m*/ public void propertyChange(PropertyChangeEvent e) { if ("progress".equals(e.getPropertyName())) { ProgressBar.setIndeterminate(false); ProgressBar.setValue((Integer) e.getNewValue()); System.out.println("**: " + e.getNewValue()); } } }); ist.execute(); try { DefaultMutableTreeNode new_root = ist.get(); System.out.println("Import Finished"); DefaultMutableTreeNode existing_root = (DefaultMutableTreeNode) VulnTree.getModel().getRoot(); if (existing_root.getChildCount() == 0) { // The tree was empty so simply set the importe one into the model VulnTree.setModel(new DefaultTreeModel(new_root)); } else { // The tree had existing children so we need to merge them VulnTree.setModel(new DefaultTreeModel(new TreeUtils().mergeTrees(existing_root, new_root))); } } catch (InterruptedException ex) { //Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); System.out.println(ex.getStackTrace()); } catch (ExecutionException ex) { //Logger.getLogger(MainWindow.class.getName()).log(Level.SEVERE, null, ex); System.out.println(ex.getStackTrace()); } } }
From source file:eu.crisis_economics.abm.dashboard.GASearchHandler.java
public void removeAllParameters() { if (chromosomeTree == null) chromosomeTree = new DefaultTreeModel(new DefaultMutableTreeNode()); else// w w w .j av a2 s. c om chromosomeTree.setRoot(new DefaultMutableTreeNode()); genes = null; for (final ModelListener listener : listeners) listener.parametersRemoved(); }
From source file:edu.harvard.i2b2.query.ui.QueryConceptTreePanel.java
/** This method is called from within the constructor to * initialize the form./*from www. j ava 2 s. c om*/ */ private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); jClearButton = new javax.swing.JButton(); jConstrainButton = new javax.swing.JButton(); jExcludeButton = new javax.swing.JButton(); jOccurrenceButton = new javax.swing.JButton(); jNameLabel = new javax.swing.JLabel(); jHintLabel = new javax.swing.JLabel(); setLayout(null); QueryConceptTreeNodeData tmpData = new QueryConceptTreeNodeData(); tmpData.name("working ......"); tmpData.tooltip("A root node"); tmpData.visualAttribute("FAO"); top = new DefaultMutableTreeNode(tmpData); //top = new DefaultMutableTreeNode("Root Node"); treeModel = new DefaultTreeModel(top); //treeModel.addTreeModelListener(new MyTreeModelListener()); jTree1 = new JTree(treeModel); jTree1.setDragEnabled(true); jTree1.setEditable(true); //jTree1.getSelectionModel().setSelectionMode // (TreeSelectionModel.SINGLE_TREE_SELECTION); //jTree1.setShowsRootHandles(true); //JScrollPane treeView = new JScrollPane(jTree1); jTree1.setRootVisible(false); jTree1.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); jTree1.setCellRenderer(new MyRenderer()); ToolTipManager.sharedInstance().registerComponent(jTree1); setBorder(javax.swing.BorderFactory.createEtchedBorder()); add(jScrollPane1); //jScrollPane1.setBounds(0, 40, 180, 200); jClearButton.setFont(new java.awt.Font("Tahoma", 1, 10)); jClearButton.setText("X"); jClearButton.setToolTipText("Clear all items from panel"); jClearButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); jClearButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); jClearButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jClearButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); } jClearButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jClearButtonActionPerformed(evt); } }); add(jClearButton); jClearButton.setBounds(160, 0, 18, 20); jConstrainButton.setText("Dates"); jConstrainButton.setToolTipText("Constrain group by dates"); jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT); jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); //jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10,-20)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jConstrainButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); //jConstrainButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); jConstrainButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); } jConstrainButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jConstrainButtonActionPerformed(evt); } }); add(jConstrainButton); jConstrainButton.setBounds(0, 20, 40, 21); jOccurrenceButton.setText("Occurs > 0x"); jOccurrenceButton.setToolTipText("Set occurrence times"); jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jOccurrenceButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jOccurrenceButton.setMargin(new java.awt.Insets(-10, -10, -10, -10)); } jOccurrenceButton.setIconTextGap(0); jOccurrenceButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jOccurrenceButtonActionPerformed(evt); } }); jOccurrenceButton.setBounds(40, 20, 90, 21); add(jOccurrenceButton); //jExcludeButton.setMnemonic('E'); jExcludeButton.setText("Exclude"); jExcludeButton.setToolTipText("Exclude all items in group"); jExcludeButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jExcludeButton.setMargin(new java.awt.Insets(2, 2, 2, 2)); if (System.getProperty("os.name").toLowerCase().indexOf("mac") > -1) { jExcludeButton.setMargin(new java.awt.Insets(-10, -15, -10, -20)); jExcludeButton.setHorizontalAlignment(javax.swing.SwingConstants.LEFT); } jExcludeButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jExcludeButtonActionPerformed(evt); } }); add(jExcludeButton); jExcludeButton.setBounds(130, 20, 48, 21); jNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jNameLabel.setText("Group 1"); jNameLabel.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); jNameLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); add(jNameLabel); jNameLabel.setBounds(0, 0, 160, 20); jNameLabel.setTransferHandler(new GroupLabelTextHandler()); jNameLabel.addMouseListener(new DragMouseAdapter()); jNameLabel.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { public void mouseMoved(java.awt.event.MouseEvent evt) { jNameLabelMouseMoved(evt); //System.out.println("mouse x: "+evt.getX()+" y: "+evt.getY()); //System.out.println("name label x: "+jNameLabel.getX()+" width: "+ // jNameLabel.getWidth()+" y: " // +jNameLabel.getY()+" height "+jNameLabel.getHeight()); } }); jNameLabel.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseExited(java.awt.event.MouseEvent evt) { jNameLabelMouseExited(evt); } }); jTree1.addTreeExpansionListener(this); jTree1.setTransferHandler(new TextHandler()); add(jScrollPane1); jScrollPane1.setViewportView(jTree1); //jTree1.setToolTipText("Double click on a folder to view the items inside"); //jScrollPane1.getViewport().setToolTipText("Double click on a folder to view the items inside"); jScrollPane1.setBounds(0, 40, 180, 120); //jScrollPane1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0))); //jTree1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() { // public void mouseMoved(java.awt.event.MouseEvent evt) { // jScrollPane1MouseMoved(evt); // } //@Override //public void mouseDragged(MouseEvent e) { // jScrollPane1MouseMoved(e); //} //}); //jTree1.addMouseListener(new java.awt.event.MouseAdapter() { // public void mouseExited(java.awt.event.MouseEvent evt) { // jScrollPane1MouseExited(evt); // } //@Override //public void mouseEntered(MouseEvent e) { // jScrollPane1MouseEntered(e); //} //}); jHintLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jHintLabel.setText( "<html><center>Drag terms from Navigate, <br>" + "<left>Find and Workplace into this group"); //jHintLabel.getFont(); jHintLabel.setFont(new Font("SansSerif", Font.PLAIN, 9)); //jHintLabel.setBorder(javax.swing.BorderFactory.createEtchedBorder()); jHintLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); jHintLabel.setVerticalAlignment(javax.swing.SwingConstants.CENTER); //jHintLabel.setBackground(Color.WHITE); //jHintLabel.setForeground(Color.WHITE); add(jHintLabel); jHintLabel.setBounds(0, 120, 180, 30); }