Upload Images java applet

Hello,
We are trying to create a java applet that will be hosted in an ASP .NET-based web application, to help a user select an image file from the client computer (such as jpg, gif or another supported image type). After that we want to do jpeg-encode the image on the client side (within the applet) and upload the result to the server.
After using FileDialog's show() method to display the Open dialog and allow the user select the image file, we try to get the image with getImage("file://" + selectedDirectory + selectedFile).
The problem is that the applet cannot (by default) read the image: getImage throws a AccessControlException with denying SocketPermission.
We tried to sign the applet by using jarsigner with a certificate generated with keygen (so with an unofficial certificat), for tests purposes only. However, even when the applet's jar is signed, the same exception is thrown and the dialog asking the user whether or not he or she would allow this applet to run (since it was signed with an unoficial certificate) does NOT appear, as we expected.
One more thing (may not be related): When removing the Name=... attribute from the APPLET tag (and only keeping class="the.class" and archive="the.jar") the applet won't load unless the HTML page is open directly from Windows Explorer (it won't load when load as http://localhost/testpage.htm).
Thanks for any suggestions you may have.

However, even when the applet's jar is signed, the same exception is thrown ...you must have done something wrong, try doprivileged if your code is called by untrusted code
like javascript.
You might try non depreciated html and have a go at the htmlconverter in the jdk bin directory to
convert your html pages.
Signing applets:
http://forum.java.sun.com/thread.jsp?forum=63&thread=524815
second post and last post for the java class file using doprivileged
Uploading using multipart/form-data:
http://forum.java.sun.com/thread.jspa?threadID=530445&tstart=270
Still problems?
A Full trace might help us out:
http://forum.java.sun.com/thread.jspa?threadID=656028

Similar Messages

  • SSL Load Balancing (Java applets problem)

    Hi,
    I have implemented loadbalancing of two webservers using CSS 11503.
    Servers are containing SSL pages which need to be loadbalanced.
    I have tried configuring the content rule for ssl using
    port 443
    application ssl
    advanced-balance ssl
    commands.The site opens properly using the VIP address (checked the SSL certificate issued by one of the servers. ) and I am able to see all the TABS on the same.The real problem starts when I am trying to upload a file to the server using the VIP address.
    The moment I try to upload a file the session shifts to the second server and prompts for new certificate issued by the second server.
    One more thing which I would like to mention here is that while uploading the file, JAVA is used.
    i.e.the files are being uploaded using JAVA applets.
    If anybody has encountered this kind of problem kindly suggest on the same.
    Would appreciate if you send the solution on [email protected]
    Any configs needed plz contact me on the above e-mail ID.
    Thanks,
    Pankaj P.

    HI Pankaj,
    depending on your Java applett it might be possible that the applett opens a new connection. therefore depending on your total configuration it might be possible taht another server is used.Even worse if you do SSL-offloading the applett might tell the user to do http instead of https. I suggest that you check with a sniffertrace what is happening:
    1) is there a new connection setup while the applett runs
    2) is it again http or https and if https is it a new https session which will be again balanced not depending on the original https session.
    Hope that helps
    regards,
    Joerg

  • Upload or Import Java Applet

    Hello,
    i want to use a Java Applet for Approval Preview from SRM. I downloaded the applet and i implemented it in my BSP Application but now i want to upload or import it into the SAP System.
    What I have to do?
    THX

    I found a Solution
    Re: Display Image In BSP

  • How to upload Image to MDM 5.5 SP3 using Java APIs

    Hi,
    I am trying to upload Image to Images table in MDM 5.5 using JAVA API for MDM. But. I'm not able to find particular field in Images table where I need to set the Blob object ( Image data ).
    I'm not aware of the method to set the Blob, there is one for getting the Image data.
    I have gone through I am not able to add images into Catalog thru java API forums posts and tried the code. But with no luck....
    I think this code is for some other MDM version as the fields mentioned are not present in the Images table e.g. DataObject - this field is used in the above posts to set the Blob data but this field does not exist in Images table in MDM 5.5
    Can anyone suggest the solution?
    Thanks and Regards,
    Mausam

    Hi Mausam,
    Please try the following:
    // adding to a image table
    // get the bytes for the image
    byte[] imageBuf = readFile("C:\pic.bmp");
    // setup A2iFields
    fields = new A2iFields();
    fields.Add(new A2iField("DataObject", new
    Value(imageBuf))); // the image binary (required)
    fields.Add(new A2iField("Name", new Value("pic.bmp")));
    // a name for the image
    fields.Add(new A2iField("OrigName", new
    Value("pic.bmp"))); // the original image file name
    (required)
    fields.Add(new A2iField("DataGroupId", new Value(888)));
    // the data group to add to (required)
    fields.Add(new A2iField("OrigLocationId", new
    Value(999))); // the data location of the image
    (required)
    fields.Add(new A2iField("Description", new Value("a
    short description"))); // a short description here
    // add the image
    String imageTable = "Images";
    catalog.AddRecord(imageTable, fields, -1, -1);
    It's taken out of the API guide for SP3 (the example for method AddRecord.
    Best regards,
    Amit

  • JDK 1.4.2 java applet image printing on mac safari

    Hi there,
    I'm trying to implement printing inside java applet using javax.print package. I read an article somewhere about the package not working perfectly under mac, and a workaround is to use the old java.awt.print to get the print services, then use the DocPrintJob to print.
    The SimpleDoc I use for capturing the image that I need to print works fine, and the printServices are there. The problem I have is it's giving me an 'invalid flavor' exception when clicking 'Print' on popup PrintDialog.
    It seems that the mimetype is what's causing the problem, as the printer's supported mime type is "application/x-java-jvm-local-objectref". (note that, on PC the printing works fine, with Doc flavor mimetype as image/png and the image I need to print in png format). I tried switching the flavor to SERVICE_FORMATTED.RENDERABLE_IMAGE, printing an ImageDoc class which implements Doc and RenderableImage, but 'invalid flavor' exception still occurs.
    I don't know much about printers on Mac, so I'm not sure what I can do about it, is it something that can be controlled from the Applet or it's something that the user has to set in the system - the Applet can only warn the user and tell the user to do the configuration.
    Thanks in advance!

    SwingUtilities.updateComponentTreeUI() works by first updating the UI of the given component, and then updating the component's children (and their children). So first it will update the JToolBar's UI (which installs the appropriate borders on its buttons), and then it will update each button's UI (which subsequently installs its own default border onto the button, undoing JToolBar's border installation, thanks to the bug mentioned previously).
    Another possible work-around for this problem would be to write your own updateComponentTreeUI() method that updates the child components' UI's before updating the parent component's UI:public static void newUpdateComponentTreeUI(Component c)
         updateTreeUIs(c);
         c.invalidate();
         c.validate();
         c.repaint();
    private static void updateTreeUIs(Component c)
         Component[] children = null;
         if (c instanceof JMenu) children = ((JMenu)c).getMenuComponents();
         else if (c instanceof Container) children = ((Container)c).getComponents();
         // Children first...
         for (int i=0; children != null && i < children.length; i++)
              updateTreeUIs(children);
         // Parent last...
         if (c instanceof JComponent) ((JComponent)c).updateUI();
    }Not sure if this will present any other conflicts though.

  • Uploading images whit thumbnail to MDM repository using Java API

    Hello,
    can someone tell me how to upload images whit thumbnail to MDM repository using Java API?
    i get following message using setHasThumbnail(true):
    com.sap.mdm.commands.CommandException: com.sap.mdm.internal.protocol.manual.ServerException: Ungültiger Wert für Parameter
    thanks

    You can upload images to MDM via the API, but the only way to create thumbnails is via the MDM Data Manager application which uses some embedded libraries to do the work.
    Walter

  • Adding an image in a java applet

    Hey everyone... I am using Jbuilder and trying to add an image or background image in my applet. The image is in the folder the java file runs out of. I would really appreciate it if anyone could help me..

    I use this to add an image that I have saved in the applet folder
    Image image;
    public void init() {
    image = getImage(getDocumentBase(), "auburn.jpg");
    and I get this error when I try to run it in Jbuilder:
    java.lang.NullPointerException
         at java.applet.Applet.getDocumentBase(Applet.java:125)
         at JavaProject.<init>(JavaProject.java:103)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
         at java.lang.reflect.Constructor.newInstance(Constructor.java:274)
         at java.lang.Class.newInstance0(Class.java:308)
         at java.lang.Class.newInstance(Class.java:261)
         at sun.applet.AppletPanel.createApplet(AppletPanel.java:617)
         at sun.applet.AppletPanel.runLoader(AppletPanel.java:546)
         at sun.applet.AppletPanel.run(AppletPanel.java:298)
         at java.lang.Thread.run(Thread.java:534)
    What could be the problem?

  • Zoom in and zoom out a image in a java applet

    hello, i don't find any example of code of a java applet that zoom in and zoom out an image in jpeg format...
    can you help me?
    thanks

    Crosspost (and other thread has started some answers):
    http://forum.java.sun.com/thread.jspa?threadID=624295

  • Wrong image refresh in java applet AND Windows 7

    I'm managing since few days a java applet that takes an image from an industrial product and shows it in a browser (simple web server).
    There is following issue: the image is not correctly loaded and refreshed in its own window if just opened but only if the applet is running on Windows 7. The issue is solved as soon as I reduce the window to icon (minimize) and then resize it. I'm looking into java documentation on how to manage the image rendering, maybe I have to override some update or redraw method more, but it is taking time and I'm still learning. NOTE that the window opened does show the issue only when the windows size is not completely shown in the monitor.
    Meanwhile I'm wandering if some of you faced and solved similar problem.
    Thank you in advance,
    Elena

    Thank you Nitin for your quick reply!
    These are the calling of the functions in the code. As you can see, before to show the image, we are managing a zoom/unzoom by mouse wheel and an addition of writings data on the image itself. All is working fine except on W7:
    public void paint(Graphics g)
         //System.out.println("[ImageFrame::paint my paint!!!]");
         this.PaintImage(g);
    public void update(Graphics g)
         // System.out.println("[ImageFrame::update]");
         this.repaint();
    public void PaintImage(ImageInfo imageInfo, float fps)
         if (imageInfo != null)
              if (this.getImageInfoRef() == null){
                   this.setVisible(true);
              this.setTitle("Image Viewer (" + imageInfo.bufferedImage.getWidth() + "x" + imageInfo.bufferedImage.getHeight() + ") ");
              this.resizeImageFrame((int) (imageInfo.bufferedImage.getWidth() * zoomFactor), (int) (imageInfo.bufferedImage.getHeight() * zoomFactor));
              this.lastFps = fps;
              this.setImageInfoRef(imageInfo);
              //System.out.println("this.getWidth(): " + this.getWidth() + " this.getHeight(): " + this.getHeight() + " zoomFactor: " + zoomFactor);////
              this.PaintImage(this.getGraphics());
    public synchronized void PaintImage(Graphics g)
         ImageInfo locImageInfo = getImageInfoRef();
         if (locImageInfo != null)
              try
                   this.resizeImageFrame((int) (locImageInfo.bufferedImage.getWidth() * zoomFactor), (int) (locImageInfo.bufferedImage.getHeight() * zoomFactor));
                   BufferedImage bufferedImage = this.resizeBufferedImage(locImageInfo.bufferedImage, zoomFactor);
                   this.overlayCodeInfo(bufferedImage, locImageInfo.decInfoStruct, zoomFactor);
                   this.overlayPointerInfo(bufferedImage, locImageInfo.scaling, zoomFactor, this.crossX, this.crossY);
                   this.overlayFrameRateInfo(bufferedImage, this.lastFps);
                   Image img = Toolkit.getDefaultToolkit().createImage(bufferedImage.getSource());
                   boolean retdraw;
                   retdraw = g.drawImage(img, frameUpperBondarySizeX, frameUpperBondarySizeY, this);
              catch (Exception ex)
                   System.out.println("[ImageFrame::PaintImage] Exception: " + ex);
    Thank you again
    Elena

  • File Uploader Java Applet cannot be run

    I have a website that I need to upload PDFs to, but since ugrading to Lion, I cannot do it any more.  I have downloaded the separte Java app, but it still does not work.
    This is the error message I get:
    File Uploader Java Applet cannot be run. Make sure that Java is installed on your PC and Java applets are permitted in browser settings. Use this link to download and install appropriate version of Java:

    Thank you etresoft - that did not solve the problem.  However, I did fix it by changing something in Java Preferences (which is located in the Utilities Folder).
    I first deleted the cache files as you suggested in the Network tab.  Then I quit and restarted Firefox.  I still got the same error message when I tried to upload.
    Then, I went back into Java Preferences and checked the box, "Enable Appplet Plug-in and Webstart Applications" located in the General Tab.  I then quit and restarted Firefox.  Now I am able to upload documents as I could before Lion.
    Thank you!!

  • Problem in sending image from applet to servlet

    dear friends,
    i have a need to send an image from applet to servlet via HttpConnection and getting back that image from applet.
    i am struggling with this sice many hours and got tired by searching any post that would help me but haven't got yet.
    i tried using this code but it dosent make any execution sit right. i got NPE at ImageIcon.getDescription() line;
    at applet side
          jf.setContentPane(getJContentPane());
                     FileDialog fd=new FileDialog(jf,"hi");
                     fd.setMode(FileDialog.LOAD);
                     fd.setVisible(true);   
                     v=new Vector();
                     try{                                                
                               FileInputStream fis=new FileInputStream(new File(fd.getDirectory()+fd.getFile()));      
                               byte[] imgbuffer=new byte[fis.available()];
                               fis.read(imgbuffer);
                               ImageIcon imgdata=new ImageIcon(imgbuffer);
                               v.add(0,imgicon);
                                String strwp ="/UASProject/Storeimage";              
                                URL servletURL = new URL(getCodeBase(),strwp);             
                                HttpURLConnection servletCon = (HttpURLConnection)servletURL.openConnection();       
                                servletCon.setDoInput(true); 
                                servletCon.setDoOutput(true);
                                servletCon.setUseCaches(false);
                                servletCon.setDefaultUseCaches(false);   
                                servletCon.setRequestMethod("POST");     
                                servletCon.setRequestProperty("Content-Type", "application/octet-stream");   
                                servletCon.connect();            
                                ObjectOutputStream oboutStream = new ObjectOutputStream(servletCon.getOutputStream());                     
                                oboutStream.writeObject(v);
                                v.remove(0);
                                oboutStream.flush();      
                                oboutStream.close();  
                                //read back from servlet
                                ObjectInputStream inputStream = new ObjectInputStream(servletCon.getInputStream());
                                 v= (Vector)inputStream.readObject();                     
                                 imgicon=(ImageIcon)v.get(1);
                                 showimg.setIcon(imgicon);
                                 this.getContentPane().validate();
                                 this.validate();  
                                inputStream.close();                                                        
                             //  repaint();
                     }catch(Exception e){e.printStackTrace();}  and this is at servlet side
            try {       
                         Vector v=new Vector();                    
                         ObjectInputStream inputFromjsp = new ObjectInputStream(request.getInputStream());                                      
                          v = (Vector)inputFromjsp.readObject();                                                                                                          
                          imgicon=(ImageIcon)v.get(0);                     
                          inputFromjsp.close();            
                          System.out.println(imgicon.getDescription());                                      
                          v.remove(0);
                          v.add(1,imgicon);
    //sending back to applet
                           response.setContentType("application/octet-stream");
                          ObjectOutputStream oboutstream=new ObjectOutputStream(response.getOutputStream());            
                          oboutstream.writeObject(v);
                          oboutstream.flush();
                          oboutstream.close();
                   } catch (Exception e) {e.printStackTrace();}  i really need your help. please let me out of this headche
    thanks
    Edited by: san_4u on Nov 24, 2007 1:00 PM

    BalusC wrote:
    san_4u wrote:
    how can i made a HttpClient PostMethod using java applets? as i have experience making request using HttpURLConnection.POST method. ok first of all i am going make a search of this only after i will tell. please be onlineOnce again, see link [3] in my first reply of your former topic.
    yeah! i got the related topic at http://www.theserverside.com/tt/articles/article.tss?l=HttpClient_FileUpload. please look it, i am reading it right now and expecting to be reliable for me.
    well what i got, when request made by html code(stated above) then all the form fields and file data mixed as binary data and available in HttpServletRequest.getinputstream. and at servlet side we have to use a mutipart parser of DiskFileItemFactory class that automatically parse the file data and return a FileItem object cotaing the actual file data,right?.You can also setup the MultipartFilter in your environment and don't >care about it further. Uploaded files will be available as request attributes in the servlet.is the multipartfilter class file available in jar files(that u suggested to add in yours article) so that i can use it directly? one more thing the import org.apache.commons.httpclient package is not available in these jar files, so where can got it from?
    one mere question..
    i looked somewhere that when we request for a file from webserver using web browser then there is a server that process our request and after retrieving that file from database it sends back as response.
    now i confused that, wheather these webservers are like apache tomcat, IBM's webspher etc those processes these request or there is a unique server that always turned on and process all the request?
    because, suppose in an orgnisation made it's website using its own server then, in fact, all the time it will not turned on its server or yes it will? and a user can make a search for kind of information about this orgnisation at any time.
    hopes, you will have understand my quary, then please let me know the actual process
    thanks
    Edited by: san_4u on Nov 25, 2007 11:25 AM

  • Please, help me with file access in Java Applet.

    import java.awt.*;
    import java.applet.*;
    import java.net.*;
    public class ImageVi extends Applet {
         URL PicPath1;
         Image Img1;
         public void init()
              try
                   PicPath1 = new URL("http://nurchi.far.ru/pic/s08.jpg");
              } catch (MalformedURLException Excep1) {}
         public void paint(Graphics g) {
              Img1=getImage(PicPath1);
              g.drawImage(Img1, 10, 10, this);
    The error message is:
    Exception occurred during event dispatching:
    java.security.AccessControlException: access denied (java.net.SocketPermission nurchi.far.ru resolve)
    at java.security.AccessControlContext.checkPermission(AccessControlContext.java:195)
    at java.security.AccessController.checkPermission(AccessController.java, Compiled Code)
    at java.lang.SecurityManager.checkPermission(SecurityManager.java, Compiled Code)
    at java.lang.SecurityManager.checkConnect(SecurityManager.java:1019)
    at sun.awt.image.URLImageSource.<init>(URLImageSource.java:48)
    at sun.applet.AppletImageRef.reconstitute(AppletImageRef.java:40)
    at sun.misc.Ref.get(Ref.java:53)
    at sun.applet.AppletViewer.getCachedImage(AppletViewer.java:275)
    at sun.applet.AppletViewer.getImage(AppletViewer.java:270)
    at java.applet.Applet.getImage(Applet.java:190)
    at ImageVi.paint(ImageVi.java:24)
    at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:116)
    at java.awt.Component.dispatchEventImpl(Component.java:2452)
    at java.awt.Container.dispatchEventImpl(Container.java:1059)
    at java.awt.Component.dispatchEvent(Component.java:2312)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:301)
    at java.awt.EventDispatchThread.pumpOneEventForComponent(EventDispatchThread.java:120)
    at java.awt.EventDispatchThread.pumpEventsForComponent(EventDispatchThread.java:95)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:90)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

    Applets are not allowed to connect to other server
    than the one they were loaded from. This is probably
    the reason here.You mean that I can use the applet after uploading on my web-site and using "getDocumentBase()" only?
    OK.
    The applet works perfectly if I use that function, but I have another question.
    If I want to use something like:
    Img1=getImage(getDocumentBase(), "s01.jpg");
    it works perfectly.
    If I do the fillowing:
    Img1=getImage(getDocumentBase(), "pic/s01.jpg");
    it also works.
    But is it possible to go a level up?
    Like:
    Img1=getImage(getDocumentBase(), "../pic/s01.jpg");
    That is if an applet is in one folder and the pictures are in another, but to get to them I have to go a level up and then enter another folder.
    Please help.
    Thanks.

  • Java Applet Security Restriction?

    Hi,
    I wrote a java applet and test it on my computer. When I view it with applet viewer I can view the applet correctly. But when I try to view on the Internet Explorer, it said "Java Applet Started" But I didn't see anything on the screen.
    This happens when I actually incorporate the JFileChooser. When I take out that, the applet can run.
    What I think is, even if I run the applect in Internet Explorer, since I am actually running directly from my computer (i.e C:\Myapplet.html) and not even through Apache or IIS why I won't be able to carry out such operation?

    Output from JavaConsole
    Exception in thread "AWT-EventQueue-2" java.security.AccessControlException: access denied (java.util.PropertyPermission user.dir read)
         at java.security.AccessControlContext.checkPermission(Unknown Source)
         at java.security.AccessController.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPermission(Unknown Source)
         at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
         at java.lang.System.getProperty(Unknown Source)
         at java.io.Win32FileSystem.getUserPath(Unknown Source)
         at java.io.Win32FileSystem.resolve(Unknown Source)
         at java.io.File.getAbsolutePath(Unknown Source)
         at sun.awt.shell.Win32ShellFolder2.<init>(Unknown Source)
         at sun.awt.shell.Win32ShellFolder2.listFiles(Unknown Source)
         at sun.awt.shell.ShellFolder.listFiles(Unknown Source)
         at sun.awt.shell.Win32ShellFolderManager2.get(Unknown Source)
         at sun.awt.shell.ShellFolder.get(Unknown Source)
         at javax.swing.plaf.metal.MetalFileChooserUI.updateUseShellFolder(Unknown Source)
         at javax.swing.plaf.metal.MetalFileChooserUI.installComponents(Unknown Source)
         at javax.swing.plaf.basic.BasicFileChooserUI.installUI(Unknown Source)
         at javax.swing.plaf.metal.MetalFileChooserUI.installUI(Unknown Source)
         at javax.swing.JComponent.setUI(Unknown Source)
         at javax.swing.JFileChooser.updateUI(Unknown Source)
         at javax.swing.JFileChooser.setup(Unknown Source)
         at javax.swing.JFileChooser.<init>(Unknown Source)
         at javax.swing.JFileChooser.<init>(Unknown Source)
         at FotoUpload.createGUI(FotoUpload.java:48)
         at FotoUpload.access$000(FotoUpload.java:24)
         at FotoUpload$1.run(FotoUpload.java:86)
         at java.awt.event.InvocationEvent.dispatch(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)
    This is what happen when I run my code below
    * FotoUpload.java
    * Created on November 15, 2006, 11:30 AM
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    * @author Leo Liu
    import java.io.*;
    import javax.swing.JApplet;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.JComponent.*;
    import javax.swing.filechooser.*;
    public class FotoUpload extends JApplet implements ActionListener{
        JButton BtnBrowse;
        JPanel PnlUpload;
        JFileChooser fcSelectFile;
        JTextArea log;
        private void createGUI(){
            setLayout(new BorderLayout(5,5));
            //Making Button
            BtnBrowse=new JButton("Browse");
            BtnBrowse.setToolTipText("Click on Browse to select picture");
            BtnBrowse.setAlignmentX(Component.RIGHT_ALIGNMENT);
            BtnBrowse.setPreferredSize(new Dimension(30,20));
            BtnBrowse.addActionListener(this);
            //Putting Button inside the panel and specifying the button size
            JPanel PnlBrowse = new JPanel();
            PnlBrowse.setLayout(new BoxLayout(PnlBrowse, BoxLayout.X_AXIS));
            PnlBrowse.add(Box.createRigidArea(new Dimension(30,20)));
            PnlBrowse.add(BtnBrowse);
            //Create a file chooser
            fcSelectFile = new JFileChooser();
            //Creating Panel to show selected pictures for uploading
            PnlUpload=new JPanel();
            PnlUpload.setBorder(javax.swing.BorderFactory.createTitledBorder("Place Pictures to Upload"));
            PnlUpload.setToolTipText("You can drag and drop images into this area");
            log=new JTextArea(5,20);
            log.setMargin(new Insets(5,5,5,5));
            log.setEditable(false);
            PnlUpload.add(log);
            //adding UI components to Applet
            add(PnlBrowse,BorderLayout.NORTH);
            add(PnlUpload,BorderLayout.CENTER);
        public void actionPerformed(ActionEvent e) {
            if (e.getSource() == BtnBrowse) {
                int returnVal = fcSelectFile.showDialog(this,"Select");
                if (returnVal == JFileChooser.APPROVE_OPTION) {
                    File file[]= fcSelectFile.getSelectedFiles();
                    //This is where a real application would open the file.
                    int count=0;
                    while(count<file.length)
                        log.append("Opening: " + file[count].getName() + ".\n");
                        count++;
                } else {
                    log.append("Open command cancelled by user.\n");
        public void init() {
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createGUI();
    }It seems like I need to catch some exception or something. Can anyone help me?

  • Thanksgiving Challenge - ListenUp Java Applet integration

    For those that like a Challenge... I came across this Java
    Applet that appears to be quite powerful to add recording and
    playing of voice audio files to a website:
    http://www.javasonics.com/downloads/
    I have not been successful in writing the coldfusion code yet
    that will read the information that is passed from this Java Applet
    with respect to sound file (wav), file name, and other fields that
    are in the form when created.
    This is the format of the use of the Applet that I would like
    to get working on the site:
    http://www.javasonics.com/listenup/examples/use_text_fields.html
    I look forward to anyone that can get this code working and
    how you did it with ColdFusion.
    Thanks,
    Tom
    [email protected]

    When I run their PHP version that works on a Linux System and
    the Java Applet debugger on this is the result from the time the
    file is handed off from the Java Applet to the PHP Code.
    Can anyone tell if the file is actually being written to the
    server then PHP is reading it from the server or is it just being
    written to memory and PHP is reading a variable or memory block for
    this data?
    ListenUp: 49.081, sendRecordedMessage(message_12345.wav)
    ListenUp: 49.091, sendRecordedMessage: upload
    message_12345.wav
    ListenUp: 49.101, start upload, freeMem = 3535456, totalMem =
    5640192
    ListenUp: 49.431, got compressed image, freeMem = 3453040,
    totalMem = 5640192
    ListenUp: 49.671, got MIME data, freeMem = 3387064, totalMem
    = 5640192
    ListenUp: 49.902, MultipartFormDataUploader: POST size =
    15733
    ListenUp: 49.902, parseStatusLine: HTTP/1.1 100 Continue, len
    21
    HTTP/1.1 200 OK
    Cache-Control: private
    Connection: close
    Date: Thu, 27 Nov 2008 18:38:07 GMT
    Content-Type: text/plain
    Server: Microsoft-IIS/6.0
    X-Powered-By: PHP/4.4.1
    X-Powered-By: ASP.NET
    <param name=userfile>
    raw_name = message_12345.wav
    name = message_12345.wav
    type = audio/wav
    size = 15420
    Upload dir = ../uploads
    duration = 2.6006349206349206
    SUCCESS - message_12345.wav uploaded.
    ListenUp: 50.332, DynamicMemoryBuffer: deleting array.
    ListenUp: 50.332, finished upload, freeMem = 3487480,
    totalMem = 5640192

  • Trouble deploying Java Applet for animation(s) on web site

    I FTP weather radar images up to my host's server, thus onto my web site constantly. As of now, I am successfully doing so with a Java Script. However, I am wanting to do so with a Java Applet.
    The trouble I am having is that the Applet deploys in the browser once on the web site..but the radar images are not being drawn upon thus not showing up to animate. I have a username and password for my web site, but have been told by many that this would not be a prohibitive situation for the Applet to retrieve the images. Thus, I feel that I am coding something wrong causing the Applet to fail in "locating" the images to animate. All files for the Applet are in the same directory as the images I am trying to upload into the Applet, yet still no success. "GR" is the sub directory where the radar image uploaded files are contained within.
    I have attached the coding that I am/have been trying to implement. If anyone can assist I would be greatly appreciative!
    <P>
    <applet archive="aniscode.jar,png.jar" code="AniS.class" align="left" height="800" width="800">
    alt="Java must be installed and working for this animation to work">
    <param name="controls" value="startstop, looprock, toggle, zoom, step, speed, refresh ">
    <param name="backcolor" value="000000">
    <param name="forecolor" value="ffffff">
    <param name="image_window_size" value="800,800">
    <param name="auto_refresh" value="1">
    <param name="toggle_size" value="8,10,5">
    <param name="active_zoom" value="x">
    <param name="pause_percent" value="990">
    <param name="enable_png" value="true
    <param name="basename" value="anim*.png">
    <param name="no_enh" value="true">
    <param name="num_frames" value="10">
    <param name="rate" value="75">
    <param name="image_base" value="http://www.leesweather.net/GR/ ">
    <param name="filenames" value="br1_9.png,br1_8.png,br1_7.png,br1_6.png,br1_5.png,br1_4.png,br1_3.png,br1_2.png,br1_1.png,br1_0.png">
    </applet>

    I FTP weather radar images up to my host's server,
    thus onto my web site constantly. As of now, I am
    successfully doing so with a Java Script.
    However, I am wanting to do so with a Java Applet.
    e trouble I am having is that the Applet deploys in
    the browser once on the web site..but the radar
    images are not being drawn upon thus not showing up
    to animate. I have a username and password for my
    web site, but have been told by many that this would
    not be a prohibitive situation for the Applet to
    retrieve the images. Thus, I feel that I am coding
    something wrong causing the Applet to fail in
    "locating" the images to animate. All files for the
    Applet are in the same directory as the images I am
    trying to upload into the Applet, yet still no
    success. "GR" is the sub directory where the radar
    image uploaded files are contained within.
    I have attached the coding that I am/have been trying
    to implement. If anyone can assist I would be
    greatly appreciative!
    <P>
    <applet archive="aniscode.jar,png.jar"
    code="AniS.class" align="left" height="800"
    width="800">
    alt="Java must be installed and working for this
    animation to work">
    param name="controls" value="startstop, looprock,
    toggle, zoom, step, speed, refresh ">
    <param name="backcolor" value="000000">
    <param name="forecolor" value="ffffff">
    <param name="image_window_size" value="800,800">
    <param name="auto_refresh" value="1">
    <param name="toggle_size" value="8,10,5">
    <param name="active_zoom" value="x">
    <param name="pause_percent" value="990">
    <param name="enable_png" value="true
    <param name="basename" value="anim*.png">
    <param name="no_enh" value="true">
    <param name="num_frames" value="10">
    <param name="rate" value="75">
    <param name="image_base"
    value="http://www.leesweather.net/GR/ ">
    <param name="filenames"
    value="br1_9.png,br1_8.png,br1_7.png,br1_6.png,br1_5.p
    ng,br1_4.png,br1_3.png,br1_2.png,br1_1.png,br1_0.png">
    </applet>I hope you have them properly packed into a jar in which case you can
    use this method...
    Code snippet from hyperview.dev.java.net
    public Image getImageFromJar(String fileName)
    int length = 0;
       if( fileName == null )
           return null;
       Image image = null;
       try
          image = getAppletContext().getImage( getClass().getResource(fileName) );
       catch(Exception exc)
          exc.printStackTrace();
          return (Image)null;
       return image;
    } ///----- Otherwise they should be in the same codebase as the Applet
    // and you can use this call (Way slower to download)
    Image myImage = getAppletContext().getImage(new URL(getCodeBase(),"YOUR_IMAGE_NAME.gif") );Good Luck!
    (T)

Maybe you are looking for