JFileChooser and JApplet

Hi,
I have some trouble with accessing JFileChooser from JApplet. Executing showOpenDialog() method really does nothing?
   JFileChooser fc = new JFileChooser();
    if (fc.showOpenDialog(getParent()) == JFileChooser.APPROVE_OPTION) {
      //some code regarding file selection.
    }Appropriate selection window doesn't appear
Thanks for some help
Krzysztof

The original post was from august last year, so I think maybe the problem is solved by now, Marco...

Similar Messages

  • JFileChooser and FileFilters

    I have the following problem:;
    I have a JFileChooser and I attached a FileFilter to it, which only allows files with the extension *.in and *.inx. Everything works well - only files with these extensions are shown in the Dialog.
    But as a user I expect, that it is not a fault if I only type in the name of the file, because I expect the programme to add the extension automatically. For example in an OpenDialog, the user sees the file test.inx and the types in "test", because he/she thinks that the extension will be added.
    This is not the case...and which is even worse, the call of fileChooser.getSelectedFiles() will return an empty array. Hence there is no possibility for the programme to add the file extension.....
    How can solve this problem?? What is my mistake?? I cannot image that Swing is not able to do this, because this common FileDialog behaviour....
    I thank everybody who tries to help me...

    The quick and dirty workaround would be to create a "Save" dialog (setDialogType method), set the Button texts to whatever you want, the same for title. When the dialog returns, you can check the file (getSelectedFile()), and if it does not exist, try the same name with the extension(s).

  • Very Very Urgent(JFileChooser in JApplet)

    Hi friends,
    I am not able to implement the JFileChooser in JApplet.Is there any
    way that I can do the same thing.Also is there any way that I can develop a GUI
    which will be displayed in a web browser to upload any number of files.
    Please send in detail,if possible with sample codes.
    bye
    kinshuk

    Yes it is.I am getting PropertyPermission Exceptions that use.dir read permissions.
    Can anyone help me in what code should I include in an JApplet to access the file systems.Please.
    with regards
    kingshuk

  • JFilechooser and droptarget

    Hi,
    I've managed to be able to drop files into a jfilechooser (using droptarget), but the drop somehow targets the wrong part of jfilechooser
    new DropTarget( jFileChooser, this);
    When I try the above, the drop only works on the scrollbar of jFileChooser (I can drop stuff on the scrollbar, but not in the file window). Do I need to target a sub-component of jFileChooser with DropTarget, if so how?
    Cheers,
    Daniel

    Don't know if it is the best way, but since I couldn't tell which sub-component of JFilechooser to use, I iterated through the JFilechooser and attached drop targets to all components within. Looks like it solved the problem.

  • JFileChooser and FilePermission write

    Hi,
    I use a JFileChooser in a swing application like this :
    JFileChooser fileChooser = new JFileChooser();
    fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    if (fileChooser.showOpenDialog(MainJWS.this)== JFileChooser.APPROVE_OPTION) {
    dir2Name = fileChooser.getSelectedFile().getPath();
    I want the application to only get rights on FilePermission to read. So I change my policy file like this :
    grant {
    permission java.io.FilePermission "<<ALL FILES>>", "read";
    So when the appli runs, there is a PermissionException on write right. Is there any way to use the JFileChooser only on a read mode ?
    thanks.

    Thanks, I saw it.
    Maybe there 's another way, with FileDialog ? Or with JFileChooser and FileSystemView ?
    any idea ?

  • Using jFileChooser and FileFilter

    I am using a jFileChooser and want to add a file filter to only show .jpg files. I tried using...
    FileFilter filter = new FileFilter();
    filter.addExtension("jpg");
    filter.setDescription("JPG Images");
    fileChooser.setFileFilter(filter);
    fileChooser.showSaveDialog(jPanel1)I get an error saying FileFilter is an abstract. I was wondering how I can successfully filter a jFileChooser. Also, what imports libraries do I need to perform the task. I have looked at sample code and it seems they do their own classes, I want to know how to handle this task using the libraries java provides.

    Here's another way to do it, using an anon. inner
    class:
    JFileChooser chooser = new JFileChooser();
    chooser.setFileFilter(new FileFilter() {
    public String getDescription() { return "Image
    files"; }
    public boolean accept(File f) {
    if(f.isDirectory()) return true;
    if(f.getName().endsWith(".jpg")) return true;
    if(f.getName().endsWith(".png")) return true;
    return false;
    /code]
    I find myself using a lot of anon. inner classes in
    Swing.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Difference between JFrame and JApplet

    i would like to create a GUI using java. as what i know, either i can use the normal applet or java swing. may i know what is the difference between 2 of them??
    thanks

    Hello thanku,
    You have asked two completely different questions:
    1) What is the difference between JFrame and JApplet?
    2) What is the difference between Applet and JApplet?
    A Java applet is a program that adheres to a set of conventions that allows it to run within a Java-compatible browser. To create a Java applet you may either use Applet or JApplet. If you are not running with in a browser, that is, if you are creating an application, you need to use a Frame or JFrame.
    Applet is the old way of creating a Java applet. It is better to use JApplet, since JApplet has all the functionality of Applet and more. Please note that you should not mix AWT components with Swing components.
    -Merwyn,
    Developer Technical Support,
    http://www.sun.com/developers/support.

  • Using  JFileChooser in JApplet

    Hi,
    I am using JFileChooser in JApplet to goto specific folder.
    But i am getting Access Denied error to that specific folder java.io.FilePermission error.
    Could you please help me how to solve this problem
    Thanks in advance.

    u need to make it a trusted applet. applets are not supposed to access ur disk information. they run in a separate space.
    read the trusted applets in java site's tutorial.
    ta,

  • Problem with JFileChooser and ImageIcon

    I'm trying to create an ImageIcon object from file selected in JFileChooser. The problem is that jfc.getSelectedFile().getAbsolutePath() returns a string with backslashes and the constructor of ImageIcon requires the string to have slashes. I`ve tried to create it via URL but it doesn't work as well...
    String lastUsedPath;
    URL imageURL;
    JFileChooser fc = new JFileChooser();
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    int returnVal = fc.showDialog(frame,title);
    if(returnVal==JFileChooser.APPROVE_OPTION){                    
         lastUsedPath = fc.getSelectedFile().getAbsolutePath();
         imageURL = getClass().getResource(lastUsedPath);     //don't really get this but I copied it from Java Swing Tutorial          
    }else{
         return null;
    int curH, curW;            
    ImageIcon srcIcon = new ImageIcon(imageURL);                              
    curW = srcIcon.getIconWidth();
    curH = srcIcon.getIconHeight();If I use it this way imageURL is set to null.
    If I set the imageURL as 'fc.getSelectedFile().toURL()' the string is eg.: "file:/E:/file.jpg" instead of "E:/file.jpg". After that the ImageIcon is created but width and height return -1.
    If I try to create ImageIcon by 'new ImageIcon(lastUsedPath)' I get a not null object but the width & height of the ImageIcon is -1 as well.
    What do I have to do to be able to create an ImageIcon from file selected in JFileChooser? Why is this so hard and mind blowing?

    It still returns the ImageIcon object with width & height set to -1.
    EDIT:
    Got it finally:
    lastUsedPathForStupidImageIcon = fc.getSelectedFile().getPath();     
    img = ImageIO.read(new File(lastUsedPathForStupidImageIcon));
    curH = img.getHeight(this);
    curW = img.getWidth(this);The key was to use another String variable and hold the path instead of the absolute path
    Edited by: Beholder on Jan 17, 2010 1:35 PM

  • Swing layout/size problem with JFrame and JApplet.

    I have a class that extends a JFrame, the classes layout is BorderLayout. I then have a class that extend JApplet, this classes layout is GridBagLayout (this class has a JTabbedPane - which contains JPanels). The problem I'm having is no matter how big I make the size of the applet or frame (using setSize), the applet/frame stays the same size - no matter how large I make it.
    Can anyone please help?
    Thanks,
    dosteov

    Here is the basic code:
    Thanks in advance,
    dosteov
    public class EADAdm extends JApplet
    EADAdmFrame theFrame = new EADAdmFrame(this);
         public void init()
              // Take out this line if you don't use symantec.itools.net.RelativeURL or symantec.itools.awt.util.StatusScroller
    //          symantec.itools.lang.Context.setApplet(this);
              // This line prevents the "Swing: checked access to system event queue" message seen in some browsers.
              getRootPane().putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE);
              // This code is automatically generated by Visual Cafe when you add
              // components to the visual environment. It instantiates and initializes
              // the components. To modify the code, only use code syntax that matches
              // what Visual Cafe can generate, or Visual Cafe may be unable to back
              // parse your Java file into its visual environment.
              //{{INIT_CONTROLS
              getContentPane().setLayout(new GridBagLayout());
              setEnabled(false);
              getContentPane().setBackground(java.awt.Color.lightGray);
              setSize(800,800);
              getContentPane().add(AdmTab, new com.symantec.itools.awt.GridBagConstraintsD(0,1,2,1,0.5,0.5,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.HORIZONTAL,new Insets(3,12,4,14),120,120));
              AdmTab.setFont(new Font("Dialog", Font.PLAIN, 12));
              titleLbl.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
              titleLbl.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
              titleLbl.setText("EAD Administration");
              getContentPane().add(titleLbl, new com.symantec.itools.awt.GridBagConstraintsD(0,0,1,1,0.0,0.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(12,36,0,0),307,15));
              titleLbl.setForeground(java.awt.Color.blue);
              titleLbl.setFont(new Font("Dialog", Font.BOLD, 15));
              exitBtn.setText("Exit EAD Administration");
              exitBtn.setActionCommand("Exit EAD Administration");
              getContentPane().add(exitBtn, new com.symantec.itools.awt.GridBagConstraintsD(0,2,2,1,0.0,0.0,java.awt.GridBagConstraints.CENTER,java.awt.GridBagConstraints.NONE,new Insets(6,371,10,14),66,8));
              exitBtn.setFont(new Font("Dialog", Font.PLAIN, 12));
         //theFrame.setVisible(false);
         login();
         AdmTab.addTab("Administration", new LogoPanel() );
         userPanel = createUserPanel();
         AdmTab.addTab("Edit Users", userPanel );
         fpoPanel = createFPOPanel();
         AdmTab.addTab("Edit FPO", fpoPanel );
         regulationPanel = createRegulationPanel();
         AdmTab.addTab("Edit Regulations", regulationPanel );
         rolloverPanel = createRolloverPanel();
         AdmTab.addTab("Rollover", rolloverPanel );           
              //{{REGISTER_LISTENERS
         SymMouse aSymMouse = new SymMouse();
              this.addMouseListener(aSymMouse);
              SymAction lSymAction = new SymAction();
              exitBtn.addActionListener(lSymAction);
              SymKey aSymKey = new SymKey();
              this.addKeyListener(aSymKey);
         theFrame.getContentPane().add(this);
    public class EADAdmFrame extends JFrame
    EADAdm theApplet;
    public EADAdmFrame(EADAdm theMainApplet)
              //{{INIT_CONTROLS
         //     theApplet = theMainApplet;
         //     this.getContentPane().add(theApplet);
              getContentPane().setLayout(new BorderLayout(0,0));
              getContentPane().setBackground(java.awt.Color.lightGray);
              setSize(1000,1000);
              setVisible(false);
         theApplet = theMainApplet;
              //{{REGISTER_LISTENERS
              SymWindow aSymWindow = new SymWindow();
              this.addWindowListener(aSymWindow);
              SymComponent aSymComponent = new SymComponent();
              this.addComponentListener(aSymComponent);

  • Problems with JFileChooser and Windows 2000 (can't see mydocuments contents

    Hi! I've an applet which has a JFileChooser component. In other Windows, I can select the MyDocuments folder and it goes there and list all the contents OK. But, in Windows 2000, when I go to MyDocuments, none of the contents is listed in the file chooser. I need to navigate through all the directories to get there (C:\documents and settings\user\my documents) and then, it shows its contents, but obviously, I don't want it to be this way because is difficult for the common user.
    Any idea of why is going on this?
    Thanks in advance!

    Hello, You need to use something like o=isp as the
    root DN, then o=yourorg.com goes beneath it.
    i.e.
    For the other questions on setup, just choose o=isp
    as base DN when you set up the directory server. When
    you run ims_dssetup.pl, choose o=internet as the DC
    tree base, then choose o=isp as the user/groups base
    suffix.
    When you are installing messaging server it will ask
    where to put the default organization, this is where
    you would choose o=abc.com, o=isp
    For more info on how this structure works please take
    a look at this link and it will all fit into place:
    http://docs.sun.com/source/816-6017-10/changes.htm#170
    8Alright, I got ims_dssetup to run successfully. But now when the ims 5.2 installation is about 50% done, I get the message:
    A serious problem occurred while installing the iPlanet Messaging Server Messaging SIE entry in LDAP (msg.cfgldap.sie.inf). It reported the following problem:
    The server configuration for the Messaging SIE entry in LDAP (msg.cfgldap.sie.inf) cannot be created.

  • JFileChooser and Read Only Folders in XP

    The following question concerns a Java application, not a applet or web service.
    If you are browsing a folder with JFileChooser the button to create a new folder is disabled if the parent folder is read-only. Under XP folders often show up as read only and cannot be easily changed by the user. Even if Windows reports that the parent folder is read only, it does not block the creation of sub-folders in it. I'd like to always make the create folder button active regardless of whether the parent folder is read only or not; that more truely reflects the folder creation permissions anyway and mimics the behaviour of an MFC file browser. How would I do this?
    I've even tried to add a listener to the file chooser so that as the user browses to a new directory I automatically change the write permissions of folder, but short of a system command, there's no way to change the write permissions from JAVA so I don't consider this a neat solution.
    I'm surprised that I haven't found similar complaints on the net. If you use a MFC file browser the create folder button is active, but a Java file chooser has it disabled for the same folder.
    Please help.

    What would you say to a new FileChooser? I love java but I'm no fan of Sun's choosers. (See www.MartinRinehart.com, Examples, ColorChooser.)
    Email me if you're interested in doing one.

  • JFileChooser and the filename

    Hi All,
    I'm going for 11 new things learned today about Java!
    I'm using JFileChooser to prompt for a file, and I need to capture the filename and see if it's inside the file.
    I'm getting a "found int, expected boolean" compile error. Can comeone enlighten?
    Thanks!
    MVP
    String strFileName;
    JFileChooser jfc = new JFileChooser();
    strFileName = jfc.getSelectedFile().getName();  // tried both these
    strFileName = jfc.getName(); // lines
    currentLine = strInFileArray;
    if(currentLine.indexOf(strFileName)) //compile error on this line

    I didn't say it didn't compile, it does compile.
    And I know it doesn't do anything because I display
    currentLine before and after the change is attempted.
    And I did read up on the method - how do you think I
    found it in the first place?If you did, then what does it say after the word "Returns" in the method description? And where else could you have found the method? Some IDEs will spit out a list of possible methods that can be called from an option. One of the reaosns why I suggest new comers shouldn't use IDEs to start (forces them to learn about the API which is the best possible thing for someone in your (ie newbie, nothing personal) possition to do).
    >
    Now, if statements like
    i++
    setBackground(Color.WHITE)
    setFont(myfont)
    getContentPane().setLayout()
    repaint()
    and others (iow, no '=' for assignment)
    all change objects or attributes of objects, it seems
    a logical assumption to me that
    currentLine.replaceAll(strFileName,NEW_FILE_NAME);
    will change the object 'currentLine'.So you assume that all methods work the sae way, and forget the docs? The first sentance of the second paragraph in the String API says:
    "Strings are constant; their values cannot be changed after they are created. "
    So you see, the answer to your question, and the why it is the way it is, are both in the API.
    >
    Finally, (not for you jverd, you are polite), to be
    called names by supposedly mature posters on this
    forum - which exists specifically for beginner-level
    questions like mine - is just amazing. Excuse me for
    thinking I might find help and assistance instead of
    abuse.A double standard, yes? I have to be mature, but not you? You whine alot. You can ask questions without whining, others do it all the time (you didn't whine in the first question in this thread, and I tried to answer (well, tried to get you to answer yourself, which I believe is more beneficial)). Once you started your whining again, I became immature also. No apologies here.
    And even if the assinine (which it was intentionally) it still had some help (by pointing to the API). You saw the API before (which is good) but I did not know that, and your questions seemed to indicate otherwise.
    >
    TheReallyDisappointedMVPBuck up. Nothing personal. Just ask questions differently, that's all.

  • JTextField and JApplet

    How can I have the JTextField as defined below to get the cursor (Focus), when the Applet starts (the requestFocus method is not working)?
    import javax.swing.*;
    import java.awt.*;
    public class MyFocusJApplet extends JApplet {
         JTextField     myTextField = new JTextField(20);
         public void init() {
              getContentPane().setLayout(new FlowLayout());
              getContentPane().add(myTextField);
              myTextField.requestFocus();
         public void start() {
              myTextField.requestFocus();
    }

    I searhed the forums and when modified my start method as:
         public void start() {
              SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                             myTextField.requestFocus();
    I got the required results!
    But I am not able to understand the above :-(

  • Selecting all files from JFilechooser and renaming them??

    dear all
    i am working on a application that selects the jpeg,jpg,jpe files form the jfilechooser with an additonal botton rename which calls the rename method and the selected file is renamed.
    i have been succssful in mselecting one file and renaming it.but the problem is with...
    1) Selection of multiple files and sending their names and parent directories getParent(); is not working with taht....should i use arrays to store that .....but how when i have enabled multiple selection already.
    2)SEcond problem is to refersh the contents of JFileChooser after i have renamed it.iwant that it shopuld be refreshed automatically just after renaming has been done.
    help is always appreciated..
    regards
    s m sharma (trainee s/w/ engg)

    hi everybody
    i have done it myself.......it was not too tough that u didnot responed...anyway thanks..
    regards
    s m sharmna

Maybe you are looking for