File chooser on applet

Dear Sir,
I use the following coding on jdk1.4 it works well that is, while pressing the button it will work (display file chooser) perfectly on applet. while convert this coding into applet(executing in browser) the file chooser not visible on exploer. i doesn't know what is the wrong code. please help me.
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JApplet;
import javax.swing.JButton;
import javax.swing.JFileChooser;
* <applet code="AppletSample" height=100 width=100>
* </applet>
public class AppletSample extends JApplet implements ActionListener {
     public JButton b1;
     JFileChooser fileChooser;
     * @param args
     public static void main(String[] args) {
          // TODO Auto-generated method stub
     public void init() {
          b1=new JButton("click");
          b1.addActionListener(this);
          getContentPane().setLayout(null);
          b1.setBounds(500, 50, 100, 20);
          getContentPane().add(b1);
          setSize(800, 600);
          setVisible(true);
     public void actionPerformed(ActionEvent e) {
          // TODO Auto-generated method stub
          if(e.getSource()==b1){
               System.out.println("good");
               list();
     public void list() {
               fileChooser = new JFileChooser(".");
                    int t= fileChooser.showOpenDialog(this);
          fileChooser.setVisible(true);
          //     this.add(fileChooser);
          repaint();
          this.setVisible(true);
          System.out.println("good3e");
}

Sounds like this bug that will be fixed in Firefox 10.0.1, possibly released later this week.
*[https://bugzilla.mozilla.org/show_bug.cgi?id=718939 Bug 718939] – Java applet causes text entry fields to become semi-unresponsive

Similar Messages

  • File Chooser in a Panel - please help

    Hello!
    I am implementing a FTP program as part of an assignment. Can you please tell me how I can get a File Chooser like interface to the files on the remote computer? Can the existing JFileChooser be modified to support this and also can it be embedded in a panel rather than opening in a separate dialog box? Is there any way to get drag and drop support in it?
    Please do help
    Thanks
    Dilip

    Hi!
    Actually, you can use JFileChooser for remote filesystems. I've implemented it once using JDK 1.3.1 (accessing a remote Linux machine over RMI in an applet):
    (1) Create your own subclass of java.io.File, hooking all methods that actually access the filesystem (isDirectory, getSize, ...) to your ftp-connection. (That's the main work, about 50 methods to overwrite, but you can skip many, e.g. createTemporaryFile).
    (2) Make your own subclass of FileSystemView to deliver objects of your File-class instead of Sun's.
    (3) Initialize JFileChooser with this FileSystemView.
    You may also take a look at
    http://www.crocodile.org/listok/2/WhatDoesFileSystemViewView.shtml .

  • File handling in applets

    i am doing a project in applet.
    i want to open file from that applet
    but appletviewer told below error,
    java.security.Exception (Access is dinied )
    but
    that same problem is solved in ordinary java program(not in applet )
    if applet is not supported for file I/O then any other idea.

    Signed applets seldom a good solution, though. I agree. I suspect most people who have this sort of problem chose applets for one of two reasons:
    1. Applets were the first thing covered in the book they were reading.
    2. They hoped it would be a short way to deploy their code.
    The correct reason to choose an applet would be because it was a useful feature for your web site.

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

  • How can i invoke a file chooser dialog box with out using input type=file

    how can i invoke a file chooser dialog box with out using <input type=file> can any one help me mail me to [email protected]

    You could use an applet...
    Or maybe Javascript has some way to do it.

  • How do I update a file in an Applet's JAR file from the Applet code

    Here's my problem.
    My applet is using a serializable history data in which I am storing in the applet's JAR file. When I run the applet, I read the file with "getResourceAsStream()" and run my program with that hist data. When my applet is closed, I need to update this file from my Applet's code and I dumfounded about how to do that.
    Is there any way to update a file in the Applet's JAR file through the Java Applet code? (i.e. OutputStream?).
    Would appreciate any advice people have.

    Just place a copy of the file on the local hard disk and update that. When you start the Applet you try to read from the hard disk. If the file exists then no problem otherwise copy it from the jar to the hard disk.

  • Reading and writing to a text file from an Applet

    I'm a novice java programming with very little formal programming training. I've pieced together enough knowledge to do what I've wanted to do so far...
    However, I've been unable to figure out how to read and write to a text file from an Applet (I can do it from a normal java program just fine). Here is a simple example of what I'd like to do (you can also look at it on my website: www.stat.colostate.edu/~leach/test02/test02.html). I know that there is some problem with permission/security but I'm not smart enough to understand what the error messages are telling or understand the few books I have. If anyone can tell me how to get this applet to work, or direct me to some referrences that would help me out I'd really appreciate it.
    Thanks,
    Andy
    import java.applet.Applet;
    import java.net.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.util.*;
    import java.io.*;
    public class test02 extends Applet {
    public Button B_go;
    public GridBagConstraints c;
    public void init() {
    this.setLayout(new GridBagLayout());
    c = new GridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    B_go = new Button("GO");
    c.gridx=1; c.gridy=0; c.gridwidth=1; c.gridheight=1;
    c.weightx = c.weighty = 0.0;
    B_go.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    print_stuff();
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
    this.add(B_go,c);
    public static void print_stuff() {
    try{
    File f = new File("test02.txt");
    PrintWriter out = new PrintWriter(new FileWriter(f));
    out.print("This is test02.txt");
    out.close();
    }catch(IOException e){**/}
    }

    I have almost the exact same problem, and I am in the same situation as you are with respects to the language.
    I am simply trying to create a file and output some garbage to it but my applet always spits back a security violation. I've tried eliminating the restrictions on the applet runner I use but I still get the error.
    My method:
    debug = new Label() ;
    debug.setLocation( 20, 20 ) ;
    debug.setSize( 500, 15 ) ;
    add( debug ) ;
    // output
    try
         OutputStream file = new FileOutputStream( new File( "" + getCodeBase() + "output.txt" ) ) ;
         byte[] buffer = { 1, 2, 3, 4, 5 } ;
         file.write( buffer ) ;
         file.close() ;
    } catch( Exception e )
         debug.setText( e.toString() ) ;
         Can anyone tell why this isnt working?

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

  • Need help adding a default file name in a file chooser of save dialog type

    I need to create a file chooser with save dialog type, how can I add a highlighted default file name into the File Name textfield? As in Microsoft Word, when you want to save a document, a default file name Doc1.doc will appear in the File name text field of the file chooser even when you change to other directories.

    For JRE 1.4.0 you can use this fix:
    public class FileChooserFix implements PropertyChangeListener {
      private String fileName;
       * @see PropertyChangeListener
      public void propertyChange(PropertyChangeEvent ev) {
        JFileChooser chooser = (JFileChooser)ev.getSource();
        if (JFileChooser.FILES_ONLY == chooser.getFileSelectionMode()) {
          if (JFileChooser.SELECTED_FILE_CHANGED_PROPERTY.equals(ev.getPropertyName())) {
            File selectedFile = (File)ev.getNewValue();
            if (selectedFile != null) {
              // remember fileName of selected file
              fileName = selectedFile.getName();
          if (fileName != null &&
              JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(ev.getPropertyName())) {
            // reset selected file
            File directory = (File)ev.getNewValue();
            chooser.setSelectedFile(new File(directory, fileName));
       * Convenience method to create a fixed file chooser.
       * @return      fixed file chooser
      public static JFileChooser create() {
        JFileChooser chooser = new JFileChooser();
        chooser.addPropertyChangeListener(new FileChooserFix());
        return chooser;

  • File chooser to buffered image

    Hi all,
    Sorry about the total newbie question; I'm trying to figure out how to convert a jpg into a buffered image, while using the file chooser to select it. I'd like to do all this in a scrollpane. Does anyone have some sample code for this, at least so I can play around? I have ideas, but I'm getting tons of errors while trying things like:
    public class ImProc extends JComponent{
    private BufferedImage source, destination;
    private JComboBox options;
    public ImProc( BufferedImage image){
    source = destination = image;
    setBackground(Color.white);
    setLayout( new BorderLayout());
    JPanel controls = new JPanel();
    options = new JComboBox(
    new String[] {"[source]", "brighten", "darken", "rotate", "scale" }
    options.addItemListener(new ItemListener(){
    public void itemStateChanged( ItemEvent ie){
    String option = (String)options.getSelectedItem();
    BufferedImageOp op = null;
    if(option.equals("[source]"))
    destination = source;
    else if(option.equals("brighten"))
    op = new RescaleOp(1.5f, 0, null);
    else if(option.equals("darken"))
    op = new RescaleOp(0.5f, 0, null);
    else if (option.equals("rotate"))
    op = new AffineTransformOp(
    AffineTransform.getRotateInstance(Math.PI / 6), null);
    else if (option.equals("scale"))
    op = new AffineTransformOp(
    AffineTransform.getScaleInstance(.5, .5), null);
    if(op != null) destination = op.filter(source, null);
    repaint();
    controls.add(options);
    add(controls, BorderLayout.SOUTH);
    public void paintComponent(Graphics g){
    int imageWidth = destination.getWidth();
    int imageHeight = destination.getHeight();
    int width = getSize().width;
    int height = getSize().height;
    g.drawImage(destination,
    (width - imageWidth) / 2, (height - imageHeight) / 2, null);
    public static void main(String[] args){
    JFileChooser chooser = new JFileChooser();
    String filename = chooser.getName();
    ImageIcon icon = new ImageIcon(filename);
    Image i = icon.getImage();
    int w = i.getWidth(null), h = i.getHeight(null);
    BufferedImage buffImage = new BufferedImage(w, h,
    BufferedImage.TYPE_INT_RGB);
    Graphics2D imageGraphics = buffImage.createGraphics();
    imageGraphics.drawImage(i, 0, 0, null);
    JFrame frame = new JFrame("Image");
    frame.getContentPane().add(new ImProc(buffImage));
    frame.setSize(buffImage.getWidth(), buffImage.getHeight());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    So, I'm stuck. Any help from anyone is appreciated.
    Thanks,
    Joe

    Now, with:
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import javax.swing.*;
    import java.io.*;
    import javax.imageio.*;
    public class ImProc extends JComponent{
    private BufferedImage source, destination;
    private JComboBox options;
    public ImProc( BufferedImage image){
    source = destination = image;
    setBackground(Color.white);
    setLayout( new BorderLayout());
    JPanel controls = new JPanel();
    options = new JComboBox(
    new String[] {"[source]", "brighten", "darken", "rotate", "scale" }
    options.addItemListener(new ItemListener(){
    public void itemStateChanged( ItemEvent ie){
    String option = (String)options.getSelectedItem();
    BufferedImageOp op = null;
    if(option.equals("[source]"))
    destination = source;
    else if(option.equals("brighten"))
    op = new RescaleOp(1.5f, 0, null);
    else if(option.equals("darken"))
    op = new RescaleOp(0.5f, 0, null);
    else if (option.equals("rotate"))
    op = new AffineTransformOp(
    AffineTransform.getRotateInstance(Math.PI / 6), null);
    else if (option.equals("scale"))
    op = new AffineTransformOp(
    AffineTransform.getScaleInstance(.5, .5), null);
    if(op != null) destination = op.filter(source, null);
    repaint();
    controls.add(options);
    add(controls, BorderLayout.SOUTH);
    public void paintComponent(Graphics g){
    int imageWidth = destination.getWidth();
    int imageHeight = destination.getHeight();
    int width = getSize().width;
    int height = getSize().height;
    g.drawImage(destination,
    (width - imageWidth) / 2, (height - imageHeight) / 2, null);
    public static void main(String[] args){
    JFrame frame = new JFrame("Image");
    frame.setSize(300, 300);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
    JFileChooser chooser = new JFileChooser();
    //String filename = chooser.getName();
    File f = chooser.getSelectedFile();
    //String filename = f.getName();
    //ImageIcon icon = new ImageIcon(filename);
    //Image i = ImageIO.read(f);
    //int w = i.getWidth(null), h = i.getHeight(null);
    //BufferedImage buffImage = null;
    try{
    BufferedImage buffImage = ImageIO.read(f);
    catch (IOException e){
    System.out.println("Error: " + e.getMessage());
    frame.getContentPane().add(new ImProc(buffImage));
    Graphics2D imageGraphics = buffImage.createGraphics();
    imageGraphics.drawImage(buffImage, 0, 0, null);
    With this, it doesn't seem to find my variable buffImage. However, it complains if I don't use the try{} catch{}. Am I not declaring something properly?

  • Default settings for File Chooser dialog

    I reach the file chooser dialog by selecting File-Open File.
    Under the toolbar-options menu in the Open File Dialog, I can select to have a bookmark icon appear on the toolbar.
    How do I set a default to have the Bookmark icon always appear?
    Firefox 11 on openSuSE 12.1

    I don't think so, if I hide the Menu bar I don't see a Bookmarks Menu.
    In this picture http://dl.dropbox.com/u/50261731/Open_File%20Menu%20.png an arrow points to an Options menu button. Select that Button and a list of options opens, one of which is "Show Bookmarks". I would like the Show Bookmarks option to be "ON" by default.
    Be aware that I am running SuSE 12.1 and I believe this Menu is provided by KDE integration "kmozillahelper", so my menu may be different from the default Firefox menu.

  • Custom file chooser

    Hello,
    I need to design a custom file chooser. Infact, I cannot call it a file
    chooser, because this is not accessing local system files. I am uploading
    some files into a directory using ASP and I keep that file name in the database.
    I can even upload directores and directores with files too into the database.
    I need to display those files and folders in the "what is called as file chooser".
    The List should work as it works in file chooser. i.e when I click on a folder,
    it should show the files inside it. When I click on the file, the file should
    be selected. Infact there is nothing in the file. Its all virtual only. Its only
    the name that is selected.
    I should be given an option to select "directories only" also.
    The "file chooser" should not have show files of type, just the file name
    text field only. The combobox should display "user added" string message. And
    this is only one item in the combobox. I should be able to create folders, show
    lists,etc... as it appears in the file chooser. (buttons beside the combobox)
    Any ideas would be greatly appreciated.
    Thanks

    ok, this is just an example....you'll probably need a different constructor and additional methods....
    public class VirtualFile{
      private String file ;
      private VirtualFile[] children;
      private VirtualFile parent;
      public VirtualFile(String file,VirtualFile parent,VirtualFiles[]children){
         this.file = file;
         this.parent = parent;
         this.children = children;
      public boolean isRoot(){
        return parent == null;
      public boolean isDirectory(){
        return children = null || children.length==0;
      public VirtualFile[] getChildren){
        return children;
    }

  • 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();
    }

  • Add a jar file to an Applet

    Hi all,
    I'm trying to add a .jar file to my applet using the code:
    <applet name=myApplet.class archive=model.jar></applet>
    Both the .class and .jar files are in the same directory as test.html
    So, when the applet starts an exception is thrown:
    java.lang.NoClassDefFoundError: it/bizware/session/interfaces/HardwareLogManagerUtil
         at AppletPistolaL.getHardwareLogManager(AppletPistolaL.java:222)
         at AppletPistolaL.init(AppletPistolaL.java:97)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    The model.jar contains the path it/bizware/session.../HardwareLogManagerUtil!
    I can't understand why this exception is thrown
    Someone can help me?!?!?!
    thanks a lot!!

    Solved,
    just to add all path it/bizware/....
    and works!!!!
    bye!

  • Exporting to a text file in an applet..

    Hey all,
    I've been working on an applet for simulating different nodal configurations on a 2D map. What I need to be able to do is export, on the click of a button, all of the nodal coordinates (x,y) to a text file. However, using the standard FileWrite hasn't been working for me. The code compiles and the applet runs fine, but I haven't been able to create the text file on the click of a button. Any ideas?
    Here's what I've got so far. Basically, on the button push, it's supposed goes through an array of ellipses (what I use for nodes) and gets the x and y coords for each and output them to a text file. The applet doesn't freeze or anything when I push the button either, it just does nothing.
    void stop_actionPerformed(ActionEvent e){
                try
                        String fileName = "NodeCoords.txt";
                        FileWriter fileWriter = new FileWriter( fileName );
                        BufferedWriter bufferedWriter = new BufferedWriter( fileWriter );
                        String tmpCoordinates;
                        int ID;
                        //for looop through x-y coordinates
                        for (int i = 0; i < node.length; i++){
                            ID = i+1;
                            tmpCoordinates = "Node: " + String.valueOf(nodeID[ID]) + "  X: " + String.valueOf(node.getX()) + " Y: " + String.valueOf(node[i].getY()) + "\n";
    bufferedWriter.write(tmpCoordinates);
    bufferedWriter.close();
    catch( IOException p )
    p.printStackTrace();

    I'm new to this type of programming. This is for simulation of a new MAC protocol that I've worked on, and is basically just serving as a visual. If I knew how to create a stand alone application that looks like the applet I would have...

Maybe you are looking for

  • Advance payment - TDS deducted but cheque printed for full amount

    Hello SAPians, Advance payment to vendor - TDS is applicable - SAP entry shows about TDS Deduction but the cheque printed for full amount. Cheque needs to be printed after TDS deduction. Please suggest. JK

  • EIDE drives

    Are EIDE drives somehow different from IDE drives. What I really need to know is--Can a Western Digital EIDE 13Gb drive be installed in a G3 B&W? Is there some trick to the process? I have tried all of the jumper positions on both drives and I can ne

  • Time out issues

    I have a program which will retrieve the accounting information, the result as like as T-code F.19, but when i execute the program it will caused time out issue, I have not idea how to solve it. Could you help. Here is the source code which cause tim

  • Validating an XML string

    What is the most efficient way to validate an XML string with about 25 elements? I was going to do something like this, but I am not sure if its the most effienct way to validate the elements being passed. Basically, I want to put a message on a queu

  • SPA2002 in SIP server environment

    Hello, I am using the SPA2002 that registers remotely to a SIP server. The phones register correctly and can reach any other user agent (not SPA2002). the problem is that other user agents cannot call the SPA2002 until the SPA2002 calls first then th