Results 1 to 2 of 2
-
JFileChooser example (selecting a directory)
The example below shows how to select a directory using a JFileChooser.
Java Code:public class DemoJFileChooser extends JPanel implements ActionListener { JButton go; JFileChooser chooser; String choosertitle; public DemoJFileChooser() { go = new JButton("Do it"); go.addActionListener(this); add(go); } public void actionPerformed(ActionEvent e) { int result; chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(".")); chooser.setDialogTitle(choosertitle); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // // disable the "All files" option. // chooser.setAcceptAllFileFilterUsed(false); // if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) { System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory()); System.out.println("getSelectedFile() : " + chooser.getSelectedFile()); } else { System.out.println("No Selection "); } } public Dimension getPreferredSize(){ return new Dimension(200, 200); } public static void main(String s[]) { JFrame frame = new JFrame(""); DemoJFileChooser panel = new DemoJFileChooser(); frame.addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } } ); frame.getContentPane().add(panel,"Center"); frame.setSize(panel.getPreferredSize()); frame.setVisible(true); } }
- 02-03-2009, 01:25 PM #2
Thanks for your code...
can't we get this in JSP?? instead of going for swings??
thanks in advance..
If so ..need help in this regardingvisit : www.yoteam.co.cc
Similar Threads
-
Localize JFileChooser
By Java Tip in forum Java TipReplies: 0Last Post: 03-14-2008, 11:54 AM -
Selecting parts of an image
By shaungoater in forum Java 2DReplies: 1Last Post: 12-15-2007, 10:06 PM -
JFileChooser remember the location
By Mr tuition in forum AWT / SwingReplies: 3Last Post: 12-08-2007, 05:17 PM -
selecting a record in database
By ramachandran in forum New To JavaReplies: 0Last Post: 10-25-2007, 07:06 AM -
how to use JFileChooser
By tommy in forum New To JavaReplies: 1Last Post: 08-06-2007, 08:49 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks