CODEFETCH™
            Examples
Searched for 2 expression(s): jtree   file  
Java API
java.awt.FileDialog search codefetch
The FileDialog class displays a dialog window from which the user can select a file.
java.awt.color.ICC_Profile search codefetch
A representation of color profile data for device independent and device dependent color spaces based on the International Co...
java.awt.color.ICC_ProfileGray search codefetch
A subclass of the ICC_Profile class which represents profiles which meet the following criteria: the color space type of the ...
java.awt.color.ICC_ProfileRGB search codefetch
The ICC_ProfileRGB class is a subclass of the ICC_Profile class that represents profiles which meet the following criteria: T...
java.io.File search codefetch
An abstract representation of file and directory pathnames.
javax.swing.JFileChooser.addChoosableFileFilter search codefetch
Adds a filter to the list of user choosable file filters.
javax.imageio.spi.ImageInputStreamSpi.canUseCacheFile search codefetch
Returns true if the ImageInputStream implementation associated with this service provider can optionally make use of a cache ...
javax.swing.filechooser.FileSystemView.createFileObject search codefetch
Returns a File object constructed from the given path string.
javax.swing.filechooser.FileSystemView.createFileSystemRoot search codefetch
Creates a new File object for f with correct behavior for a file system root directory.
java.io.File.createNewFile search codefetch
Atomically creates a new, empty file named by this abstract pathname if and only if a file with this name does not yet exist....
Most relevant API matches shown. View All.
Source code below from:
Professional Java User Interfaces
By Mauro Marinilli
Published 26 May, 2006
Average rating

      Powells     Alibris

PJUI/com/marinilli/b1/ac/pres/proto/JProtoTree.java (307 lines)
18  */ 
19 public class JProtoTree extends JTree implements MouseListener,
20                                                  TreeSelectionListener { 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
137 java.io.InputStream in = 138 ServiceManager.getInstance().getClass().getClassLoader() 139 .getResourceAsStream(fileName); 140 prpts.load(in); 141 } catch (Exception ex) { 142 System.out.println("loading tree properties: "+ex); 143 } 144 //launch recursion 145 setRoot(createNode("root",prpts,"")); 146 147 //read other properties 148 for (Enumeration i = prpts.propertyNames(); i.hasMoreElements(); ) { 149 String s = (String)i.nextElement(); 150 if (s.startsWith("JTree.")) 151 clientProperties.put(s,prpts.getProperty(s)); 152 else {
Additional matches viewable in cache of PJUI/com/marinilli/b1/ac/pres/proto/JProtoTree.java.
PJUI/com/marinilli/b1/c5/templates/JProtoTree.java (310 lines)
20  */ 
21 public class JProtoTree extends JTree implements MouseListener, TreeSelectionListener {
22   private final static int CAPTION = 0; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
143 try { 144 java.io.InputStream in = 145 ServiceManager.getInstance().getClass().getClassLoader().getResourceAsStream(fileName); 146 prpts.load(in); 147 } catch (Exception ex) { 148 System.out.println("loading tree properties: "+ex); 149 } 150 //launch recursion 151 setRoot(createNode("root",prpts,"")); 152 153 //read other properties 154 for (Enumeration i = prpts.propertyNames(); i.hasMoreElements(); ) { 155 String s = (String)i.nextElement(); 156 if (s.startsWith("JTree.")) 157 clientProperties.put(s,prpts.getProperty(s)); 158 else {
Additional matches viewable in cache of PJUI/com/marinilli/b1/c5/templates/JProtoTree.java.
PJUI/com/marinilli/b1/c3/spareparts/SparePartViewer.java (92 lines)
16 public class SparePartViewer extends JFrame{ 
17   JTree tree;
18  
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
49 JMenuBar jMenuBar = new JMenuBar(); 50 jMenuBar.add(new JMenu("File")); 51 jMenuBar.add(new JMenu("Edit"));
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
81 82 tree = new JTree(root); 83
Source code below from:
The Definitive Guide to Java Swing, Third Edition (Definitive Guide)
By John Zukowski
Published 13 June, 2005
Average rating

      Powells     Alibris

Ch04/ComponentHier.java (58 lines)
36  
37         Object jComponentNodes[] = {abstractButtonVector, "Box", "JColorChooser", 
38             "JComboBox", "JFileChooser", "JInternalFrame", "JLabel", jLayeredPaneVector,
39             "JList", "JMenuBar", "JOptionPane", "JPanel", "JPopupMenu", "JProgressBar",  
40             "JRootPane", "JScrollBar", "JScrollPane", "JSeparator", "JSlider", "JSpinner", 
41             "JSplitPane", "JTabbedPane", "JTable", jTextComponentVector, "JToolBar", "JTree",
42             "JViewPort"}; 
43         Vector jComponentVector = new NamedVector("JComponent", jComponentNodes); 
Additional matches viewable in cache of Ch04/ComponentHier.java.
Ch01/SwingTree.java (39 lines)
17           "colorchooser",  
18           "event",  
19           "filechooser", 
20           "plaf",  
21           "table",  
22           textVector, 
23           "tree", 
24           "undo"}); 
25         JTree tree = new JTree(rootVector);
26         tree.setRootVisible(true); 
27         TreeModel model = tree.getModel(); 
Source code below from:
Learning Java
By Pat Niemeyer and Jonathan Knudsen
Published 20 May, 2005
Average rating

      Powells     Alibris

examples/ch18/PartsTree.java (72 lines)
1 //file: PartsTree.java
2 import java.awt.*; 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
25 26 // create the JTree 27 final DefaultTreeModel model = new DefaultTreeModel(root); 28 final JTree tree = new JTree(model); 29
Source code below from:
Core Java(TM) 2, Volume II--Advanced Features (7th Edition)
By Cay Horstmann and Gary Cornell
Published 22 November, 2004
Average rating

      Powells     Alibris

v2/v2ch12/DOMTreeTest/DOMTreeTest.java (243 lines)
40  
41       JMenu fileMenu = new JMenu("File");
42       JMenuItem openItem = new JMenuItem("Open"); 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
80 int r = chooser.showOpenDialog(this); 81 if (r != JFileChooser.APPROVE_OPTION) return; 82 File f = chooser.getSelectedFile(); 83 try 84 { 85 if (builder == null) 86 { 87 DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); 88 builder = factory.newDocumentBuilder(); 89 } 90 91 Document doc = builder.parse(f); 92 JTree tree = new JTree(new DOMTreeModel(doc)); 93 tree.setCellRenderer(new DOMTreeCellRenderer()); 94
Additional matches viewable in cache of v2/v2ch12/DOMTreeTest/DOMTreeTest.java.
Source code below from:
Java Cookbook, Second Edition
By Ian Darwin
Published 14 June, 2004
Average rating

      Powells     Alibris

gui/FileTree.java (99 lines)
7  
8 /** 
9  * Display a file system in a JTree view
10  * 
11  * @version $Id: FileTree.java,v 1.9 2004/02/23 03:39:22 ian Exp $
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
15 { 16 /** Construct a FileTree */ 17 public FileTree(File dir) { 18 setLayout(new BorderLayout()); 19 20 // Make a tree list with all the nodes, and make it a JTree 21 JTree tree = new JTree(addNodes(null, dir)); 22
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
30 }); 31 32 // Lastly, put the JTree into a JScrollPane. 33 JScrollPane scrollpane = new JScrollPane(); 34 scrollpane.getViewport().add(tree); 35 add(BorderLayout.CENTER, scrollpane); 36 } 37 38 /** Add nodes from under "dir" into curTop. Highly recursive. */ 39 DefaultMutableTreeNode addNodes(DefaultMutableTreeNode curTop, File dir) { 40 String curPath = dir.getPath(); 41 DefaultMutableTreeNode curDir = new DefaultMutableTreeNode(curPath);
Additional matches viewable in cache of gui/FileTree.java.
Source code below from:
Java Swing, Second Edition
By James Elliott, Robert Eckstein, Marc Loy, David Wood, and Brian Cole
Published 01 November, 2002
Average rating

      Powells     Alibris

jswing2/ch24/FSTree.java (78 lines)
1 // FSTree.java 
2 // A sample component for dragging & dropping a collection of files
3 // into a tree. 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
13 import java.awt.Rectangle; 14 import java.awt.Insets; 15 import java.io.File; 16 import java.io.IOException; 17 18 public class FSTree extends JTree { 19 20 public FSTree() { super(); init(); }
Additional matches viewable in cache of jswing2/ch24/FSTree.java.
jswing2/ch17/SortTreeDemo.java (55 lines)
2 // This class creates a tree model using the SortTreeModel with 
3 // a File hierarchy as input.
4 // 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
19 fillModel(model, root); 20 21 JTree tree = new JTree(model); 22 getContentPane().add(new JScrollPane(tree)); 23 } 24 25 protected void fillModel(SortTreeModel model, DefaultMutableTreeNode current) { 26 PrettyFile pf = (PrettyFile)current.getUserObject(); 27 File f = pf.getFile(); 28 if (f.isDirectory()) {
Additional matches viewable in cache of jswing2/ch17/SortTreeDemo.java.
jswing2/ch17/VSX.java (117 lines)
1 // VSX.java 
2 // A simple XML parser that builds a tree from SAX events.  The xml file
3 // should be passed as a commandline argument. 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
104 public static void main(String args[]) { 105 if (args.length != 1) { 106 System.err.println("Usage is: java VSX testfile.xml"); 107 System.exit(1); 108 } 109 JFrame frame = new JFrame("VSX Test"); 110 VSX parser = new VSX(); 111 JTree tree = new JTree(parser.parse(args[0])); 112 frame.getContentPane().add(new JScrollPane(tree)); 113 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Additional matches viewable in cache of jswing2/ch17/VSX.java.
jswing2/ch17/VSX2.java (156 lines)
3 // Currently this class has two main methods: parse() and write(). 
4 // Both work with the TreeModel class and are meant to help you 
5 // view XML documents with JTree.  This version will embed icons
6 // and tool tip text in nodes if <code>icon</code> or 
7 // <code>tiptext</code> attributes are found in the tag. 
8 // 
9  
10 import javax.swing.*; 
11 import javax.swing.tree.*; 
12 import java.util.*; 
13 import java.io.*; 
14 import org.xml.sax.*; 
15 import org.xml.sax.helpers.*; 
16 import javax.xml.parsers.*; 
17  
18 public class VSX2 { 
19  
20  
21   public TreeModel parse(String filename) {
22     SAXParserFactory factory = SAXParserFactory.newInstance(); 
23     XMLIconTreeHandler handler = new XMLIconTreeHandler(); 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
133 public static void main(String args[]) { 134 if (args.length != 1) { 135 System.err.println("Usage is: java VSX2 testfile.xml"); 136 System.exit(1); 137 } 138 JFrame frame = new JFrame("Tree Renderer Test"); 139 VSX2 parser = new VSX2(); 140 JTree tree = new JTree(parser.parse(args[0])); 141 142 // Steal the default icons from the default renderer...
Additional matches viewable in cache of jswing2/ch17/VSX2.java.
jswing2/ch17/EmailTreeCellEditor.java (76 lines)
2 // An editor that actually manages two separate editors: one for folders 
3 // (nodes) that uses a combobox; and one for files (leaves) that uses a
4 // textfield. 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
29 30 public Component getTreeCellEditorComponent(JTree tree, Object value, 31 boolean isSelected,
Source code below from:
Java Examples in a Nutshell (In a Nutshell)
By David Flanagan
Published 26 September, 2000
Average rating

      Powells     Alibris

JavaExamples2/com/davidflanagan/examples/xml/DOMTreeWalkerTreeModel.java (158 lines)
16 import javax.swing.tree.*;           // TreeModel and related classes 
17 import javax.swing.event.*;          // Tree-related event classes 
18 import java.io.*;                    // For reading the input XML file
19  
20 /** 
21  * This class implements the Swing TreeModel interface so that the DOM tree 
22  * returned by a TreeWalker can be displayed in a JTree component.
23  **/ 
24 public class DOMTreeWalkerTreeModel implements TreeModel { 
Additional matches viewable in cache of JavaExamples2/com/davidflanagan/examples/xml/DOMTreeWalkerTreeModel.java.

Not satisfied? Try this search biased towards software and programming:
Google