File chooser internationalization problem

Hello All!
I'm trying to have Armenian texts on Swing components.
        Locale hay = new Locale("hy", "HY");
        Locale.setDefault(hay);
        UIManager.put("FileChooser.openDialogTitleText", "Բացել");
        UIManager.put("FileChooser.saveDialogTitleText", "Պահել");
        UIManager.put("FileChooser.lookInLabelText", "Փնտրել");
        UIManager.put("FileChooser.saveInLabelText", "Պահել");
        UIManager.put("FileChooser.upFolderToolTipText", "Մի Մակարդակ Վերև");
        UIManager.put("FileChooser.homeFolderToolTipText", "Աշխատաէկրան");
        UIManager.put("FileChooser.newFolderToolTipText", "Ստեղծել Նոր Պանակ");
        UIManager.put("FileChooser.listViewButtonToolTipText", "Ցուցակ");
        UIManager.put("FileChooser.detailsViewButtonToolTipText", "Մանրամասներ");
        UIManager.put("FileChooser.fileNameHeaderText", "Անուն");
        UIManager.put("FileChooser.fileSizeHeaderText", "Ծավալ");
        UIManager.put("FileChooser.fileTypeHeaderText", "Տեսակ");
        UIManager.put("FileChooser.fileDateHeaderText", "Փոփոխման Ամսաթիվ");
        UIManager.put("FileChooser.fileAttrHeaderText", "Հատկանիշներ");
        UIManager.put("FileChooser.fileNameLabelText", "Նշոցի Անուն");
        UIManager.put("FileChooser.filesOfTypeLabelText", "Նշոցների Տեսակներ");
        UIManager.put("FileChooser.openButtonText", "Բացել");
        UIManager.put("FileChooser.openButtonToolTipText", "Բացել Ընտրված Նշոցը");
        UIManager.put("FileChooser.saveButtonText", "Պահել");
        UIManager.put("FileChooser.saveButtonToolTipText", "Պահել Ընտրված Նշոցը");
        UIManager.put("FileChooser.directoryOpenButtonText", "Պահել");
        UIManager.put("FileChooser.directoryOpenButtonToolTipText", "Պահել Ընտրված Նշոցը");
        UIManager.put("FileChooser.cancelButtonText", "Դադարեցնել");
        UIManager.put("FileChooser.cancelButtonToolTipText", "Դադարեցնել Նշոց Ընտրման Երկխոսության Պատուհանը");
        UIManager.put("FileChooser.newFolderErrorText", "Նոր Պահոցի Ստեղծման Սխալ");
        UIManager.put("FileChooser.acceptAllFileFilterText", "Բոլոր Նշոցներ");Only DialogTitleText is working. And if I'm trying to internationalize other Swing components: buttons and so on, the only problem with JFrame title is.
I'm working on WindowsXP, and java version is 1.6.0_17.
Thanks in advance!
Astghik

The quick answer:
You can't use JFileChooser unless you sign the applet.

Similar Messages

  • 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

  • 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

  • File Ext Openning problem!

    I have searched all over my mac high and low and can not figure out out to make the default file ext. open in the correct program example .doc, .eps, .psd, .pdf, .indd I can only right click and have it open in program if I double click all files open in preview. This problem occurred after I installed snow leopard, please help me

    Select a file, choose File -> Get Info, set the app you want in the Open With pop-up and click the Change All button.

  • Time machine: An error occurred while copying files. The problem could be temporary. If the problem persists, use Disk Utility to repair your backup disk.

    Time machine backups are failing. I've followed the instructions I found on the Time Machine troubleshooting page (http://pondini.org/TM/Troubleshooting.html) but have gotten to where I don't know what to do next.
    Sequence of events:
    The main error message is always:
    An error occurred while copying files. The problem could be temporary. If the problem persists, use Disk Utility to repair your backup disk.
    Yesterday, I opened Disk Utility and verified the disk. Got this error:
    Error: This disk needs to be repaired using the Recovery HD. Restart your computer, holding down the Command key and the R key until you see the Apple logo. When the OS X Utilities window appears, choose Disk Utility.
    I ran Disk Utility and repaired the hard drive. Then I manually started the backup before going to bed, figuring it was going to take a long time to run. When I got up this morning, the backup had failed with the same "could be temporary" error. I checked the log, which says:
    Starting manual backup
    Attempting to mount network destination URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Mounted network destination at mount point: /Volumes/Tery Griffin's Time Capsule using URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Disk image /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle mounted at: /Volumes/Time Machine Backups
    Backing up to: /Volumes/Time Machine Backups/Backups.backupdb
    Event store UUIDs don't match for volume: Macintosh HD
    Error: (-36) Applying backup protections to /Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC
    Error: (5) setxattr for key:com.apple.backupd.SnapshotStartDate path:/Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC size:17
    Error: (5) setxattr for key:com.apple.backupd.SnapshotState path:/Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/ABB10CF2-F041-4DE5-B6AE-3C228B59ADCC size:2
    Deep event scan at path:/ reason:must scan subdirs|new event db|
    Finished scan
    Found 145601 files (11.88 GB) needing backup
    16.1 GB required (including padding), 620.77 GB available
    Copied Zero KB of 11.88 GB, 0 of 145601 items
    Copied 0 files (Zero KB) from volume Macintosh HD.
    Copy stage failed with error:11
    Backup failed with error: 11
    Ejected Time Machine disk image: /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle
    Ejected Time Machine network volume.
    Starting automatic backup
    Attempting to mount network destination URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Mounted network destination at mount point: /Volumes/Tery Griffin's Time Capsule using URL: afp://Tery%20Griffin;[email protected]/Tery%20Griffin's%20Time%20Ca psule
    Disk image /Volumes/Tery Griffin's Time Capsule/Tery Griffin’s Computer (44).sparsebundle mounted at: /Volumes/Time Machine Backups
    Backing up to: /Volumes/Time Machine Backups/Backups.backupdb
    Event store UUIDs don't match for volume: Macintosh HD
    Error: (-36) Applying backup protections to /Volumes/Time Machine Backups/Backups.backupdb/Tery Griffin’s Computer (44)/2014-03-05-201742.inProgress/9F8E7957-9C50-49C3-8314-880E5203E3D9
    Error: (5) setxattr for key:com.apple.backupd.SnapshotStartDate path:/Volumes/Time Machine Backups/
    Does anyone know what the problem is here and what I should do?
    Thanks,
    Tery

    You have repaired your boot drive (which is good) but have you repaired your time machine drive?  I don't own a Time Capsule so I don't know if disk utility can operate on it.  If it can, you should repair it as well.  You may need to erase it and start a new backup.  That happens to time machine volumes from time to time and is why people who are serious about their data never rely on a single source of backup.

  • 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 - 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

  • Hi, since i put some mp4 video or DVD files on my external hard drives final cut prox won't recognize my hard drives, i move all the video files and the problem still exist. somebody have the solution

    Hi, since i put some mp4 video or DVD files on my external hard drives final cut prox won't recognize my hard drives, i move all the video files and the problem still exist. somebody have the solution

    Did the back and forth between PC and Mac file systems screw up my files somehow?
    Yes. Unfortunately the move has almost certainly caused the loss of the resource data that would have been (invisibly) attached to those files.
    By adding a specific .mov extension after the fact you will have helped the Mac correctly identify the file type / asscoiations but also significantly you will have physically changed the filename eg from "clip" to "clip.mov". This means that when you come to reconnect the media in FCP , then FCP will be looking for files that no longer exist at the given path eg when specifically looking for our example clip called "clip" of course it won't find it.
    Try this as a test... first remove the ".mov" extension from one or more of the clips, select those clips and press Cmd-Opt-I to open an Info window for the selection. You'll see an "Open with:" popup and in that popup you should choose QuickTime Player (if its a Unix Executable then it will initially list Terminal as the appropriate app, you have to choose Other... then in the open dialog choose Enable > All Applications and then navigate to and select the Quicktime Player app as the appropriate app). After you've done that restart FCP and see if you can now reconnect to those clips.

  • 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.

Maybe you are looking for

  • IMessage's not sending - no 'delivered' or 'error' notifications

    I have iMessage configured to work with my Apple ID and phone number. I can receive iMessages, but when I try to send a message in return it just sits there all day, without the 'delivered' notification underneath the message, or the red exclamation

  • How to  populate the List for  second LOV using bean

    hi how can i pass selected value of LOV to second LOV using bean,so can have cascading lov,my lov are as followss,am in jdeveloper 11.1.1.6.0 <td width="50%" height="22"><af:selectOneChoice                                         label="#{bindings.Lu

  • Computer to Watch TV Confined to Bed

    I'm confined to bed for at least six months. I've got my iBook G4 on the hospital table but it isn't powerful enough to watch most tv shows, i.e. Dancing with the Stars. In the evening Hubby connects the mac to our standard definition tv so we can wa

  • How to create an interactive pdf, hyperlinking text to a video on a usb drive?

    Creating an interactive pdf in InDesign CS6, hyperlinking text to a video.  Both pdf and video placed on a usb thumbdrive.  When clicking link on Mac a warning box came up, but after clicking Allow the video played fine.  On PC the warning box also c

  • Will this work with the titanium ? (pic)

    Hey guys planning to buy a new pioneer 89. I want to connect it to my titanium card. so i plan to connect it using analog RCA to mini jack. What I want to know is will the BD/DVD multi in work with the titaniums analog ports?