Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  
 

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
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
Advertisements
Version of directory>apacheds-core dependency
List of Version of directory>apacheds-core dependency
Version of directory-naming>naming-core dependency
List of Version of directory-naming>naming-core dependency
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
Java File Chooser
Java File Chooser Java provides javax.swing.* package that is really... the file system. This has made the user to select file or directory... FileChooser { public static void main(String[] args) { JFileChooser chooser = new
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
core java
core java  how to display characters stored in array in core java
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
core java
core java  basic java interview question
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
core java
core java  i need core java material   Hello Friend, Please visit the following link: Core Java Thanks
CORE JAVA
CORE JAVA  CORE JAVA PPT NEED WITH SOURCE CODE EXPLANATION CAN U ??   Core Java Tutorials
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
core java
core java  Hi, can any one exain me the concept of static and dynamic loading in core java
core java
core java  Hi, can any one expain me serialization,Deseralization and exterenalization in core java
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
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
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 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
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
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
core java - Java Beginners
core java  i want to get java projects in core java
Core Java
Core Java  How to execute cmd command through java?? Give Code of them
core java
core java  write a java program to view product details from product table
core java
core java  its compulsory to save file name and class name is same in java