?
Solved

FileChooser

Posted on 2004-09-21
12
Medium Priority
?
165 Views
Last Modified: 2010-03-31
I have the following button which opens a dialog box of filechooser, can someone tell me how to restrict the user to choose only .xml file?

 Load.addActionListener(new ActionListener()
               {
                     public void actionPerformed(ActionEvent e)
                       {
                              //Handle open button action.
                     if (e.getSource() == Load)
                      {
                         int returnVal = fc.showOpenDialog(GUI.this);
                         if (returnVal == JFileChooser.APPROVE_OPTION)
                           {
                              File file = fc.getSelectedFile();
                             
                              printStats("Loaded successfully: " + file.getName() + "." + "\n");
                           }               
                          }
                     }
               }
             );
0
Comment
Question by:jtcy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 3
12 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12111285
Use a FileFilter
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12111292
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 37

Accepted Solution

by:
zzynx earned 80 total points
ID: 12111297
0
 

Author Comment

by:jtcy
ID: 12111301
Actually, i was just from that page. The example it gives there uses many classes, i was wondering if there is an easier way to do. hm~
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12111312
There are just two classes in the example i mentioned
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12111313
See my previous comment
0
 

Author Comment

by:jtcy
ID: 12111339
Yup, that was exactly what I wanted.
0
 
LVL 37

Expert Comment

by:zzynx
ID: 12111349
Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 12111359
LOL and the difference between that and what i'd already posted is ..?
0
 

Author Comment

by:jtcy
ID: 12120991
Problem Problem~~

Um....apparently the directory that shown when the dialog box first opened is mydocument, how can i set it to be the directory that current class file is from?

p/s: Sorry CEHJ, I only had 20 points here, cant split them, but thanks anyway.

0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question