3 Pages

JTreeFileNavigatorExercise

Course: COMP 585, Fall 2009
School: CSU Northridge
Rating:
 
 
 
 
 

Word Count: 560

Document Preview

for JTree File System Display Create an application that uses a JTree to display the contents of a portion of the local file system. Using the JFileChooser dialog, allow the user to pick a directory to use as the root of the directory tree. Using methods of class File (package java.io), navigate from this directory through its files and subdirectories. During the traversal of the directory tree, build a...

Register Now

Unformatted Document Excerpt

Coursehero >> California >> CSU Northridge >> COMP 585

Course Hero has millions of student submitted documents similar to the one
below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.

Course Hero has millions of student submitted documents similar to the one below including study guides, practice problems, reference materials, practice exams, textbook help and tutor support.
for JTree File System Display Create an application that uses a JTree to display the contents of a portion of the local file system. Using the JFileChooser dialog, allow the user to pick a directory to use as the root of the directory tree. Using methods of class File (package java.io), navigate from this directory through its files and subdirectories. During the traversal of the directory tree, build a parallel JTree using DefaultMutableTreeNode objects. The user object for each node should be a reference to the corresponding file or directory. At the end of the traversal, set the root of the directory tree to be the root node of a JTree object. Display the JTree object on the GUI. Additional Features A common organization for GUIs using JTree-based data display is to use a JSplitPane with the JTree on the left side panel, and the display of information associated with the currently selected node in the right side panel. For example, you could use this GUI skeleton to implement an image browser or Java source code browser. Example Implementation Below is code for a simplified implementation that allows the user to pick a file, then build a string representation of all files/directories within the file system subtree starting at the chosen file. The string is then displayed as text in a JOptionPane dialog box. The method String getFileNames() is the recursive method that builds the String. For this exercise, start by rewriting the getFileNames() method to build a JTree instead of a String. At every level in the hierarchy, the method should build a DefaultMutableTreeNode, make recursive calls to build subtrees, add subtree nodes to the current node, and then finally return a reference to the original node. Once the nodes have been built, the root node is added to a JTree, the JTree is placed into a JScrollPane, and the is JScrollPane displayed on the GUI. import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.io.*; import javax.swing.tree.*; public class FileDemo extends JPanel { JFileChooser fc; JButton btnfc; public FileDemo() { super(true); fc = new JFileChooser(); fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); btnfc = new JButton("Choose File"); add(btnfc); // action listener for the choose file button // will open the file choose and allow the user to pick a directory btnfc.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int fcstatus = fc.showOpenDialog(FileDemo.this); if (fcstatus == JFileChooser.APPROVE_OPTION) { // build string list of file/directory names String s = getFileNames(fc.getSelectedFile(),0); // place string into a text pane, and display it JTextPane tp = new JTextPane(); tp.setText(s); JScrollPane sp = new JScrollPane(tp); sp.setPreferredSize(new Dimension(400,300)); JOptionPane.showConfirmDialog(FileDemo.this, sp); } } }); } public static void buildGUI() { JFrame f = new JFrame("File Demo")...

Find millions of documents on Course Hero - Study Guides, Lecture Notes, Reference Materials, Practice Exams and more. Course Hero has millions of course specific materials providing students with the best way to expand their education.

Below is a small sample set of documents:

CSU Northridge - COMP - 585
COMP 585 Noteset #11 Text Editing, Lists, Combo Boxes, Spin (Petzold Ch 18) Abstract Class TextBoxBase Properties string Text int MaxLength int TextLength string[] Lines Class TextBox Class RichTextBox Events (from Class Control) TextChanged (based o
CSU Northridge - COMP - 585
COMP 585 Fall 2007 Project 1: Number Puzzle Project (Java Swing Programming) You will create 2 versions of a GUI-based Java application for the 15 puzzle. Heres some example screen captures:Figure 1: Screen Capture of Puzzle 1.0Figure 2: Screen C
CSU Northridge - COMP - 110
COMP 110 Spring 2007 Midterm 2 NAME: _ Four problems, equally weighted at 25 points each. Read each problem carefully, and answer all parts.Problem 1: Write Methods Write methods to implement solutions to the problems for two of the four subparts b
CSU Northridge - COMP - 585
COMP 585 Fall 2007 Project 3 Knights Tour Solution and GUI in C#/Windows Forms (DRAFT) Background The Knights Tour is a mathematical puzzle based on an empty chess board and a single chess piece the knight. The board is an 8-by-8 grid of 64 squares
CSU Northridge - ECS - 350
ECE 350 Linear Systems I Spring 2009 Course Information and PoliciesInstructor:Xiaojun (Ashley) Geng Jacaranda Hall Rm# 3343 Office phone: 818-677-4755 Email: xjgeng@csun.edu (the best way to contact)Meet Time: 2:00pm 3:15pm, Tuesdays and Thur
CSU Northridge - ECS - 350
ECE 350 Homework 4 1. For each of the systems described by the following differential equations, find the system transfer function: & & (a) &(t ) + 11 y (t ) + 24 y (t ) = 5 x(t ) + 3x(t ) y& (b) &(t ) y (t ) = x(t ) x(t ) y2. Find the inverse
CSU Northridge - ECS - 350
ECE 350 Matlab Assignment #1Requirements: (1) All your work should be edited using word processing software such as MS WORD, including graphs, Matlab files (M file) and your description and comments. Do not use printouts directly from Matlab softwar
CSU Northridge - ECS - 350
EE 350 Linear Systems I MATLAB Tutorial #1 The homework assignments in this course contain problems that must be completed using MATLAB. A minimal knowledge of MATLAB is required get started. Advanced MATLAB features will be introduced in tutorials
CSU Northridge - ECS - 350
ECE 350 Solution to Homework 2 1. Answer: (a) ; nonlinear; (b) linear; (c) nonlinear; (d) nonlinear; Approach 1: This can be verified by using the procedure discussed in Example 1.9 in the textbook, i.e., checking if the superposition property is sat
CSU Northridge - ECS - 350
ECE 350 Midterm Exam Practice Problem 1. [10 points] Write a single expression for x(t) in terms of the unit step function.Problem 2. [15 points] (a) Simplify the following expression; et 2 t + 2 (t + 2) = (b) Evaluate the following two int
CSU Northridge - ECS - 350
ECE 350 Solution to Homework 4 1. Answer: s 1 1 5s + 3 = (a) 2 ; (b) 2 s 1 s +1 s + 11s + 242. Find the inverse (unilateral) Laplace transforms of the functions given below.Another approach: X(s) =3( s + 2) 1 3( s + 2) 3 1 = 2 2 2 2 2 2 ( s +
CSU Northridge - ECS - 350
ECE 350 Homework 3 (Completed by March 5, 2009)1. An LTIC system is specified by the equation 5 6 1 (a) Find the characteristic polynomial, characteristic equation, characteristic roots (eigenvalues), and characteristic modes of this system. (b) Fi
CSU Northridge - VER - 9
Orcad Component Information System Quick ReferenceShortcut keys CIS toolbars Command mapping from CIS v7.20 to CIS Release 9Cadence PCB Systems Division (PSD) offices PSD main office (Portland) PSD Irvine office PSD Japan office PSD UK office PSD
CSU Northridge - VER - 9
PSpice Quick ReferencePSpice shortcut keys PSpice toolbars PSpice Model Editor shortcut keys and toolbar PSpice Stimulus Editor shortcut keys and toolbarCadence PCB Systems Division (PSD) offices PSD main office (Portland) PSD Irvine office PSD J
CSU Northridge - VER - 9
Orcad Capture Quick ReferenceShortcut keys The toolbar The schematic page editor tool palette The part editor tool paletteCadence PCB Systems Division (PSD) offices PSD main office (Portland) PSD Irvine office PSD Japan office PSD UK office PSD c
CSU Northridge - VER - 9
Orcad LayoutAutoplacement Users GuideCopyright 1985-2000 Cadence Design Systems, Inc. All rights reserved. Trademarks Allegro, Ambit, BuildGates, Cadence, Cadence logo, Concept, Diva, Dracula, Gate Ensemble, NC Verilog, OpenBook online documenta
CSU Northridge - VER - 9
Orcad Layout Quick ReferenceShortcut keys Toolbar Command mapping from Layout v7.10 to Layout Release 9Cadence PCB Systems Division (PSD) offices PSD main office (Portland) PSD Irvine office PSD Japan office PSD UK office PSD customer support PSD
CSU Northridge - VER - 9
capug.book Page 1 Tuesday, May 23, 2000 12:08 PMOrcad CaptureUsers Guidecapug.book Page 2 Tuesday, May 23, 2000 12:08 PMCopyright 1985-2000 Cadence Design Systems, Inc. All rights reserved. Trademarks Allegro, Ambit, BuildGates, Cadence, Cad
CSU Northridge - WS - 20500
ANNOUNCEMENT OF ANTICIPATED PART-TIME FACULTY POSITION OPENINGS18111 Nordhoff Street Northridge, California 91330 Department: Gender & Womens Studies 2009 Effective Date of Appointment: Fall 2008 and/or SpringAll part-time faculty appointments ar
CSU Northridge - VCGEO - 005
ARTICLETime to Accumulate Chloride Ions in the Worlds OceansCreationisms Young Earth Not SupportedINTRODUCTION Some creation scientists claim that the earth is only about 6000 years old, but this assertion is not based on science.They also object
CSU Northridge - KFS - 103
Math 103 Section 3.1, 3.2: Math of Finance: solving for timeThree ways to compute future valueSimple interest Compound interest Continuous compounded interest A = P (1 + rt) A = P (1 + i)n A = P ertThese formulas can also be used to compute the
CSU Northridge - KFS - 4816
Math 103 Section 3.1, 3.2: Math of Finance: solving for timeThree ways to compute future valueSimple interest Compound interest Continuous compounded interest A = P (1 + rt) A = P (1 + i)n A = P ertThese formulas can also be used to compute the
CSU Northridge - KFS - 4816
Katherine F. StevensonDepartment of Mathematics California State University, Northridge, CA 91330 Telephone: (818)677-6446; Email: Katherine.Stevenson@csun.edu Web: http:/www.csun.edu/kfs4816/Education: B.S., Mount Holyoke College, June 1989. Cum
CSU Northridge - KFS - 4816
NAME: CALCULUS II (Math 150B): Final. General Instructions 1. You are allowed your cheatsheat (one page, front and back allowed). 2. NO Calculators. 3. Please show all your work, unless explicitly instructed not to do so. 4. You may use the tables in
CSU Northridge - KFS - 4816
Practice Test 3 1. In each of the following determine whether the series converges or diverges. Circle your answer. You do not need to show all your work. (a)(1)k k=0 k2 +3 .Converges (b) 1 k=2 (ln n)2 n .DivergesConverges (c) k=1 (k1/3 1)
CSU Northridge - KFS - 4816
Homework: Vectors Math 150B. 1. Let a = 2j + 3j, b = 2j 3j and c = 5j. Compute the following: (a) 2a 4b; (b) a b; (c) a (b + c; (d) (2a 4b) 5c; (e) b b |b|; 2. Find the cosine of the angle between the vectors a and b below. (a) a = j 3j and
CSU Northridge - KFS - 4816
CALCULUS II (Math 150B): Practice Midterm II.1. Suppose that Alice computed the Left, Right, Trapezoidal, and Midpoint approximations with 10 partitions to 01 f (x)dx, where f (x) is as shown below. She wrote them on cards, but forgot to label whic
CSU Northridge - KFS - 103
4.2 Systems of Linear equations and Augmented Matrices1. 2.3.It is impractical to solve more complicated linear systems by hand. Computers and calculators now have built in routines to solve larger and more complex systems. Matrices, in conjunct
CSU Northridge - KFS - 4816
4.2 Systems of Linear equations and Augmented Matrices1. 2.3.It is impractical to solve more complicated linear systems by hand. Computers and calculators now have built in routines to solve larger and more complex systems. Matrices, in conjunct
CSU Northridge - KFS - 320
Course Notes for Math 320: Fundamentals of Mathematics Analysis.May 4, 20061Completeness Property1. A is bounded above if there is a real number b R such that a b for all a A. 2. A is bounded below if there is a real number l R such that a
CSU Northridge - KFS - 4816
Course Notes for Math 320: Fundamentals of Mathematics Analysis.May 4, 20061Completeness Property1. A is bounded above if there is a real number b R such that a b for all a A. 2. A is bounded below if there is a real number l R such that a
CSU Northridge - KFS - 103
WARM UP EXERCISEThe ozone level (in parts per billion) on a summer day at R University is given by P(x) = 80 + 12t t 2 Where t is hours after 9 am. 1. P (x). 2. Find P (3) and P (3). 3. Write an interpretation.Given y = f (x) then the derivativ
CSU Northridge - KFS - 4816
WARM UP EXERCISEThe ozone level (in parts per billion) on a summer day at R University is given by P(x) = 80 + 12t t 2 Where t is hours after 9 am. 1. P (x). 2. Find P (3) and P (3). 3. Write an interpretation.Given y = f (x) then the derivativ
CSU Northridge - KFS - 320
Math 320 Project Equivalence of 2-by-2 integral matricesSeptember 8, 20051An equivalence relation on integral matricesThis project is about an equivalence relation on 2-by-2 integral matrices. Our notation for these matrices is: M2 (Z) = a b
CSU Northridge - KFS - 4816
Math 320 Project Equivalence of 2-by-2 integral matricesSeptember 8, 20051An equivalence relation on integral matricesThis project is about an equivalence relation on 2-by-2 integral matrices. Our notation for these matrices is: M2 (Z) = a b
CSU Northridge - KFS - 320
Course Notes for Math 320: Fundamentals of Mathematics Chapter 2: Sets.September 15, 20041Introdction to SetsDenition 1.1. A set A is a well dened collection of objects. If a is an element of A then we write a A. Remark 1.2. Well dened means
CSU Northridge - KFS - 4816
Course Notes for Math 320: Fundamentals of Mathematics Chapter 2: Sets.September 15, 20041Introdction to SetsDenition 1.1. A set A is a well dened collection of objects. If a is an element of A then we write a A. Remark 1.2. Well dened means
CSU Northridge - KFS - 103
4.5 Inverse of a Square MatrixIn this section, we will learn how to find an inverse of a square matrix (if it exists) and learn the definition of the identity matrix.Identity Matrix for Multiplication:The number 1 is called the multiplicative ide
CSU Northridge - KFS - 4816
4.5 Inverse of a Square MatrixIn this section, we will learn how to find an inverse of a square matrix (if it exists) and learn the definition of the identity matrix.Identity Matrix for Multiplication:The number 1 is called the multiplicative ide
CSU Northridge - KFS - 103
4.4 Matrices: Basic OperationsAddition and subtraction of matrices Product of a number k and a matrix M Matrix Product.Addition and Subtraction of matrices! !To add or subtract matrices, they must be of the same size mxn. To add matrices of th
CSU Northridge - KFS - 4816
4.4 Matrices: Basic OperationsAddition and subtraction of matrices Product of a number k and a matrix M Matrix Product.Addition and Subtraction of matrices! !To add or subtract matrices, they must be of the same size mxn. To add matrices of th
CSU Northridge - KFS - 320
NAME: FINAL: Fundamentals of Mathematics (Math 320) Stevenson General Instructions 1. You are allowed your cheatsheat. 2. NO Calculators. 3. Please show all your work, unless explicitly instructed not to do so. 4. Please ask if you are not sure of an
CSU Northridge - KFS - 4816
NAME: FINAL: Fundamentals of Mathematics (Math 320) Stevenson General Instructions 1. You are allowed your cheatsheat. 2. NO Calculators. 3. Please show all your work, unless explicitly instructed not to do so. 4. Please ask if you are not sure of an
CSU Northridge - KFS - 103
Math 103 Section 3.1, 3.2: Math of Finance simple interest compound interestSimple Interest:A = P (1 + rt) A: amount, or future value P : principal, or present value r: annual simple interest rate (decimal form) t time in years.1Example
CSU Northridge - KFS - 4816
Math 103 Section 3.1, 3.2: Math of Finance simple interest compound interestSimple Interest:A = P (1 + rt) A: amount, or future value P : principal, or present value r: annual simple interest rate (decimal form) t time in years.1Example
CSU Northridge - KFS - 320
Project Notes for Math 320: Fundamentals of Mathematics Recurrence Relations.August 17, 20051Silly examplePlease complete the following: 1. Consider the table below: n 0 1 2 3 4 5 6 k 3 XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX
CSU Northridge - KFS - 4816
Project Notes for Math 320: Fundamentals of Mathematics Recurrence Relations.August 17, 20051Silly examplePlease complete the following: 1. Consider the table below: n 0 1 2 3 4 5 6 k 3 XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX XX
CSU Northridge - KFS - 320
Course Notes for Math 320: Fundamentals of Mathematics Homework Hints for Number Theory.October 5, 200588 Let r1 , r2 , r3 , . be an innite sequence of nonnegative integers such that r1 > r2 > r3 > . Prove that for some number k N, rk = 0. Hint: (
CSU Northridge - KFS - 4816
Course Notes for Math 320: Fundamentals of Mathematics Homework Hints for Number Theory.October 5, 200588 Let r1 , r2 , r3 , . be an innite sequence of nonnegative integers such that r1 > r2 > r3 > . Prove that for some number k N, rk = 0. Hint: (
CSU Northridge - KFS - 103
WARM UP EXERCSEA cable company has found that the total number N (in thousands) of subscribers t months after the installation of the system is given by N( t ) = 200t / (t + 5) Find N (15) and N (15). Write an interpretation of these results.11
CSU Northridge - KFS - 4816
WARM UP EXERCSEA cable company has found that the total number N (in thousands) of subscribers t months after the installation of the system is given by N( t ) = 200t / (t + 5) Find N (15) and N (15). Write an interpretation of these results.11
CSU Northridge - KFS - 103
Math 103 Section 2.2: Elementary Functions and Transformations1. A beginning library of elementary functions2. Graphs of elementary functions3. Shifts and stretches4. Piecewise -dened functions1Beginning Library identity function f (x) =
CSU Northridge - KFS - 4816
Math 103 Section 2.2: Elementary Functions and Transformations1. A beginning library of elementary functions2. Graphs of elementary functions3. Shifts and stretches4. Piecewise -dened functions1Beginning Library identity function f (x) =
CSU Northridge - KFS - 103
103 Section 3.1, 3.2: Math of Finance continued simple interest compound interest continuous compounded interestThree ways to compute future valueSimple interest Compound interest Continuous compounded interest A = P (1 + rt) A = P (1 + i)n A =
CSU Northridge - KFS - 4816
103 Section 3.1, 3.2: Math of Finance continued simple interest compound interest continuous compounded interestThree ways to compute future valueSimple interest Compound interest Continuous compounded interest A = P (1 + rt) A = P (1 + i)n A =
CSU Northridge - KFS - 320
Course Notes for Math 320: Fundamentals of Mathematics Chapter 4: Relations, Equivalence Relations and Congruence.March 14, 20061RelationsDenition 1.1. (Kazimierz Kuratowski) Let S be a set and let a and b be members of S. The ordered pair (a,
CSU Northridge - KFS - 4816
Course Notes for Math 320: Fundamentals of Mathematics Chapter 4: Relations, Equivalence Relations and Congruence.March 14, 20061RelationsDenition 1.1. (Kazimierz Kuratowski) Let S be a set and let a and b be members of S. The ordered pair (a,
CSU Northridge - KFS - 103
Practice Math 103 Spring 2007: Midterm III. You are allowed your cheatsheat 1/4 of a page. 1. Find the derivatives of the following functions and simplify. (a) q(x) = 4x5 + 3x2 (b) n(x) = (c) m(x) =4x+3 (7x1)2 4x+3 (7x1)2 1/32. Use the denition of
CSU Northridge - KFS - 4816
Practice Math 103 Spring 2007: Midterm III. You are allowed your cheatsheat 1/4 of a page. 1. Find the derivatives of the following functions and simplify. (a) q(x) = 4x5 + 3x2 (b) n(x) = (c) m(x) =4x+3 (7x1)2 4x+3 (7x1)2 1/32. Use the denition of
CSU Northridge - KFS - 320
Project Notes for Math 320: Fundamentals of Mathematics Partitions ARE Equivalence Relations.August 31, 20051Introduction to Partitions and CountingS = {1, 2, 3, 4, 5, 6, 7}Example 1.1. Let Consider the following three subsets of the power s
CSU Northridge - KFS - 4816
Project Notes for Math 320: Fundamentals of Mathematics Partitions ARE Equivalence Relations.August 31, 20051Introduction to Partitions and CountingS = {1, 2, 3, 4, 5, 6, 7}Example 1.1. Let Consider the following three subsets of the power s