Problem in File Chooser

Hi all
I open the file chooser in save mode.when a new folder is created using the 'New Folder" icon, to edit the name of the folder I have to click on it to edit it.But I want When I will create a New Folder it must be in edit mode.Can anyone help me to solve the problem.
thanks

On my system thats exactly what happens, maybe this is new for 1.5 (can't rememeber if it used to or not) what version are you using?
Alex

Similar Messages

  • How to find if the user has selected one or many files using a file chooser

    I have a file chooser but want it to return either a file or file array depending on whether more than one file is selected but there doesn't seem to be any way to find out if that is the case or not. I want it to look something like:
                if(fileChooser.getSelectedFile().isDirectory()==true)
                    selectedFile=fileChooser.getCurrentDirectory();
                else if(fileChooser.multipleFilesSelected())
                    fileChooser.getSelectedFiles();//we have more than one file selected
                else   
                    fileChooser.getSelectedFile();    //if we have one file selected
                }am I going about dealing with this in the right way?

    OK, I scoured the API again and found I could avoid the problem altogether by using
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFileChooser.html#isMultiSelectionEnabled()
    and
    http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JFileChooser.html#setFileSelectionMode(int)

  • File file chooser

    Hi.
    I have a JFrame (main frame), that opens another JFrame (popup frame) when u click a button, and in this frame I have a file chooser. The problem is, when i open the file chooser, the popup frame closes (shuts down) while the main frame stais put. How can i prevent the popup frame from closing when clicking the file chooser button?
    here's the code for the file chooser:
    FileChooser fc = new FileChooser();
    int returnVal = fc.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION)
    File file = fc.getSelectedFile();
    String fileName = file.getName();
    JDialog chooseFileFrame = new JDialog();
    Container content2 = chooseFileFrame.getContentPane();
    content2.show();

    Nope. both main frame and popup frame are JFrames. Here's the rest of the code:
    I have a JFrame, fullcreen, contains a button Button_popup, that calls a new JFrame:
    //call file chooser button
    JButton chooseFileButton = new JButton("choose file");
    //popup frame (that closes when i opens the file chooser
    JFrame popUp= new JFrame("Heading");
    popUp.setUndecorated(true);
    popUp.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    popUp.setBounds(0,0,600,500);
    Container content = popUp.getContentPane();
    content.setBackground(Color.white);
    content.add(chooseFileButton);
    adds the file chooser button to my action listener, if hit:
    private void chooseFile()
    if (returnVal == JFileChooser.APPROVE_OPTION)
    File file = fc.getSelectedFile();
    String file= file.getName();
    JDialog fileChooserDialog= new JDialog();
    Container content = fileChooserDialog.getContentPane();
    content.show();
    }

  • File Chooser is displaying names of the Files and Directories as boxes

    Hi All,
    Actually i am working on an application in which i have the requirement to internationalize the File Chooser in All Operating Systems. The application is working properly for all languages on MAC OS, but not working properly for the language Telugu on both the Ubuntu and Windows OS. The main problem is, when i try to open the File Chooser after setting the language to TELUGU all the labels and buttons in the File Chooser are properly internationalized but names of Files and directories in the File Chooser are displaying as boxes.
    So please provide your suggestions to me.
    Thanks in Advance
    Uday.

    I hope this can help you:
    package it.test
    import java.awt.BorderLayout;
    import java.awt.Frame;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.Locale;
    import javax.swing.JButton;
    import javax.swing.JDialog;
    import javax.swing.JFileChooser;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    * @author Alessandro
    public class Test extends JDialog {
         private JFileChooser fc = null;
         private Frame bfcParent = null;
         public Test(Frame parent, boolean modal) {
              super(parent, modal);
              this.bfcParent = parent;
              if (fc == null) {
                   fc = new JFileChooser();
                   fc.setAcceptAllFileFilterUsed(false);
                   fc.setLocale(Locale.ITALIAN);//i think you should use english
                   //these are in telugu
                   UIManager.put("FileChooser.openDialogTitleText", "Open Dialog");
                   UIManager.put("FileChooser.saveDialogTitleText", "Save Dialog");
                   UIManager.put("FileChooser.lookInLabelText", "LookIn");
                   UIManager.put("FileChooser.saveInLabelText", "SaveIn");
                   UIManager.put("FileChooser.upFolderToolTipText", "UpFolder");
                   UIManager.put("FileChooser.homeFolderToolTipText", "HomeFolder");
                   UIManager.put("FileChooser.newFolderToolTipText", "New FOlder");
                   UIManager.put("FileChooser.listViewButtonToolTipText", "View");
                   UIManager.put("FileChooser.detailsViewButtonToolTipText", "Details");
                   UIManager.put("FileChooser.fileNameHeaderText", "Name");
                   UIManager.put("FileChooser.fileSizeHeaderText", "Size");
                   UIManager.put("FileChooser.fileTypeHeaderText", "Type");
                   UIManager.put("FileChooser.fileDateHeaderText", "Date");
                   UIManager.put("FileChooser.fileAttrHeaderText", "Attr");
                   UIManager.put("FileChooser.fileNameLabelText", "Label");
                   UIManager.put("FileChooser.filesOfTypeLabelText", "filesOfType");
                   UIManager.put("FileChooser.openButtonText", "Open");
                   UIManager.put("FileChooser.openButtonToolTipText", "Open");
                   UIManager.put("FileChooser.saveButtonText", "Save");
                   UIManager.put("FileChooser.saveButtonToolTipText", "Save");
                   UIManager.put("FileChooser.directoryOpenButtonText", "Open Directory");
                   UIManager.put("FileChooser.directoryOpenButtonToolTipText", "Open Directory");
                   UIManager.put("FileChooser.cancelButtonText", "Cancel");
                   UIManager.put("FileChooser.cancelButtonToolTipText", "Cancel");
                   UIManager.put("FileChooser.newFolderErrorText", "newFolder");
                   UIManager.put("FileChooser.acceptAllFileFilterText", "Accept");
                   fc.updateUI();
         public int openFileChooser() {
              fc.setDialogTitle("Open File");
              fc.resetChoosableFileFilters();
              int returnVal = 0;
              fc.setDialogType(JFileChooser.OPEN_DIALOG);
              returnVal = fc.showDialog(this.bfcParent, "Apri File");
              //Process the results.
              if (returnVal == JFileChooser.APPROVE_OPTION) {
                   System.out.println("Hai scelto di aprire un file");
              } else {
                   System.out.println("hai annullato l'apertura");
              return returnVal;
         private static void createAndShowGUI() {
              JFrame frame = new JFrame("FileChooser");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              JPanel jp = new JPanel(new BorderLayout());
              JButton openButton = new JButton("Open File");
              final Test test = new Test(frame, true);
              openButton.addActionListener(new ActionListener() {
                   @Override
                   public void actionPerformed(ActionEvent e) {
                        test.openFileChooser();
              openButton.setEnabled(true);
              jp.add(openButton, BorderLayout.AFTER_LAST_LINE);
              //Add content to the window.
              frame.add(jp);
              //Display the window.
              frame.pack();
              frame.setVisible(true);
         public static void main(String[] args) {
              //Schedule a job for the event dispatch thread:
              //creating and showing this application's GUI.
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        //Turn off metal's use of bold fonts
                        createAndShowGUI();
    }bye ale

  • Problem downloading file's from a .php cart

    Having problems downloading files form a php based cart software, but Firefox works fine and also on a PC they download on Explorer fine, is there a setting on Safari to fix this or is there another way around this.

    Welcome to Apple Discussions
    Usually, this type of content doesn't work on Safari due to a PC mentality when coding the site. Here, Firefox etc. are better able to read this code.
    Also, a good reason for having alternate browsers from which to choose.

  • File Chooser - time taken

    Hello All,
    I am working on swings for quiet some time. I am facing a situation while using file chooser. If considered with the Swings perspective it is fine, but if any one of you know some solution or any information on the same please do post it.
    The situation is as follows.
    1) Building a menu bar
    2) 3 of menu items are associated with instances of File chooser objects
    3) The first file chooser instantiation takes around 700-800 ms.
    4) The next 2 file chooser instances takes 50-130 ms.
    So from this it is understandable that the first file chooser is instantiated with the file system vier etc etc and the next two instances uses that and so it is faster.
    I would like to know what is that the Filechooser objects does on instantiation. Also is it possible to reduce the time.
    The main reason for this is in Windows 98 Japanese OS (with 64 MB RAM) this takes around 8-10 seconds.
    Please throw some light on this.
    -Girish~~

    I have had the same problem, and from memory, doing a "new FileChooser();" somewhere in initialization does fix it (at init time expense). I didn't try to fire off a thread to do it on the side, this may work, too.

  • File Chooser to open a document?

    Does anyone know how I can display a file chooser for a directory on the application server in Forms 10g and then open the file?

    The problem I'm trying to solve is that I have several directories on my Windows application server with report files in them and I want the user of the Forms application to be able to access them. I want to restrict access to some of the directories via privileges I define in a database table associated to the user of the Forms application. I was using Windows security and web.show_document instead of the database table approach, but some of my users need to access the Forms application from remote sites (or home) so Windows security won't work in those cases.

  • J file chooser

    Hello everybody,
    i was wondering if anybody can help me with this problem i am having. i am trying to create a jfilechooser that enco-operates the operating systems icons. basically if my program is running on window then it would know the icon to use for different files. i think you are suppose to use FileSystemView but i cant seem to get it to compile. basically i want the same file chooser that you get in softwares such as Microsoft word and so.
    thanks

    Swing uses a concept called a "Look and Feel".
    If you don't specify one, you get the Java default "Metal" look and feel. I'm pretty sure that it's the look and feel that determines what icons are used for files.
    If you want to use the windows look and feel, you would do perform a statement like this at the start of your code, before you display any frames or windows:
    UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    This will make all of your windows look like a Windows app (and it only works ON a Windows operating system).
    To automatically have your code set the Look and Feel relevant to the current platform, call:
    UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName() );
    I think there's a way to have one component (like just the FileChooser) use a specific look and feel, but it isn't really appropriate in general GUI terms, I think, to be inconsistent like that. Alternatively, you could create your own subclass of JFileChooser or FileChooserUI that duplicates the Windows one. For that, I'd recommend you start here:
    http://java.sun.com/docs/books/tutorial/uiswing/components/filechooser.html

  • Combining File Chooser and this MP3 class

    Hello all,
    I was curious if anyone could help me figure out how to get a file to actually load once it is used with this code.
    I'm unfamiliar with how it works and I was hoping for an explanation on it.
    I wasn't sure if I had to have the program recgonize that I would like to load a mp3 or if it just would load it automatically...
    Essentially, I want to be able to load a mp3 if I use the file chooser.
    I can try to clarify my question more if anyone should need it.
    Thank you
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class List extends JPanel
                                 implements ActionListener {
        static private final String newline = "\n";
        JButton openButton, saveButton;
        JTextArea log;
        JFileChooser fc;
        public List() {
            super(new BorderLayout());
            //Create the log first, because the action listeners
            //need to refer to it.
            log = new JTextArea(5,20);
            log.setMargin(new Insets(5,5,5,5));
            log.setEditable(false);
            JScrollPane logScrollPane = new JScrollPane(log);
            //Create a file chooser
            fc = new JFileChooser();
            //Uncomment one of the following lines to try a different
            //file selection mode.  The first allows just directories
            //to be selected (and, at least in the Java look and feel,
            //shown).  The second allows both files and directories
            //to be selected.  If you leave these lines commented out,
            //then the default mode (FILES_ONLY) will be used.
            //fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
           // fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
            //Create the open button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            openButton = new JButton("Open a File...",
                                     createImageIcon("images/Open16.gif"));
            openButton.addActionListener(this);
            //Create the save button.  We use the image from the JLF
            //Graphics Repository (but we extracted it from the jar).
            saveButton = new JButton("Save a File...",
                                     createImageIcon("images/Save16.gif"));
            saveButton.addActionListener(this);
            //For layout purposes, put the buttons in a separate panel
            JPanel buttonPanel = new JPanel(); //use FlowLayout
            buttonPanel.add(openButton);
            buttonPanel.add(saveButton);
            //Add the buttons and the log to this panel.
            add(buttonPanel, BorderLayout.PAGE_START);
            add(logScrollPane, BorderLayout.CENTER);
        public void actionPerformed(ActionEvent e) {
            //Handle open button action.
            if (e.getSource() == openButton) {
                int returnVal = fc.showOpenDialog(List.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    File file = fc.getSelectedFile();
                    //This is where a real application would open the file.
                    log.append("Opening: " + file.getName() + "." + newline);
                } else {
                    log.append("Open command cancelled by user." + newline);
                log.setCaretPosition(log.getDocument().getLength());
            //Handle save button action.
            } else if (e.getSource() == saveButton) {
                int returnVal = fc.showSaveDialog(List.this);
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    File file = fc.getSelectedFile();
                    //This is where a real application would save the file.
                    log.append("Saving: " + file.getName() + "." + newline);
                } else {
                    log.append("Save command cancelled by user." + newline);
                log.setCaretPosition(log.getDocument().getLength());
        /** Returns an ImageIcon, or null if the path was invalid. */
        protected static ImageIcon createImageIcon(String path) {
            java.net.URL imgURL = List.class.getResource(path);
            if (imgURL != null) {
                return new ImageIcon(imgURL);
            } else {
                System.err.println("Couldn't find file: " + path);
                return null;
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("FileChooserDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Create and set up the content pane.
            JComponent newContentPane = new List();
            newContentPane.setOpaque(true); //content panes must be opaque
            frame.setContentPane(newContentPane);
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
    }The mp3 class that I've been playing around with...
    import java.io.BufferedInputStream;
    import java.io.FileInputStream;
    import javazoom.jl.player.Player;
    public class MP3 {
        private String filename;
        private Player player;
        // constructor that takes the name of an MP3 file
        public MP3(String filename) {
            this.filename = filename;
        public void close() { if (player != null) player.close(); }
        // play the MP3 file to the sound card
        public void play() {
            try {
                FileInputStream fis = new FileInputStream(filename);
                BufferedInputStream bis = new BufferedInputStream(fis);
                player = new Player(bis);
            catch (Exception e) {
                System.out.println("Problem playing file " + filename);
                System.out.println(e);
            // run in new thread to play in background
            new Thread() {
                public void run() {
                    try { player.play(); }
                    catch (Exception e) { System.out.println(e); }
            }.start();
    // test client
        public static void main(String[] args) {
            String filename = "C:\\FP\\1.mp3";
            MP3 mp3 = new MP3(filename);
            mp3.play();
    }

    Thanks for the link
    I've been looking over the sections and still confused with the code.
    It's obvious that I have to do something with this portion of the code:
    public void actionPerformed(ActionEvent e) {
        //Handle open button action.
        if (e.getSource() == openButton) {
            int returnVal = fc.showOpenDialog(FileChooserDemo.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
                File file = fc.getSelectedFile();
                //This is where a real application would open the file.
                log.append("Opening: " + file.getName() + "." + newline);
            } else {
                log.append("Open command cancelled by user." + newline);
    }I'm just not sure what.

  • Calling File Chooser from a Button

    I create a new JFileChooser when a button in a main control panel is pushed but when the Chooser pops up it only responds to the keyboard and not to the mouse. How do I get the Chooser to respond to the mouse after it has been opened? (By the way, when I don't use the button to access the Chooser it works fine)
    Thanks.
    Scott

    I have no problem opening the file chooser using the button, the problem is that the file chooser does not listen to the mouse once it is opened. I know the file chooser normally works properly because when I comment out the buttons I can use the same file chooser method that I have created it works fine. Here is the code that I have for these parts:
    JButton getFile = new JButton("Get Files");
              JButton displayImage = new JButton("Display Scans");
              JButton calculate = new JButton("Calculate Rotations");
              panel.add(getFile, BorderLayout.WEST);
              panel.add(displayImage, BorderLayout.CENTER);
              panel.add(calculate, BorderLayout.EAST);     
              frame.getContentPane().add(panel, BorderLayout.CENTER);
              frame.pack();
              frame.setVisible(true);
              getFile.addActionListener(new ActionListener() {      
                   public void actionPerformed(ActionEvent e) {
                   JFileChooser choser2 = new JFileChooser();
                        File[] files = getDirectory(choser2);
    public static File[] getDirectory(JFileChooser fc){
         File[] files;
         files = new File[200];
         File file;
         fc.setMultiSelectionEnabled(true);
         JFrame frame = new JFrame("File Selector");
         int returnVal = fc.showOpenDialog(frame);
         if (returnVal == JFileChooser.APPROVE_OPTION) {
         files = fc.getSelectedFiles();
    } else {
         file = null;
    System.out.println("Open command cancelled by user.");
         return files;
    }

  • AHHHHHH! Multiple open file chooser windows

    Ok, I am going nuts here. I have figured out the problem of getting the data to appear on the same frame that I originally open. The menu at the top has File -> Open. When the user first comes into the form, that is the only thing enabled. I am using a different file opener for this initial opening. Here is why (although, it doesn't fix the problem):
    When the user opens the file, the data appears in the frame. If the user opens another file, the data appears in the frame and another file open chooser window appears even though the users did not select it again. If the user then opens another file, then that is it. If the user then goes to the menu and selects File->Open the file open chooser appears. The user selects a file and the data appears in the frame, but another file open chooser appears. I have had it happen up to 8 times. Now, I have no idea why this is getting called over and over again. It is this that is being called multiple times:
           jMenuFileOpen.addActionListener(new ActionListener()  {
            public void actionPerformed(ActionEvent e) {
              System.out.println("IS THIS THE OPEN THAT IS CALLED OVER AND OVER AND OVER AGAIN");
              jMenuFileOpen_actionPerformed(e);
          });That println is printing each time another file open chooser window appears. I am pulling out my hair trying to figure this one out. The way I am starting this up is this:
      public FDASFrame(File file) {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        inputfile = file;
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      public void setFile (File file) {
        enableEvents(AWTEvent.WINDOW_EVENT_MASK);
        inputfile = file;
        try {
          jbInit();
        catch(Exception e) {
          e.printStackTrace();
      }These methods are in the main frame - FDASFrame. I am wondering if that is the problem. Here is the part of the filechooser that calls the main frame when the file is gotten:
                parent.setFile(file);
                JFrame frame = (JFrame)parent;Has anyone got any ideas to this problem? It might solve the problem of the tables getting duplicate data in them, too, each time a new file is opened.
    Thanks to anyone who has any ideas on how to solve this. I am stumped.
    Allyson

    I have other tests, but this is the one that is messing me up. Here is the whole file chooser (it is really long):
    package sdh;
    import java.io.*;
    //import java.io.File;
    //import java.io.FileInputStream;
    //import java.io.BufferedReader;
    //import java.io.InputStreamReader;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    //import javax.swing.filechooser.*;
    import java.util.*;
    import org.w3c.dom.Document;
    import org.w3c.dom.*;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.DocumentBuilder;
    import org.xml.sax.SAXException;
    import org.xml.sax.SAXParseException;
    public class FileChooserFrame extends JFrame {
      static File file;
      String tempfile, wholeline;
      PrintWriter textfile;
      Hashtable QualityCodes = new Hashtable();
      Hashtable DistanceCodes = new Hashtable();
      Hashtable ScreeningCodes = new Hashtable();
      Hashtable ObjectCodes = new Hashtable();
      Hashtable WeatherCodes = new Hashtable();
      Hashtable StabilityCodes = new Hashtable();
        public FileChooserFrame(FDASFrame parent, String filetype) {
          //Create a file chooser
          if (filetype.equals("Open")) {
            final JFileChooser fc = new JFileChooser();
            fc.addChoosableFileFilter(new xmlExtensionFileFilterClass());
            fc.addChoosableFileFilter(new fsExtensionFileFilterClass());
            fc.addChoosableFileFilter(new sdmExtensionFileFilterClass());
            fc.addChoosableFileFilter(new rcvExtensionFileFilterClass());
            fc.addChoosableFileFilter(new txtExtensionFileFilterClass());
            fc.setAcceptAllFileFilterUsed(false);
            int returnVal = fc.showOpenDialog(FileChooserFrame.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              file = fc.getSelectedFile();
              String ext = fc.getSelectedFile().toString().substring(fc.getSelectedFile().toString().indexOf(".")+1);
              /** @todo FDASFrame comes up each time you open a file - does not put data in the one already up */
    //        FDASFrame fdas = FDASFrame.getInstance();
    //          JFrame frame = new FDASFrame(file);
              if (ext.equals("txt")) {
                parent.setFile(file);
                JFrame frame = parent;
    //            JFrame frame = new FDASFrame(file);
                try {
                  String v;
                  FileInputStream f = new FileInputStream(file);
                  BufferedReader b = new BufferedReader(new InputStreamReader(f));
                  if ((v = b.readLine()) != null) {
                    StringTokenizer t = new StringTokenizer(v,"|");
                    if (t.nextElement().equals("FH")) {
                      frame.setTitle(t.nextElement().toString() + " Version " + t.nextElement().toString());
                catch(Exception ee) {
                  ee.printStackTrace();
                frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                    System.exit(0);
                frame.setVisible(true);
              else if (ext.equals("xml") || ext.equals("sdm") || ext.equals("sdm.xml")) {
                // Hashtable for WeatherCodes for setups
                WeatherCodes.put("Clear","4");
                WeatherCodes.put("Pt. Cloudy","3");
                WeatherCodes.put("Cloudy","2");
                WeatherCodes.put("Hazy/Foggy","1");
                WeatherCodes.put("","0");
                // Hashtable for StabilityCodes for setups
                StabilityCodes.put("Good","3");
                StabilityCodes.put("Fair","2");
                StabilityCodes.put("Poor","1");
                StabilityCodes.put("","0");
                // Hashtable for ObjectCodes for objects
                ObjectCodes.put("Land","9");
                ObjectCodes.put("Mountain","8");
                ObjectCodes.put("Water","7");
                ObjectCodes.put("Dense Trees","6");
                ObjectCodes.put("Thin Trees","5");
                ObjectCodes.put("Building","4");
                ObjectCodes.put("Tower","3");
                ObjectCodes.put("Pole","2");
                ObjectCodes.put("Antenna","1");
                ObjectCodes.put("","0");
                // Hashtable for ScreeningCodes for objects
                ScreeningCodes.put("High","4");
                ScreeningCodes.put("Doubtful","3");
                ScreeningCodes.put("Intermediate","2");
                ScreeningCodes.put("Photo","1");
                ScreeningCodes.put("","0");
                // Hashtable for DistanceCodes for objects
                DistanceCodes.put("Feet","3");
                DistanceCodes.put("Meters","2");
                DistanceCodes.put("NMI","1");
                DistanceCodes.put("","0");
                // Hashtable for QualityCodes for points
                QualityCodes.put("High","3");
                QualityCodes.put("Medium","2");
                QualityCodes.put("Low","1");
                QualityCodes.put("","0");
                try{
                  tempfile = fc.getCurrentDirectory().toString() + "\\Tempxml.txt";
                  textfile = new PrintWriter(new BufferedWriter(new FileWriter(tempfile)));
                catch(Exception ee) {
                  ee.printStackTrace();
                try {
                  DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
                  DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                  Document doc = docBuilder.parse(file);
                  // normalize text representation
                  doc.getDocumentElement ().normalize ();
                  NodeList rootlist = doc.getElementsByTagName("root");
                  NodeList FHList = null;
                  Node rootnode = rootlist.item(0);
                  if(rootnode.getNodeType() == Node.ELEMENT_NODE){
                    Element FHElement = (Element)rootnode;
                    FHList = FHElement.getElementsByTagName("FileHeader");
                    Element FHeElement = (Element)FHList.item(0);
                    NodeList textFHList = FHeElement.getChildNodes();
                    wholeline = ((Node)textFHList.item(0)).getNodeValue().trim();
                  Node FHnode = FHList.item(0);
                  if(FHnode.getNodeType() == Node.ELEMENT_NODE){
                    Element FHelemElement = (Element)FHnode;
                    NodeList IDList = FHelemElement.getElementsByTagName("Identifier");
                    Element IDElement = (Element)IDList.item(0);
                    NodeList textIDList = IDElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textIDList.item(0)).getNodeValue().trim();
                    NodeList VerList = FHelemElement.getElementsByTagName("Version");
                    Element VerElement = (Element)VerList.item(0);
                    NodeList textVerList = VerElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textVerList.item(0)).getNodeValue().trim();
                    textfile.println(wholeline);
                  wholeline = "";
                  NodeList siteList = doc.getElementsByTagName("Site");
                  Element siteElement = (Element)siteList.item(0);
                  NodeList textsiteList = siteElement.getChildNodes();
                  wholeline = ((Node)textsiteList.item(0)).getNodeValue().trim();
                  Node sitenode = siteList.item(0);
                  if (sitenode.getNodeType() == Node.ELEMENT_NODE) {
                    Element siteelemElement = (Element) sitenode;
                    NodeList SiteNameList = siteelemElement.getElementsByTagName("Site_Name");
                    Element SiteNameElement = (Element)SiteNameList.item(0);
                    NodeList textSiteNameList = SiteNameElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textSiteNameList.item(0)).getNodeValue().trim();
                    NodeList EquipTypeList = siteelemElement.getElementsByTagName("Equipment_Type");
                    Element EquipTypeElement = (Element)EquipTypeList.item(0);
                    NodeList textEquipTypeList = EquipTypeElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textEquipTypeList.item(0)).getNodeValue().trim();
                    NodeList LatList = siteelemElement.getElementsByTagName("Site_Latitude");
                    Element LatElement = (Element)LatList.item(0);
                    NodeList textLatList = LatElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textLatList.item(0)).getNodeValue().trim();
                    NodeList LonList = siteelemElement.getElementsByTagName("Site_Longitude");
                    Element LonElement = (Element)LonList.item(0);
                    NodeList textLonList = LonElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textLonList.item(0)).getNodeValue().trim();
                    NodeList GtFPList = siteelemElement.getElementsByTagName("Ground_to_Focal_Point");
                    Element GtFPElement = (Element)GtFPList.item(0);
                    NodeList textGtFPList = GtFPElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textGtFPList.item(0)).getNodeValue().trim();
                    NodeList SiteElvList = siteelemElement.getElementsByTagName("Site_Elevation");
                    Element SiteElvElement = (Element)SiteElvList.item(0);
                    NodeList textSiteElvList = SiteElvElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textSiteElvList.item(0)).getNodeValue().trim();
                    NodeList UCAList = siteelemElement.getElementsByTagName("Upper_Coverage_Angle");
                    Element UCAElement = (Element)UCAList.item(0);
                    NodeList textUCAList = UCAElement.getChildNodes();
                    wholeline = wholeline + "|" + ((Node)textUCAList.item(0)).getNodeValue().trim();
                  textfile.println(wholeline);
                  NodeList listOfSetups = doc.getElementsByTagName("Setup");
                  int totalSetups = listOfSetups.getLength();
                  for (int s = 0; s < totalSetups; s++) {
                    wholeline = "";
                    Node Setupnode = listOfSetups.item(s);
                    Element setupElement = (Element)listOfSetups.item(s);
                    NodeList textsetupList = setupElement.getChildNodes();
                    wholeline = ((Node)textsetupList.item(0)).getNodeValue().trim();
                    if (Setupnode.getNodeType() == Node.ELEMENT_NODE) {
                      Element setuplistElement = (Element)Setupnode;
                      NodeList SurveyorList = setuplistElement.getElementsByTagName("Surveyor");
                      Element SurveyorElement = (Element)SurveyorList.item(0);
                      NodeList textSurveyorList = SurveyorElement.getChildNodes();
                      wholeline = wholeline + "|" + ((Node)textSurveyorList.item(0)).getNodeValue().trim();
                      NodeList Azi2FPList = setuplistElement.getElementsByTagName("Azimuth_to_Focal_Point");
                      Element Azi2FPElement = (Element)Azi2FPList.item(0);
                      NodeList textAzi2FPList = Azi2FPElement.getChildNodes();
                      wholeline = wholeline + "|" + ((Node)textAzi2FPList.item(0)).getNodeValue().trim();
                      NodeList Dist2FPList = setuplistElement.getElementsByTagName("Dist_to_Focal_Point");
                      Element Dist2FPElement = (Element)Dist2FPList.item(0);
                      NodeList textDist2FPList = Dist2FPElement.getChildNodes();
                      wholeline = wholeline + "|" + ((Node)textDist2FPList.item(0)).getNodeValue().trim();
                      NodeList Hi2FPList = setuplistElement.getElementsByTagName("Hi_to_Focal_Point");
                      Element Hi2FPElement = (Element)Hi2FPList.item(0);
                      NodeList textHi2FPList = Hi2FPElement.getChildNodes();
                      wholeline = wholeline + "|" + ((Node)textHi2FPList.item(0)).getNodeValue().trim();
                      NodeList WeatherList = setuplistElement.getElementsByTagName("Weather");
                      Element WeatherElement = (Element)WeatherList.item(0);
                      NodeList textWeatherList = WeatherElement.getChildNodes();
                      wholeline = wholeline + "|" + (String)WeatherCodes.get(((Node)textWeatherList.item(0)).getNodeValue().trim());
                      NodeList StabilityList = setuplistElement.getElementsByTagName("Stability");
                      Element StabilityElement = (Element)StabilityList.item(0);
                      NodeList textStabilityList = StabilityElement.getChildNodes();
                      wholeline = wholeline + "|" + (String)StabilityCodes.get(((Node)textStabilityList.item(0)).getNodeValue().trim());
                      Element objectElement = (Element)Setupnode;
                      NodeList textobjectList = objectElement.getElementsByTagName("Object");
                      int TotalObjs = textobjectList.getLength();
                      if (TotalObjs == 0) {
                        textfile.print(wholeline);
                      else {
                        textfile.println(wholeline);
                      for (int j = 0; j < TotalObjs; j++) {
                        wholeline = "";
                        Node Objectnode = textobjectList.item(j);
                        Element objectelement = (Element)textobjectList.item(j);
                        NodeList textObjList = objectelement.getChildNodes();
                        wholeline = ((Node)textObjList.item(0)).getNodeValue().trim();
                        if (Objectnode.getNodeType() == Node.ELEMENT_NODE) {
                          Element objElement1 = (Element)Objectnode;
                          NodeList textobjList1 = objElement1.getElementsByTagName("Object_Type");
                          Element objelement1 = (Element)textobjList1.item(0);
                          NodeList textOList1 = objelement1.getChildNodes();
                          wholeline = wholeline + "|" + (String)ObjectCodes.get(((Node)textOList1.item(0)).getNodeValue().trim());
                          Element objElement2 = (Element)Objectnode;
                          NodeList textobjList2 = objElement2.getElementsByTagName("Screening_Type");
                          Element objelement2 = (Element)textobjList2.item(0);
                          NodeList textOList2 = objelement2.getChildNodes();
                          wholeline = wholeline + "|" + (String)ScreeningCodes.get(((Node)textOList2.item(0)).getNodeValue().trim());
                          Element objElement3 = (Element)Objectnode;
                          NodeList textobjList3 = objElement3.getElementsByTagName("Distance_Units");
                          Element objelement3 = (Element)textobjList3.item(0);
                          NodeList textOList3 = objelement3.getChildNodes();
                          wholeline = wholeline + "|" + (String)DistanceCodes.get(((Node)textOList3.item(0)).getNodeValue().trim());
                          Element PointElement = (Element)Objectnode;
                          NodeList textPointList = PointElement.getElementsByTagName("Point");
                          int TotalPts = textPointList.getLength();
                          textfile.println(wholeline);
                          for (int k = 0; k < TotalPts; k++) {
                            wholeline = "";
                            Node Pointnode = textPointList.item(k);
                            Element pointelement = (Element)textPointList.item(k);
                            NodeList textPList = pointelement.getChildNodes();
                            wholeline = ((Node)textPList.item(0)).getNodeValue().trim();
                            if (Pointnode.getNodeType() == Node.ELEMENT_NODE) {
                              Element pointElement1 = (Element)Pointnode;
                              NodeList textpointList1 = pointElement1.getElementsByTagName("Azimuth");
                              Element pointelement1 = (Element)textpointList1.item(0);
                              NodeList textPList1 = pointelement1.getChildNodes();
                              wholeline = wholeline + "|" + ((Node)textPList1.item(0)).getNodeValue().trim();
                              Element pointElement2 = (Element)Pointnode;
                              NodeList textpointList2 = pointElement2.getElementsByTagName("Vertical_Angle");
                              Element pointelement2 = (Element)textpointList2.item(0);
                              NodeList textPList2 = pointelement2.getChildNodes();
                              wholeline = wholeline + "|" + ((Node)textPList2.item(0)).getNodeValue().trim();
                              Element pointElement3 = (Element)Pointnode;
                              NodeList textpointList3 = pointElement3.getElementsByTagName("Distance");
                              Element pointelement3 = (Element)textpointList3.item(0);
                              NodeList textPList3 = pointelement3.getChildNodes();
                              wholeline = wholeline + "|" + ((Node)textPList3.item(0)).getNodeValue().trim();
                              Element pointElement4 = (Element)Pointnode;
                              NodeList textpointList4 = pointElement4.getElementsByTagName("Quality");
                              Element pointelement4 = (Element)textpointList4.item(0);
                              NodeList textPList4 = pointelement4.getChildNodes();
                              wholeline = wholeline + "|" + (String)QualityCodes.get(((Node)textPList4.item(0)).getNodeValue().trim());
                            textfile.println(wholeline);
                  textfile.close();
                  File f = new File(tempfile);
    //              JFrame frame = new FDASFrame(f);
                  parent.setFile(f);
                  JFrame frame = parent;
                  if(FHnode.getNodeType() == Node.ELEMENT_NODE){
                    Element FHelemElement = (Element)FHnode;
                    NodeList IDList = FHelemElement.getElementsByTagName("Identifier");
                    Element IDElement = (Element)IDList.item(0);
                    NodeList textIDList = IDElement.getChildNodes();
                    NodeList VerList = FHelemElement.getElementsByTagName("Version");
                    Element VerElement = (Element)VerList.item(0);
                    NodeList textVerList = VerElement.getChildNodes();
                    frame.setTitle(((Node)textIDList.item(0)).getNodeValue().trim() + " Version " + ((Node)textVerList.item(0)).getNodeValue().trim());
                  frame.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                     System.exit(0);
                  frame.setVisible(true);
                catch(Exception ee) {
                  ee.printStackTrace();
          else if (filetype.equals("Save")) {
            final JFileChooser fc = new JFileChooser();
            fc.setFileFilter(new saveExtensionFileFilterClass());
            fc.setAcceptAllFileFilterUsed(false);
            int returnVal = fc.showSaveDialog(FileChooserFrame.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              file = fc.getSelectedFile();
          else if (filetype.equals("Log")) {
            final JFileChooser fc = new JFileChooser();
            fc.setFileFilter(new logExtensionFileFilterClass());
            fc.setAcceptAllFileFilterUsed(false);
            int returnVal = fc.showSaveDialog(FileChooserFrame.this);
            if (returnVal == JFileChooser.APPROVE_OPTION) {
              file = fc.getSelectedFile();
        public static File getFile() {
          return file;
    }I know I should split this out and I will sometime, but for now, this is the way the code is.
    I think the reason that nothing is coming up is that all my work is done in jbInit(). I don't want to post that code, but I will if needed. So, if I can only call it once, then how do I get the rest of it to run? Maybe I am going about this all wrong. But if it is not in jbInit(), then how does it get called? I guess now, I am confused.
    Thanks for the help.
    Allyson

  • How to start Windows file chooser?

    I don't mean the AWT file chooser FileDialog.
    I have seen a Java application use the new Windows file chooser which is used in Windows 2000 and Windows XP. On the left side it has a large bar.
    How can I start that new Windows file chooser?

    Hello, my name is Silvia.
    I'd like to know how to hide that large bar on the left side in the file chooser (jdk 1.4.x).
    My problem is about truncated names like 'My Document' (it is shown as 'My Docum...') or 'My Network Place' (it is shown as 'My Networ...').
    Should I extend the JFileChooser class? What is the name of 'the large bar on the left side in the file chooser'?
    Thank you very much, Silvia.

  • Swing file chooser

    Hi.
    I have a JFrame (main frame), that opens another JFrame (popup frame) when u click a button, and in this frame I have a file chooser. The problem is, when i open the file chooser, the popup frame closes (shuts down) while the main frame stais put. How can i prevent the popup frame from closing when clicking the file chooser button?
    here's the code for the file chooser:
    FileChooser fc = new FileChooser();
    int returnVal = fc.showOpenDialog(this);
    if (returnVal == JFileChooser.APPROVE_OPTION)
    File file = fc.getSelectedFile();
    String fileName = file.getName();
    JDialog chooseFileFrame = new JDialog();
    Container content2 = chooseFileFrame.getContentPane();
    content2.show();

    yup.
    I have a JFrame, fullcreen, contains a button Button_popup, that calls a new JFrame:
    //call file chooser button
    JButton chooseFileButton = new JButton("choose file");
    //popup frame (that closes when i opens the file chooser
    JFrame popUp= new JFrame("Heading");
    popUp.setUndecorated(true);
    popUp.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
    popUp.setBounds(0,0,600,500);
    Container content = popUp.getContentPane();
    content.setBackground(Color.white);
    content.add(chooseFileButton);
    adds the file chooser button to my action listener, if hit:
    private void chooseFile()
    if (returnVal == JFileChooser.APPROVE_OPTION)
    File file = fc.getSelectedFile();
    String file= file.getName();
    JDialog fileChooserDialog= new JDialog();
    Container content = fileChooserDialog.getContentPane();
    content.show();
    }

  • Hi iam unable to add file chooser

    hello,
    iam trying to add file chooser for application but getting following error..
    regards,
    sam
    401)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java:52
    at java.lang.SecurityManager.checkPropertyAccess(SecurityManager.jav
    76)
    at java.lang.System.getProperty(System.java:626)
    at java.io.Win32FileSystem.getUserPath(Win32FileSystem.java:295)
    at java.io.Win32FileSystem.resolve(Win32FileSystem.java:311)
    at java.io.File.getAbsolutePath(File.java:471)
    at sun.awt.shell.Win32ShellFolder2.<init>(Win32ShellFolder2.java:213
    at sun.awt.shell.Win32ShellFolder2.listFiles(Win32ShellFolder2.java:
    at sun.awt.shell.ShellFolder.listFiles(ShellFolder.java:100)
    at sun.awt.shell.Win32ShellFolderManager2.get(Win32ShellFolderManage
    ava:191)
    at sun.awt.shell.ShellFolder.get(ShellFolder.java:230)
    at javax.swing.plaf.metal.MetalFileChooserUI.updateUseShellFolder(Me
    ileChooserUI.java:417)
    at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(Metal
    ChooserUI.java:188)
    at javax.swing.plaf.basic.BasicFileChooserUI.installUI(BasicFileChoo
    I.java:135)
    at javax.swing.plaf.metal.MetalFileChooserUI.installUI(MetalFileChoo
    I.java:123)
    at javax.swing.JComponent.setUI(JComponent.java:624)
    at javax.swing.JFileChooser.updateUI(JFileChooser.java:1755)
    at javax.swing.JFileChooser.setup(JFileChooser.java:366)
    at javax.swing.JFileChooser.<init>(JFileChooser.java:332)
    at javax.swing.JFileChooser.<init>(JFileChooser.java:285)
    at Sampath.init(Sampath.java:111)
    at sun.applet.AppletPanel.run(AppletPanel.java:354)
    at java.lang.Thread.run(Thread.java:566)

    Hello,
    Unless you sign your applet, I don't think the security manager will authorize access to the hard drive.
    Search this forum for "applet" + "JFileChooser" and you'll find many posts of people facing the same problem.

  • File Chooser + Loops

    I've been at this sadly for almost 8 hours now....here is what my program is suppose to accomplish....yet it's not and I cannot for the life of me figure out what to do
    1. Prompt the user to browse to a file.
    If the user browses to a file, selects it and hits open it will open a JTextArea displaying the text within the file. When the JTextArea closes the program should terminate.
    2. When the user is prompted and selects CANCEL a "catch" statement should then throw a pop-up window telling the user they they did not select a file. When they aknowledge the pop-up they should be prompted to browse to a file. If they continue to hit cancel it should continue to run them through the loop. HOWEVER, when they finally browse and select a file it should work just as I stated in #1.
    3. The same explaination as #2 goes for the catch statement when a users file is unable to be found.
    I have exhausted all online resources, my book, my teacher to try and find how to properly formulate my code and loop to work correctly. This is the best I have come up with.
    It does everything except for one major problem. When a user finally does select a file after running through the loop, it will not display anything.
    Someone please...break this down for me or even edit my code so that I can visually see what and where things go.....I know the reason nothing is being displayed is because in the catch statement I am not stating what to do after the user selects a file....but I dont even think i'm doing this right....sigh
    //  DisplayFile.java       Author: Lewis/Loftus
    //  Demonstrates the use of a file chooser and a text area.
    import java.util.Scanner;
    import java.io.*;
    import javax.swing.*;
    public class FileDisplay
       public static void main (String[] args) throws IOException
          JFrame frame = new JFrame ("Display File");
          frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
          JTextArea ta = new JTextArea (20, 30);
          JFileChooser chooser = new JFileChooser();
          int status = chooser.showOpenDialog (null);
         do
             try {
                File  file = chooser.getSelectedFile();
                Scanner scan = new Scanner(file);
                String info = "";
                while (scan.hasNext())
                info +=scan.NextLine() + "\n";
                 ta.setText (info);
              catch (FileNotFoundException exception)
                   JOptionPane.showMessageDialog (null, "File could not be found, click ok to try again");
    chooser.showOpenDialog (null);
              catch (NullPointerException exception)
                   JOptionPane.showMessageDialog (null, "You did not choose a file, click ok to try again");
    chooser.showOpenDialog (null);
         } while (status !=JFileChooser.APPROVE_OPTION);
          frame.getContentPane().add (ta);
          frame.pack();
          frame.setVisible(true);
    }

    No. That's not an assignment statement. To change the value of the variable "status", you need an assignment statement. If being told that isn't helpful, then I suggest you go and talk to your teacher. You won't be able to get anywhere here by asking questions like that.

Maybe you are looking for

  • HTTP 500 error while opening pdf report in Workspace

    Hi all, i have a HFM - FDM - Financial Reporting 11.1.1.3 installation at a custommer that is working fine. Except for the fact that when i open a report (doesn't matter if it's from the studio or workspace) in pdf it gives an HTTP 500 internal serve

  • USE of CF 6004 with HP IPAQ 5550

    Hello Could someone tell whether we could use CF-6004 with HP IPAQ 5550 PDA? as it looks that the size of the card is a bit larger to fit in the memory card slot. thanks Sam 

  • FDF in browser without toolbar

    Hi, The following link shows another with a similar problem. http://adobe.groupbrowser.com/t100813.html I apologize if this isn't posted in the right place. I have set the #toolbar=0 parameter in the /F parameter of the FDF document. Eg. /F(http://lo

  • Using presentation variables selected in dashboard prompt in query builder

    In dashboard prompt I have made four dropdowns(have four presentation variables) and based on these values selected,can the Query Builder generate dynamic reports based on the presentation variables selected? I will provide the link(i.e Link of BI pu

  • How to move a region to a specific region automatically

    hi everyone, I m using apex 4.o, I have a tree on page zero so its appears on every page and its a hide and show template on my other page i have a another region with report .now when i open the tree the page region should move to right and when i c