Directory chooser in core java

Ads

 
 

Share on Google+Share on Google+

Manoj
Directory chooser in core java
1 Answer(s)      9 years ago
Posted in : Java Beginners
Ads
View Answers

May 12, 2008 at 7:12 PM


Hi friend,


import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import java.util.*;


public class FileChooser extends JPanel implements ActionListener {
JButton button;
JFileChooser chooser;
String choosertitle;

public FileChooser() {
button = new JButton("Click me");
button.addActionListener(this);
add(button);
}

public void actionPerformed(ActionEvent e) {
int result;

chooser = new JFileChooser();
chooser.setCurrentDirectory(new java.io.File("."));
chooser.setDialogTitle(choosertitle);
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
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 file");
}
}

public Dimension getPreferredSize(){
return new Dimension(300, 300);
}

public static void main(String s[]) {
JFrame frame = new JFrame("Directory chooser file example");
FileChooser panel = new FileChooser();
frame.addWindowListener(
new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
frame.getContentPane().add(panel,"Center");
frame.setSize(panel.getPreferredSize());
frame.setVisible(true);
}
}

----------------------------------------

read for more information,

http://www.roseindia.net/java/

Ads









Related Tutorials/Questions & Answers:
Directory chooser in core java - Java Beginners
Directory chooser in core java  Hi, I have to create a Utility...[]) { JFrame frame = new JFrame("Directory chooser file example"); FileChooser... to create a GUI( AWT or Swing based only) which should have 2 directory
Version of directory>apacheds-core dependency
List of Version of directory>apacheds-core dependency
Advertisements
Version of directory-naming>naming-core dependency
List of Version of directory-naming>naming-core dependency
create folder chooser - Java Server Faces Questions
( to save file download, for instance, not file chooser), please help me,(use swing...[]) { JFileChooser chooser = new JFileChooser... saveFile = new File("image." + "jpg"); JFileChooser chooser = new
Java Create Directory Example
Java Create Directory Example To create a directory in java call the mkdir... of creating a directory in java is given below SampleInterfaceImp.java import... below, F:\Core Java Examples>javac
Getting Current Directory from java - Java Beginners
Getting Current Directory from java  I'm designing an application in linux where i need to get the current directory of my java file... I'm using.../Softwares/apache-tomcat-5.5.27/logs How to get the directory of my current
Version of directory-naming>naming-java dependency
List of Version of directory-naming>naming-java dependency
Copy Directory or File in Java
Copy Directory in Java      ...: C:\nisha>java CopyDirectory Enter the source directory...;        Introduction Java has
how to copy the directory in to ftp server using java
how to copy the directory in to ftp server using java  how to copy the directory in to ftp server using java ?   Hello venaktehs As much as I know,You can do this as follows: First,Create a directory in the current
File copy from one directory to another in java
directory in Java. I have to write a program in my application for copying one file... for copying the file from one directory to another directory in Java...File copy from one directory to another in java  I am trying to find
Version of com.amazonaws>aws-java-sdk-directory dependency
List of Version of com.amazonaws>aws-java-sdk-directory dependency
Get current working directory in Java
Get current working directory in Java In this section we will discuss about how to get the the current working directory in java. Current working directory means the current working directory where java program execute. In java
Java Naming and Directory Interface (JNDI)
Java Naming and Directory Interface (JNDI)       The Java Naming and Directory Interface (JNDI) is a directory service based API to allow the clients to discover and lookup data
Java Create Directory - Java Tutorial
Java Create Directory - Java Tutorial   ...;java CreateDirectory Directory: test created Directories... a directory or subdirectories are created. This program also explains the process
Java Create Directory
The following example will show how to Create Directory in Java. Though... is already created" will be displayed. Example of Java Create Directory... directory "Roseindia" in C drive of your computer. If the directory
core java
core java  how to display characters stored in array in core java
Java Telephone directory management system
Java Telephone directory management system Here we are going to create a java application for Telephone directory system. For this, we have accepted ID, name...: import java.io.*; import java.util.*; class Directory implements
core java
core java  basic java interview question
Traversing a file and directory under a directory
and subdirectories are traversed lying under a directory. We can find that, how many files and directories are available within a directory. This is very frequently... describes how you can traverse a directory if it contains directory and files
CORE JAVA
CORE JAVA  CORE JAVA PPT NEED WITH SOURCE CODE EXPLANATION CAN U ??   Core Java Tutorials
core java
core java  i need core java material   Hello Friend, Please visit the following link: Core Java Thanks
Java SDK Directory Structure
Java SDK Directory Structure   ... of command provided by Java compiler. Demo directory - This directory consists... to combine C code into a Java program. Jre directory - When you run
Java Create Directory - Java Tutorial
Java Create Directory - Java Tutorial   ... how to create directory using java program. This program also explains... directory in Java?" Here is the code for creating directory and all non
how to copy file from one directory to another in java with examples
how to copy file from one directory to another in java with examples  how to copy file from one directory to another in java with examples? I want... copy from one directory to another in java. Thanks
core java
core java  Hi, can any one expain me serialization,Deseralization and exterenalization in core java
core java
core java  Hi, can any one exain me the concept of static and dynamic loading in core java
Java file new directory
Java file new directory In this section, you will learn how to create a new directory. Description of code: This is a common task. The java.io.package... an object of File class and specify a directory which you want to create. Then we
core java
core java  how can we justify java technology is robust
Core JAva
Core JAva  how to swap 2 variables without temp in java
Java Directory - Directory and File Listing Example in Java
Java Directory - Directory and File Listing Example in Java... directory. This topic is related to the I/O (input/output... and directory pathnames. This class is an abstract, system-independent view
core java - Java Beginners
core java  i want to get java projects in core java