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?

Similar Messages

  • 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

  • Having problem with importing images to a java applet in web broswer

    I'm creating a mini 2d game just for fun and I am running it as a applet with the JApplet class.
    This is my html file.
    <html>
    <body>
    <applet code=ambiDexApplet.class name=ambiDexApplett archive=ambiDexApplet.jar
         width=640 height=480>
         <param name="Player" value="Player.class">
         <param name="Actor" value="Actor.class">
         <param name="Tail_Bead" value="Tail_Bead.class">
         <param name="Block" value="Block.class">
         <param name="Morphable" value="Morphable.class">
         <param name="Item" value="Item.class">
         <param name="GameObject" value="GameObject.class">
         <param name="leftImg" value="Player_Left3.gif">
         <param name="rightImg" value="Player_Right3.gif">
         <param name="img1" value="bgImgFinal.jpg">
         <param name="img2" value="Block_Tower2.gif">
    </applet>
    </body>
    </html>However every time i try to run the program i get the following error when i open the java console.
    java.security.AccessControlException: access denied (java.io.FilePermission Images\Player_Left3.gif read)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    Obviously, the applet is not letting me read the image files. By the way, the .class files and the image files are all in same directory. So can anyone help me please?

    Unfortunately, yes--I've tried it that way over and over, and every other way I could think of.  The files are all in one folder, and I've converted the raw files to both tiffs and jpegs.  I even tried converting them to jpegs at the final pixel dimensions.  Each folder that I have used only contains one type of file, and they are all part of the same sequence and sequentially numbered.  I have even tried renumbering the files with numbers first, numbers last, numbers only, moving underscores.  I moved the files from my external hard-drive to the desktop ... I have a lot less hair than I had only a few days ago!
    I've looked at a few other tutorials that outline the same sequence of steps, and tried them over and over, and then changing one step at a time to make sure that it was not a single step that caused the problem.
    The thing that is really bugging me is that it works fine if I use the different approach of using the place command instead. 
    Anyway, thanks for all of your time.  It's going to be a lot simpler to just stick with 'place' command and I will likely do that, but I tend take things like this as a challenge.  I like to know WHY it won't work for me.  Sometimes it seems that there is just no logical explanation!
    Stuart

  • Opening image files in java applet

    Hi,
    I made an applet that opens up the image file and displays it.
    When the photo is loaded, the program sets boolean photoLoaded = true;
    and when the image is loaded, it has to do something else.
    the problem is that I have to open the file twice meaning I would click
    "open" button and select the photo, which doesn't do anything, so I have to go back
    and click open button, select the photo, and open up again.
    When I changed the code slightly so that it shows the first time, photoLoaded is still false the first time,
    so I still have to open it up twice for photoLoaded to be true.
    methods for opening an image file:
        private void loadPhoto() throws Exception{
            Frame parent = new Frame();
            FileDialog fd = new FileDialog(parent, "Please choose a image file:",
                FileDialog.LOAD);
            fd.show();
            String selectedImage = fd.getFile();
            if(selectedImage == null){
                // no image file selected
            }else{
                File ffile = new File(fd.getDirectory() + File.separator +
                                    fd.getFile());
                boolean canOpen = accept(ffile);
                if(canOpen){
                    imageLoaded = kit.getImage(selectedImage);
                    width = imageLoaded.getWidth(ob);
                    height = imageLoaded.getHeight(ob);
                    /*get image*/
                    imageLoaded = getImage(getCodeBase(), selectedImage);
                    tracker.addImage(imageLoaded, 0);
                    /* wait until image is loaded */
                    try{
                        tracker.waitForAll();
                        photoLoaded = true;
                    }catch(InterruptedException ex) {
                        //does nothing
                    repaint();
        public boolean accept(File f){
            if(f.isDirectory()){
                return true;
            String extension = Utils.getExtension(f);
            if(extension !=null){
                if(extension.equals(Utils.gif) ||
                   extension.equals(Utils.jpeg) ||
                   extension.equals(Utils.jpg)){
                       return true;
                } else{
                    return false;
            return false;
        public static class Utils{
            public final static String jpeg = "jpeg";
            public final static String jpg = "jpg";
            public final static String gif = "gif";
            /* get the extension of a file */
            public static String getExtension(File f){
                String ext = null;
                String s = f.getName();
                int i = s.lastIndexOf('.');
                if(i>0 && i<s.length()-1){
                    ext = s.substring(i+1).toLowerCase();
                return ext;
        }and the paint method:
        public void paint(Graphics g)
            g.drawImage(background, 0, 0, this);
            if(photoLoaded == true){
                g.drawImage(imageLoaded, startingPtX, startingPtY, ob);
        }does anybody have idea on what's wrong with it?
    thanks!

    Is this what you mean by you have to load it twice? You load the image, then add it to the MediaTracker, then you do what ever you want with it--like get the width and height and set you flags.
       imageLoaded = kit.getImage(selectedImage);
       width = imageLoaded.getWidth(ob);
       height = imageLoaded.getHeight(ob);
       /*get image*/
       imageLoaded = getImage(getCodeBase(), selectedImage);
       tracker.addImage(imageLoaded, 0);

  • Why is it unable to read URL through Java Applet ?

    I have tried to read an image with ImageIO.read(URL) in JApplet. But it failed to be initialized. Please refer to TEST.java. But if I read the image in MSDOS mode, it works. Please refer to DisplayImage.java. The only difference is Applet and MSDOS mode.
    I am using WindowsXP with j2sdk1.4.1_01 installed.
    //File one: TEST.java
    //Please run in Applet mode
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.applet.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import java.net.*;
    public class TEST extends JApplet
         BufferedImage tempimg;
         public void init()
              try
                   tempimg = ImageIO.read(new URL("http", "www.footprint.org.hk", 80, "/newsphotos/N200301270_0.jpg"));
              catch(MalformedURLException murle){}
              catch(IOException ioe){}
              JFrame f = new JFrame("ImageDisplayer");
              f.setSize(new Dimension(550,350));
              f.setVisible(true);
    //End of TEST.java
    //File two: DisplayImage.java
    //Please run in MSDOS mode
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import java.awt.image.*;
    import java.applet.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.imageio.stream.*;
    import java.net.*;
    public class DisplayImage extends JApplet
         ImagePanel imagePanel;
         public static void main(String[] args) throws MalformedURLException, IOException
              DisplayImage img = new DisplayImage();
              img.init();
         public void init()
              //Display Image
              try
                   imagePanel = new ImagePanel(ImageIO.read(new URL("http", "www.footprint.org.hk", 80, "/newsphotos/N200301270_0.jpg")));
              catch(MalformedURLException murle){}
              catch(IOException ioe){}
    JFrame f = new JFrame("ImageDisplayer");
              f.addWindowListener(new WindowAdapter() {
                   public void windowClosing(WindowEvent e) {
                        System.exit(0);
              f.getContentPane().add(imagePanel, BorderLayout.CENTER);
              f.setSize(new Dimension(550,350));
              f.setVisible(true);
    class ImagePanel extends JPanel {
    Image image;
    public ImagePanel(Image image) {
    this.image = image;
    public void paintComponent(Graphics g) {
    super.paintComponent(g); //paint background
    //Draw image at its natural size first.
    g.drawImage(image, 0, 0, this); //85x62 image
    //End of DisplayImage.java

    The security model for applets does not allow them to read from a URL unless it is on the same host the applet was loaded from. If you must do this then you must sign your applet for it to work.

  • Adding image to JDialog in Applet

    Well.. I've decided to make my Applet load via a JDialog. Which I know is possible :). And to a start I'll make a very simple Applet in the JDialog, including a background picture, which I just can't add! So to make a long story short, I want an image in my JDialog, but my code gives me a nullPointerException during the Runtime.. Here's the exact Runtime error:
    Exception in thread "main" java.lang.NullPointerException
            at applet.<init>(applet.java:16)
            at applet.main(applet.java:100)And here's my exact applet.java file:
    import java.applet.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.swing.plaf.metal.*;
    public class applet extends Applet implements Runnable
        private ImagePanel panel;   
    public applet()
         panel.createGUI();
        public void init()
        public void run()
    public void start()
         Thread thread = new Thread(this);
         thread.start();
    public void stop()
    public void destroy()
    public void paint(Graphics g)
    private class ImagePanel extends JPanel
        BufferedImage buffered = null;
        public ImagePanel(String name)
            try
                buffered = ImageIO.read(new File(name));
                setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight()));
            } catch(IOException ioe)
                ioe.printStackTrace();
        public void paintComponent(Graphics g)
            if (buffered == null)
                g.drawString("No Image", 10, 40);
            else
                g.drawImage(buffered, 0, 0, null);
        public void createGUI()
         MetalLookAndFeel.setCurrentTheme(new BlackTheme());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JDialog dialog = new JDialog();
      dialog.setTitle("Applet loading via. JDialog");
      Container container = dialog.getContentPane();
      ImagePanel panel = new ImagePanel("background.gif");
      dialog.pack();
      dialog.setSize(1000, 1000);
      dialog.setVisible(true);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        public static void main(String[] args)
         applet app = new applet();
    }And I don't see any errors, but still.. Runtime error.. -.-' So a little bit of help would really be appretaiced!

    Okay I guess I spoke to soon.. :O Now I have no Runtime error but my JDialog is completly empty.. And my BlackTheme stopped working.. Not It's a blue theme instead..
    Here take a look at my applet.java:
    import java.applet.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.imageio.*;
    import javax.swing.plaf.metal.*;
    public class applet extends Applet implements Runnable
        ImagePanel panel = new ImagePanel("background.gif");  
    public applet()
         panel.createGUI();
        public void init()
        public void run()
    public void start()
         Thread thread = new Thread(this);
         thread.start();
    public void stop()
    public void destroy()
    public void paint(Graphics g)
    private class ImagePanel extends JPanel
        BufferedImage buffered = null;
        public ImagePanel(String s)
            try
                buffered = ImageIO.read(new File(s));
                setPreferredSize(new Dimension(buffered.getWidth(), buffered.getHeight()));
            } catch(IOException ioe)
                ioe.printStackTrace();
        public void paintComponent(Graphics g)
            if(buffered == null)
                System.out.println("No image to display.");
            else
                g.drawImage(buffered, 0, 0, null);
        public void createGUI()
            MetalLookAndFeel.setCurrentTheme(new BlackTheme());
            JFrame.setDefaultLookAndFeelDecorated(true);
            JDialog.setDefaultLookAndFeelDecorated(true);
            JPopupMenu.setDefaultLightWeightPopupEnabled(false);
         JDialog dialog = new JDialog();
      dialog.setTitle("Applet loading via. JDialog");
      Container container = dialog.getContentPane();
      ImagePanel panel = new ImagePanel("background.gif");
      dialog.pack();
      dialog.setSize(1000, 1000);
      dialog.setVisible(true);
      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
        public static void main(String[] args)
         applet app = new applet();
    }

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

  • How to add images into a java application (not applet)

    Hello,
    I am new in java programming. I would like to know how to add images into a java application (not an applet). If i could get an standard example about how to add a image to a java application, I would apreciated it. Any help will be greatly apreciated.
    Thank you,
    Oscar

    Your' better off looking in the java 2d forum.
    package images;
    import java.awt.*;
    import java.awt.image.*;
    import java.io.FileInputStream;
    import javax.imageio.ImageIO;
    import javax.swing.*;
    /** * LogoImage is a class that is used to load images into the program */
    public class LogoImage extends JPanel {
         private BufferedImage image;
         private int factor = 1; /** Creates a new instance of ImagePanel */
         public LogoImage() {
              this(new Dimension(600, 50));
         public LogoImage(Dimension sz) {
              //setBackground(Color.green);      
              setPreferredSize(sz);
         public void setImage(BufferedImage im) {
              image = im;
              if (im != null) {
                   setPreferredSize(
                        new Dimension(image.getWidth(), image.getHeight()));
              } else {
                   setPreferredSize(new Dimension(200, 200));
         public void setImageSizeFactor(int factor) {
              this.factor = factor;
         public void paintComponent(Graphics g) {
              super.paintComponent(g);
              //paint background 
              Graphics2D g2D = (Graphics2D) g;
              //Draw image at its natural size first. 
              if (image != null) {
                   g2D.drawImage(image, null, 0, 0);
         public static LogoImage createImage(String filename) { /* Stream the logo gif file into an image object */
              LogoImage logoImage = new LogoImage();
              BufferedImage image;
              try {
                   FileInputStream fileInput =
                        new FileInputStream("images/" + filename);
                   image = ImageIO.read(fileInput);
                   logoImage =
                        new LogoImage(
                             new Dimension(image.getWidth(), image.getHeight()));
                   fileInput.close();
                   logoImage.setImage(image);
              } catch (Exception e) {
                   System.err.println(e);
              return logoImage;
         public static void main(String[] args) {
              JFrame jf = new JFrame("testImage");
              Container cp = jf.getContentPane();
              cp.add(LogoImage.createImage("logo.gif"), BorderLayout.CENTER);
              jf.setVisible(true);
              jf.pack();
    }Now you can use this class anywhere in your pgram to add a JPanel

  • Help on moving of image across screen(java application,not applet)

    I've searched the entire internet and everything I've found is on java applets and I'm an alien to the differences between an applet and an application.
    This is actually for a java game I'm creating using Eclipse's visual editor and I'm failing miserably.
    What I'm trying to do is to find some java source code that enables me to start an image automatically moving across the screen that only stops when I click on it. I did find some applet codes but when I tried converting it to application code a load of errors popped out.
    Thanks for the help if there's any! I'm getting desperate here because the game's due this friday and I'm stuck at this stage for who knows how long.

    Here is one of the codes I found ,it's not mine but I'm trying to edit it into a java application instead of an applet...Sort of like: ' public class MovingLabels extends JFrame ' or some code that I can copy and paste into another java program.
    * Swing version.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MovingLabels extends JApplet
    implements ActionListener {
    int frameNumber = -1;
    Timer timer;
    boolean frozen = false;
    JLayeredPane layeredPane;
    JLabel bgLabel, fgLabel;
    int fgHeight, fgWidth;
    int bgHeight, bgWidth;
    static String fgFile = "wow.gif";
    static String bgFile = "Spring.jpg";
    //Invoked only when run as an applet.
    public void init() {
    Image bgImage = getImage(getCodeBase(), bgFile);
    Image fgImage = getImage(getCodeBase(), fgFile);
    buildUI(getContentPane(), bgImage, fgImage);
    void buildUI(Container container, Image bgImage, Image fgImage) {
    final ImageIcon bgIcon = new ImageIcon(bgImage);
    final ImageIcon fgIcon = new ImageIcon(fgImage);
    bgWidth = bgIcon.getIconWidth();
    bgHeight = bgIcon.getIconHeight();
    fgWidth = fgIcon.getIconWidth();
    fgHeight = fgIcon.getIconHeight();
    //Set up a timer that calls this object's action handler
    timer = new Timer(100, this); //delay = 100 ms
    timer.setInitialDelay(0);
    timer.setCoalesce(true);
    //Create a label to display the background image.
    bgLabel = new JLabel(bgIcon);
    bgLabel.setOpaque(true);
    bgLabel.setBounds(0, 0, bgWidth, bgHeight);
    //Create a label to display the foreground image.
    fgLabel = new JLabel(fgIcon);
    fgLabel.setBounds(-fgWidth, -fgHeight, fgWidth, fgHeight);
    //Create the layered pane to hold the labels.
    layeredPane = new JLayeredPane();
    layeredPane.setPreferredSize(
    new Dimension(bgWidth, bgHeight));
    layeredPane.addMouseListener(new MouseAdapter() {
    public void mousePressed(MouseEvent e) {
    if (frozen) {
    frozen = false;
    startAnimation();
    } else {
    frozen = true;
    stopAnimation();
    layeredPane.add(bgLabel, new Integer(0)); //low layer
    layeredPane.add(fgLabel, new Integer(1)); //high layer
    container.add(layeredPane, BorderLayout.CENTER);
    //Invoked by the applet browser only.
    public void start() {
    startAnimation();
    //Invoked by the applet browser only.
    public void stop() {
    stopAnimation();
    public synchronized void startAnimation() {
    if (frozen) {
    //Do nothing. The user has requested that we
    //stop changing the image.
    } else {
    //Start animating!
    if (!timer.isRunning()) {
    timer.start();
    public synchronized void stopAnimation() {
    //Stop the animating thread.
    if (timer.isRunning()) {
    timer.stop();
    public void actionPerformed(ActionEvent e) {
    //Advance animation frame.
    frameNumber++;
    //Display it.
    fgLabel.setLocation(
    ((frameNumber*5)
    % (fgWidth + bgWidth))
    - fgWidth,
    (bgHeight - fgHeight)/2);
    //Invoked only when run as an application.
    public static void main(String[] args) {
    Image bgImage = Toolkit.getDefaultToolkit().getImage(
    MovingLabels.bgFile);
    Image fgImage = Toolkit.getDefaultToolkit().getImage(
    MovingLabels.fgFile);
    final MovingLabels movingLabels = new MovingLabels();
    JFrame f = new JFrame("MovingLabels");
    f.addWindowListener(new WindowAdapter() {
    public void windowIconified(WindowEvent e) {
    movingLabels.stopAnimation();
    public void windowDeiconified(WindowEvent e) {
    movingLabels.startAnimation();
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    movingLabels.buildUI(f.getContentPane(), bgImage, fgImage);
    f.setSize(500, 125);
    f.setVisible(true);
    movingLabels.startAnimation();
    }

  • 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

  • Adding a java applet in Apex page

    Hello, I am trying to add a java applet to my page. This is what I do. I create an html region with source ;
    <applet width=300 height=300 codebase="#WORKSPACE_IMAGES#DrawingLines.class"></applet>
    and I upload DrawingLines.class file as a static file.
    When I run the page I see the java cup sign (with running circle around) but not the applet. Does this have to do anything with the browser security? My knowledge of Java is very limited, but I thought this should work.
    George

    I just feel like I have to answer this and I hope this is the last post in this thread.
    "I find it amusing that you have come to this forum demanding free technical support, and have posted over 200 times, but you yourself have never once answered somebody's question and gotten a helpful or correct reward"
    First of all, I have helped people on a few occasions , I don't know what kind of "helpful or correct reward" you are referring to but yes I have given useful answers and gotten "thank you" from a few members.
    Second, most of my posts are from year or more ago when I was learning Apex, I have very few posts in the last 6-12 months.
    Third, if nobody asks the questions then there will be no answers => there will be no forum. The very existence of this forum is based on people asking question so why should I be ashamed to "demand free technical hellp", isn't this what most people are doing here?
    The rest of your post is just words pretty much not saying anything (you might wanna try a carier in the politics) so I am not going to address it.
    Have a wonderful day.

  • Php adding java applet

    Hi, I new to java and php and I want to use php and using java applet. How to add java applet into php. Please Help me.

    How to add java applet into php. Please Help me. If it is working in html why don't you puts those tags in your php page.
    something like this. But i don't know your PHP server support java..
    <?php 
    Your php  here
       ?>
    <applet code="MyApplet.class" width=100 height=140></applet>
    <?php 
    more php  here
       ?>Edited by: sunish_jose on Jan 29, 2009 12:41 PM

  • Proxy Login Request on Java applets

    • 10.4.5 Client
    • Windows 2.3k ISA 2005 Proxy Server
    • Users' fileserving to Win2.3k - ADmitMac for AD integration
    The client is a test machine on which I build campus master NetInstall images. In my testing procedures I've come across a bizarre problem with Java in the browsers (IE, Safari, & FireFox).
    We use ISA proxy server with web filtering, and users must authenticate to the proxy. On a new user's first use of any browser, the proxy username & password are requested, and the Add to Keychain checkbox is available. If the user checks the box, no further proxy login requests are made; the user's Keychain is updated with the proxy information.
    On pages with Java applets, however, each and every applet will ask for a proxy login, but the login window does not offer a Add to Keychain checkbox! If a page has 15 applets on it, the user will be asked 15 times to authenticate against the proxy.
    Naturally, this is a BIG problem, especially when several of the sites our teachers use in classes and labs contain many Java applets.
    On the web, there is almost nothing concerning setting up Java with proxy servers, as all Apple Java from v. 1.4.2 onwards picks up proxy information from the system's network settings.
    On the Apple Developer site, Tech Note QA1263 demonstrates a way of setting HTTPS proxy settings by entering text strings in the 1.3.1 and 1.4.1 Plugin Settings apps Java Runtime Parameters. The same capability exists in the J2SE 5.0 Java Preferences app, too. Unfortunately, the Java applets do not use HTTPS, so far as I can tell, so this remedy is useless.
    Any clues I can pursue? Any help or fixes?
    Thanks in advance!
    Derek I Smith
    Systems & Network Admin
    Riverdale Country School
    www.riverdale.edu
    eMacs,g4s,QSs,B/Ws,iMacs,G5,G5 XServe, etc   Mac OS X (10.4.5)  

    After some more research with the J2SE 5.0 Java Preferences app, I turned on the Java console, booted Safari and went to my favorite Java applet - babynamewizard. This is the output of the console log. From what I can glean, the plug-in sees the proxy server settings as it should, and reports them.
    In addition, the J2SE 5.0 Java Preferences app allows you to turn off all security settings. No change in behavior.
    The Log:
    Java Plug-in 1.5.0
    Using JRE version 1.5.0_05 Java HotSpot(TM) Client VM
    User home directory = /Users/admin
    network: Loading user-defined proxy configuration ...
    network: Done.
    network: Loading proxy configuration from Netscape Navigator ...
    network: Done.
    network: Loading manual proxy configuration ...
    network: Done.
    network: Proxy Configuration: Manual Configuration
    Proxy: http=pcproxy.riverdale.edu:8080,https=pcproxy.riverdale.edu:8080,ftp=pcproxy.ri verdale.edu:8080,gopher=pcproxy.riverdale.edu:8080,socks=pcproxy.riverdale.edu:8 080
    Proxy Overrides:
    basic: Cache is enabled
    basic: Location: /Users/admin/Library/Caches/Java/cache/javapi/v1.0
    basic: Maximum size: unlimited
    basic: Compression level: 0
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    p: reload proxy configuration
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    basic: Referencing classloader: sun.plugin.ClassLoaderInfo@fb6354, refcount=1
    basic: Added progress listener: sun.plugin.util.GrayBoxPainter@dc0e7a
    basic: Loading applet ...
    basic: Initializing applet ...
    basic: Starting applet ...
    network: Connecting http://babynamewizard.com/namevoyager/nametide2.jar with proxy=HTTP @ pcproxy.riverdale.edu/172.16.1.52:8080
    network: Connecting http://babynamewizard.com/namevoyager/nametide2.jar with cookie "s_cc=true; s_sq=%5B%5BB%5D%5D"
    network: Firewall authentication: site=pcproxy.riverdale.edu/172.16.1.52:8080, protocol=http, prompt=ENKI.riverdale.edu, scheme=basic
    basic: User selected: 0
    ~ ~ ~
    The proxy login window appears at this point and I authenticate to the proxy
    The log continues...
    ~ ~ ~
    network: Connecting http://babynamewizard.com/namevoyager/nametide2.jar with proxy=HTTP @ pcproxy.riverdale.edu/172.16.1.52:8080
    basic: Loading http://babynamewizard.com/namevoyager/nametide2.jar from cache
    basic: No certificate info, this is unsigned JAR file.
    network: Connecting http://babynamewizard.com/namevoyager/namedb.zip with proxy=HTTP @ pcproxy.riverdale.edu/172.16.1.52:8080
    network: Connecting http://babynamewizard.com/namevoyager/namedb.zip with cookie "s_cc=true; s_sq=%5B%5BB%5D%5D"
    Columns found: 28
    Num years: 13
    YEAR NAME: 1880s
    YEAR NAME: 1890s
    YEAR NAME: 1900s
    YEAR NAME: 1910s
    YEAR NAME: 1920s
    YEAR NAME: 1930s
    YEAR NAME: 1940s
    YEAR NAME: 1950s
    YEAR NAME: 1960s
    YEAR NAME: 1970s
    YEAR NAME: 1980s
    YEAR NAME: 1990s
    YEAR NAME: 2004
    Num names: 5251
    0 --> 923475.0
    1 --> 915444.0
    2 --> 905002.0
    3 --> 910731.0
    4 --> 915165.0
    5 --> 924335.0
    6 --> 938721.0
    7 --> 940141.0
    8 --> 923814.0
    9 --> 869609.0
    10 --> 848116.0
    11 --> 800666.0
    12 --> 759055.0
    Rank misses: 21
    0.15
    0.4475
    0.395
    0.3425
    0.29000002
    0.23750001
    0.185
    0.48250002
    0.43
    0.3775
    0.325
    0.2725
    0.22
    0.1675
    0.465
    0.4125
    0.36
    0.3075
    0.255
    0.2025
    ~ ~ ~
    The applet runs

  • PROXY SETTING ERROR - LOADING JAVA APPLET FAILED

    I have the most current version of Java (confirmed) installed l.5.0. When I do the Java Virtual Test, I fail at the proxy setting with the red X. I have tried everything recommended at "Configuration Check List" and I have also chatted with microsoft techs who recommended that I register certain .dll's among other things. Nothing has worked. Is the Java Control Panel the same thing as the Java Plug-in Control Panel? I only have the JCP. Could that be the problem? I also get a message in other areas that scripting is not enabled. Is this all related?

    Thought I should add this to further explain what is happening ... Hope you can help!
    Java Plug-in 1.5.0_06
    Using JRE version 1.5.0_06 Java HotSpot(TM) Client VM
    User home directory = C:\Documents and Settings\Compaq_Owner
    network: Loading user-defined proxy configuration ...
    network: Done.
    network: Loading proxy configuration from Internet Explorer ...
    network: Done.
    network: Loading direct proxy configuration ...
    network: Done.
    network: Proxy Configuration: No proxy
    basic: Cache is enabled
    basic: Location: C:\Documents and Settings\Compaq_Owner\Application Data\Sun\Java\Deployment\cache\javapi\v1.0
    basic: Maximum size: unlimited
    basic: Compression level: 0
    c: clear console window
    f: finalize objects on finalization queue
    g: garbage collect
    h: display this help message
    l: dump classloader list
    m: print memory usage
    o: trigger logging
    p: reload proxy configuration
    q: hide console
    r: reload policy configuration
    s: dump system and deployment properties
    t: dump thread list
    v: dump thread stack
    x: clear classloader cache
    0-5: set trace level to <n>
    basic: Registered modality listener
    liveconnect: Invoking JS method: document
    liveconnect: Invoking JS method: URL
    basic: Referencing classloader: sun.plugin.ClassLoaderInfo@f73c1, refcount=1
    basic: Added progress listener: sun.plugin.util.GrayBoxPainter@19a0c7c
    basic: Loading applet ...
    basic: Initializing applet ...
    basic: Starting applet ...
    network: Connecting http://www.java.com/applet/testvm.class with proxy=DIRECT
    network: Connecting http://www.java.com/applet/testvm.class with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/applet/testvm.class from cache
    TestVM 3.1 kc
    Copyright (c) 2005 Sun Microsystems, Inc.
    All Rights Reserved.
    basic: Loaded image: http://www.java.com/en/img/download/t1.gif
    basic: Loaded image: http://www.java.com/en/img/download/t2.gif
    basic: Loaded image: http://www.java.com/en/img/download/t3.gif
    basic: Loaded image: http://www.java.com/en/img/download/t4.gif
    basic: Loaded image: http://www.java.com/en/img/download/t5.gif
    basic: Loaded image: http://www.java.com/en/img/download/t6.gif
    basic: Loaded image: http://www.java.com/en/img/download/t7.gif
    network: Connecting http://www.java.com/en/img/download/t1.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t1.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t1.gif from cache
    network: Connecting http://www.java.com/en/img/download/t2.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t2.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t2.gif from cache
    network: Connecting http://www.java.com/en/img/download/t3.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t3.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t3.gif from cache
    network: Connecting http://www.java.com/en/img/download/t4.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t4.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t4.gif from cache
    network: Connecting http://www.java.com/en/img/download/t5.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t5.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t5.gif from cache
    network: Connecting http://www.java.com/en/img/download/t6.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t6.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t6.gif from cache
    network: Connecting http://www.java.com/en/img/download/t7.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t7.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t7.gif from cache
    basic: Stopping applet ...
    basic: Removed progress listener: sun.plugin.util.GrayBoxPainter@19a0c7c
    basic: Finding information ...
    basic: Releasing classloader: sun.plugin.ClassLoaderInfo@f73c1, refcount=0
    basic: Caching classloader: sun.plugin.ClassLoaderInfo@f73c1
    basic: Current classloader cache size: 1
    basic: Done ...
    basic: Joining applet thread ...
    basic: Destroying applet ...
    basic: Disposing applet ...
    basic: Quiting applet ...
    basic: Joined applet thread ...
    basic: Unregistered modality listener
    basic: unique id: com_sun_deploy_AboutJava-1.5.0
    basic: server port at: 2309
    basic: getSingleInstanceFilename: C:\Documents and Settings\Compaq_Owner\Application Data\Sun\Java\Deployment\tmp\si\com_sun_deploy_AboutJava-1.5.0_2309
    basic: waiting connection
    network: Connecting socket://127.0.0.1:2309 with proxy=DIRECT
    basic: recv: javaws.singleinstance.stop
    basic: getSingleInstanceFilename: C:\Documents and Settings\Compaq_Owner\Application Data\Sun\Java\Deployment\tmp\si\com_sun_deploy_AboutJava-1.5.0_2309
    basic: getSingleInstanceFilename: C:\Documents and Settings\Compaq_Owner\Application Data\Sun\Java\Deployment\tmp\si\com_sun_deploy_AboutJava-1.5.0_2309
    basic: removed SingleInstanceFile: C:\Documents and Settings\Compaq_Owner\Application Data\Sun\Java\Deployment\tmp\si\com_sun_deploy_AboutJava-1.5.0_2309
    basic: Registered modality listener
    liveconnect: Invoking JS method: document
    liveconnect: Invoking JS method: URL
    basic: Referencing classloader: sun.plugin.ClassLoaderInfo@f73c1, refcount=1
    basic: Added progress listener: sun.plugin.util.GrayBoxPainter@1e228bc
    basic: Loading applet ...
    basic: Initializing applet ...
    basic: Starting applet ...
    TestVM 3.1 kc
    Copyright (c) 2005 Sun Microsystems, Inc.
    All Rights Reserved.
    basic: Loaded image: http://www.java.com/en/img/download/t1.gif
    basic: Loaded image: http://www.java.com/en/img/download/t2.gif
    basic: Loaded image: http://www.java.com/en/img/download/t3.gif
    basic: Loaded image: http://www.java.com/en/img/download/t4.gif
    basic: Loaded image: http://www.java.com/en/img/download/t5.gif
    basic: Loaded image: http://www.java.com/en/img/download/t6.gif
    basic: Loaded image: http://www.java.com/en/img/download/t7.gif
    network: Connecting http://www.java.com/en/img/download/t1.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t1.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t1.gif from cache
    network: Connecting http://www.java.com/en/img/download/t2.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t2.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t2.gif from cache
    network: Connecting http://www.java.com/en/img/download/t3.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t3.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t3.gif from cache
    network: Connecting http://www.java.com/en/img/download/t4.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t4.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t4.gif from cache
    network: Connecting http://www.java.com/en/img/download/t5.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t5.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t5.gif from cache
    network: Connecting http://www.java.com/en/img/download/t6.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t6.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t6.gif from cache
    network: Connecting http://www.java.com/en/img/download/t7.gif with proxy=DIRECT
    network: Connecting http://www.java.com/en/img/download/t7.gif with cookie "JSESSIONID=E4C78C2C09A916295DDBD9EAEE101C10.tomcat4; s_cc=true; s_sq"
    basic: Loading http://www.java.com/en/img/download/t7.gif from cache
    basic: unique id: com_sun_deploy_AboutJava-1.5.0
    basic: server port at: 2335
    basic: getSingleInstanceFilename: C:\Documents and Settings\Compaq_Owner\Application Data\Sun\Java\Deployment\tmp\si\com_sun_deploy_AboutJava-1.5.0_2335
    basic: waiting connection
    basic: Modality pushed
    network: Connecting socket://127.0.0.1:2335 with proxy=DIRECT
    basic: Modality popped
    basic: recv: javaws.singleinstance.stop
    basic: getSingleInstanceFilename: C:\Documents and Settings\Compaq_Owner\Application Data\Sun\Java\Deployment\tmp\si\com_sun_deploy_AboutJava-1.5.0_2335
    basic: getSingleInstanceFilename: C:\Documents and Settings\Compaq_Owner\Application Data\Sun\Java\Deployment\tmp\si\com_sun_deploy_AboutJava-1.5.0_2335
    basic: removed SingleInstanceFile: C:\Documents and Settings\Compaq_Owner\Application Data\Sun\Java\Deployment\tmp\si\com_sun_deploy_AboutJava-1.5.0_2335

Maybe you are looking for

  • Big lcd screen in conjunction with my laptop

    I have been running LR on my laptop with a 15.4 screen. Although it isn't state of the art dual core pc, it runs ok and I am happy with it. I was thinking of getting a bigger laptop with a 17 inch screen, but now I'm thinking of getting a big 20 inch

  • Scrap sales

    Can any buddy let me know how do we configure Scrap sales in SD and what is the goods movement type for quality to scrap? Mail id : [email protected]

  • Status updation of Shop floor paper

    Hi expert    I have created one Shop floor printout in Smart forms.i have created my own program.In the statndard printout   status will be changed to PRT when the print out taken.I want to in coperate this feature in my program also. Please guide me

  • IMac Intel

    Hi. I have some trouble with my iphoto. When I've clicked on one of my albums, at the end of the album title I get a triangle symbol with a error message. The error reads as follows: An error occured with the publication of "Album Name".             

  • How can i install free apps on the ipod touch?

    whenever i click the install button, it takes me to varify my account. how can i make it not go to that?