How get image in applet?

Please read see if you can help me ... I have a applet... I bring a panel on a applet.. and then on that panel i bring a another panel and then on this panel i am trying to read an image... but image does not show..
can any one help me?
package javaapplication25;
import java.awt.*;
import java.net.*;
public class IconOnApplet extends javax.swing.JApplet {
    static  Image img  ;
    /** Initializes the applet IconOnApplet */
    public void init() {
        try {
            java.awt.EventQueue.invokeAndWait(new Runnable() {
                public void run() {
                    initComponents();
              panelOnPanel iop = new panelOnPanel();
              getContentPane().add(iop, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 70,310, 70));
            URL address = null;
            try{
                System.out.println("DIR:" + System.getProperty("user.dir"));
                address = new URL("file:"+System.getProperty("user.dir")+ "\\" + "test2.gif")  ;
                System.out.println("File read ok" + address);
            }catch (Exception e){System.out.println(" file reading problem:"+e);}
            img =  Toolkit.getDefaultToolkit().getImage(address);
        } catch (Exception ex) {
            ex.printStackTrace();
    /** This method is called from within the init() method to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
        jRadioButton1 = new javax.swing.JRadioButton();
        getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        jRadioButton1.setText("jRadioButton1");
        getContentPane().add(jRadioButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(150, 30, -1, -1));
    // </editor-fold>
    // Variables declaration - do not modify
    private javax.swing.JRadioButton jRadioButton1;
    // End of variables declaration
package javaapplication25;
public class panelOnPanel extends javax.swing.JPanel {
    /** Creates new form panelOnPanel */
    public panelOnPanel() {
        initComponents();
               ImgOnPanel iop = new ImgOnPanel();
              this.add(iop, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 70,310, 70));
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
        setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout());
        setBackground(new java.awt.Color(0, 204, 204));
    // </editor-fold>
    // Variables declaration - do not modify
    // End of variables declaration
    public static void main(String[] args){
        panelOnPanel pnl = new panelOnPanel();
        try {
            pnl.setVisible(true);
            Thread.sleep(2000);
        }catch (Exception e){}
package javaapplication25;
import java.awt.*;
import java.net.*;
public class ImgOnPanel extends javax.swing.JPanel {
    /** Creates new form ImgOnPanel */
Image img ;
    public ImgOnPanel() {
        initComponents();
                        URL address = null;
            try{
                System.out.println("DIR:" + System.getProperty("user.dir"));
                address = new URL("file:"+System.getProperty("user.dir")+ "\\" + "test2.gif")  ;
                System.out.println("File read ok" + address);
            }catch (Exception e){System.out.println(" file reading problem:"+e);}
            img =  Toolkit.getDefaultToolkit().getImage(address);
        public void paint(Graphics g){
        //     repaint();
        //    validate();
        if (this.img != null){
                  g.drawImage(img,0,50,100,100, this);
           // this.setBackground(Color.CYAN);
            //       g.drawLine(20,20,100, 100);
            System.out.println(" Draw..");
        }else
            System.out.println("null Draw..");
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
    private void initComponents() {
        setLayout(new java.awt.BorderLayout());
        setBackground(new java.awt.Color(204, 255, 255));
    // </editor-fold>
    // Variables declaration - do not modify
    // End of variables declaration
}

there are free codes availabe on jguru and some otherf websites just go there and search signing an applet and i hope that u will acquire the desired code ... some other sites also provide free code to test applets ..... try some earch engines ... plz
i have that code back home so thats why i cant send u that rit now so if u dont get that code so plz feel free to ask me again.

Similar Messages

  • How get image of component from graphics (or create image of component)?

    How do I grab an image of a component while in it's paintComponent method? I tried calling super.paintComponent( g ) and then doing a robot.createScreenCapture (using the bounds of the component), but that doesn't work properly. It doesn't paint the back ground (and I think it's not painting the children).
    Any ideas?

    OK, I figured it out (and with a cool twist since the back image is not opaque).
    * This stuff allows us to keep the rounded corners of the component which has
    * the edges as see-through. Otherwise, it captures those transparent parts
    * as black.
    GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
    GraphicsDevice gd = ge.getDefaultScreenDevice();
    GraphicsConfiguration gc = gd.getDefaultConfiguration();
    // Create an image that supports transparent pixels
    BufferedImage bImage = gc.createCompatibleImage(getWidth(), getHeight(), Transparency.BITMASK);
    * And now this is how we get an image of the component
    Graphics2D g = bimage.createGraphics();
    //Then use the current component we're in and call paint on this graphics object
    paint( g );
    //The image now has the graphics of that component including transparent pixels!

  • Forms 9i: How get image from database?

    Hi!
    I want to get a image (GIF,JPG, TIFF, etc.) that is stored in database table (as blob) in Image_Item (No Database Block) by Trigger (PL/SQL) way.
    In a Block that is database=yes It's OK, the Query do this in automatic.
    I know that "select column into block_item from db_table" is not possible.
    Thanks!

    I have a multi-row block for entry data, so was thinking in a image item (No Database) in the same block for show a GIF when the user entry one code; then I will not need any thing more for show the correct GIF in each row when the user scroll them.
    The other way, if I create one block-image_item for each row that is displaying; then I need create a Procedure por Syncronize the data row with the GIF; this mean a lot re-quering when the user is scrolling the rows. This is the reason I searching one Instruccion equivalent to read_image_file (but in place Operating System from database) or dbms_lob.read( ... ) but the target must be a block image item.
    Thanks.

  • How can I use applet to get the desktop image of client

    hi,I have a question to ask u.
    How can I use applet to get the desktop image of client? Now I develop a web application and want user in the client to get his current image of the screen.And then save as a picture of jpeg format ,then upload it to the server?
    I have done an application to get the screen image and do upload file to server in a servlet with the http protocal.

    Since the desktop image is on the client's local hard drive, you'll need to look at trusted applets first.

  • When browsing a new library that I created, the browser shows dotted lines around grey rectangles, no images. When I double click on a rectangle the image appears. How do I get images to appear in the browser rectangles?

    When browsing a new library that I created and exported onto an external hard drive, the browser shows dotted lines around grey rectangles, no images. When I double click on a rectangle, the image appears, but all the other rectangles remain empty - no image. How do I get images to appear in the browser rectangles? I am viewing this on a second computer (an older intel duo iMac), not the one I created the library on (a MacBook Pro). Both computers have Aperture 3.2.4 installed. When I return the external to the MacBook, all images appear in browser rectangles. What's happening on the iMac?

    You may have a problem with the permissions on your external volume. Probably you are not the owner of your library on the second mac.
    If you have not already done so, set the "Ignore Ownership on this Volume" flag on your external volume. To do this, select the volume in the Finder and use the Finder command "File > Get Info" (or ⌘I).
    In the "Get Info" panel disclose the "Sharing & Permissions" brick, open the padlock, and enable the "Ignore Ownership on this Volume" flag. You will have to authentificate as administrator to do this.
    Then run the "Aperture Library First Aid Tools" on this library and repair the permissions. To launch the "First Aid Tools" hold down the ⌥⌘-key combination while you double click your Aperture Library. Select "Repair Permissions" and run the repair; then repeat with "Repair Database". Do this on the omputer where you created the library and where you can see the thumbnails.
    Then check, if you now are able to read the library properly on your iMac.
    Regards
    Léonie

  • How many images per sec can I get from ImageIO.read(url) ??????

    Hello,
    In my program I read images from a url...I'm wondering how many images I can get with ImageIO.read(url) per second..
    Hereby is the code that I'm using:
    import java.awt.*; //Contains all of the classes for creating user interfaces and for painting graphics and images
    import java.awt.event.*;//Provides interfaces and classes for dealing with different types of events fired by AWT components
    import java.awt.image.*;//Provides classes for creating and modifying images
    import java.io.*;//Provides for system input and output through data streams, serialization and the file system
    import java.net.URL;
    import javax.imageio.*;//The main package of the Java Image I/O API.
    import javax.swing.*;//Provides a set of "lightweight" (all-Java language) components that, to the maximum degree possible, work the same on all platforms.
    import java.text.*;
    import java.text.SimpleDateFormat;
    import java.util.Date;
    public class getPic extends Component{
    private BufferedImage img;
        static int n=0;
        private URL url;
        private DateFormat dateFormat;
        private Date date;
        private String s;
        private String str1= ".jpeg";
        private String str2="C:\\Users\\";
        private String str3;
        private String str4;
          public getPic() {
         try {
                  url = new URL("http://"); //a url that gives a real-time image
                  img = ImageIO.read(url);
                } catch (IOException e) {
               System.err.println("Unable to read file");
    public void savePic(){
    try{
    n++;
    str3=str2.concat(Integer.toString(n-1));
                        str4=str3.concat(str1);
                        ImageIO.write(img, "jpeg" , new File(str4));
                    } catch(IOException e) {
                      System.err.println("Unable to output results");
    @Override
        public Dimension getPreferredSize() {
            if (img == null) {
               return new Dimension(100,100);
            } else {
               return new Dimension(img.getWidth(), img.getHeight());
        @Override
          public void paint(Graphics g) {  //http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Paint.html
            g.drawImage(img, 10, 10, null);//http://java.sun.com/j2se/1.4.2/docs/api/java/awt/Graphics.html
        public static void main(String[] args) throws IOException {
           JFrame f = new JFrame(" Image without processing!!");
           f.addWindowListener(new WindowAdapter(){//http://java.sun.com/j2se/1.4.2/docs/api/java/awt/event/WindowListener.html
                @Override
                    public void windowClosing(WindowEvent e) {
                        System.exit(0);
        int i=0;
        for( ; ; ){
            i++;
            getPic pi = new getPic();
            pi.savePic();
            f.add(pi);
            f.pack();  //Causes this Window to be sized to fit the preferred size and layouts of its subcomponents.
            f.setVisible(true);
         try
            Thread.sleep(1000);
            }catch (InterruptedException ie)
            System.out.println(ie.getMessage());
    }Thank you in advance for your answers
    Joan

    Finally I solved my problem(getting as many images as possible from a url infinitely) using the above code:
    import java.net.*;
    import java.io.*;
    public class UserApplication {
        private static int n=0;
        String url;
      public void UserApplication(){
        public static void main(String[] args) throws Exception {
            UserApplication app= new UserApplication();
            for(;;){
            app.urlStr();
        private void urlStr(){
            try{
                url= "http://mplamplampla/frame.php/";
                HttpURLConnection con=(HttpURLConnection) ((new URL(url).openConnection()));
                BufferedOutputStream out = new BufferedOutputStream( new FileOutputStream("C:\\Users\\mpla\\Desktop\\" + n + ".jpeg"));
                con.setDoInput(true);
                con.setDoOutput(false);
                con.setRequestMethod("GET");
                BufferedInputStream in = new BufferedInputStream(con.getInputStream());
                int bt = 0;
                byte[] buffer = new byte[4096];
                while ((bt = in.read(buffer, 0, 4096)) > -1) {
                  out.write(buffer, 0, bt);
                in.close();
                out.close();
                System.out.println("Image " + n + " saved");
                n++;
                } catch (Exception e) {e.printStackTrace();}
    }

  • How do I get images to automatically center in a picture box?

    How do I get images to automatically center in a picture box (e.g. place a picture box on a master page and set it so that any image placed inside will automatically center, but not scale)? This was a simple procedure in CS5 (set "Fitting Options" to 'center' by clicking on the center box in the 9-box centering tool) but seems to have disappeared in CS6/CC. Am I missing something?

    Hi and thanks. Actually, my problem is with setting the properties of the image frame to 'align center' before an image is placed, allowing me to place large numbers of images and having them automatically center instead of me centering each one manually. Even when I create an object style the frame will not hold any alignment settings and apply them to the image being placed (unless some manner of scaling has been chosen, which is not something I want). There are work-arounds I have used but it would be nice to be able to just put a picture box on a master page, set it to align it's contents to the center and just be done with it . Thanks though.

  • How to move multiple images in applet

    Hi,how to move multiple images in applet or random images in applet .
    Means moving images.gif around the applet with different starting point ,help me to create that move method ..

    why don't you check the tumbling duke applet as provided free in this site? :-)

  • How to check image GPS data and get image file from image field

    Hello,
    I have some trouble and want to fix this problem.
    1. I want to validate image file before its attached in image field about the image file have a GPS data or not. Have any way that can be check about image has contained a GPS data?
    2. After validate image and PDF form is upload to the server. I want to get image file that embed in image field, because I have to extract image from PDF form and store this image in project image folder. If this topic can be fix by code script please give me some example code.
    Thakyou for every comment and suggestion
    Best Regards,
    Mai

    Hi Naill,
    First I have to say thankyou for your answer.
    About my (1) question, My image fields have set to be a embedded data and I try to test many example script of image fields.I can get image content type, image size. But that not work when I used ImageField1.desc.embeddedHref.value. It's response as "Unknown Embedded URI". Therefore, image field is and embedded data. How can I access filename?
    (2) In that forum. As I see, his problem is about how to automate change image field with href image file. But I want to extract an exist embedded image in PDF form to normal image file with original metada (such as extract image filed to .JPEG with GPS data. Same as before attached in PDF form.). There has any concept or solution in this problem?
    Best Regards,
    Mai

  • How do I get Image Capture to recognize a printer on my network?

    I just got a new MacBook Pro. I have my epson printer on my network. How do I get Image Capture to recognize that I have a printer. Nothing comes up on devices. I'm sort of stabbing in the dark at network settings and I downloaded the latest Epson driver. Nothing seems to work. Can anyone help? Suz

    In Image Capture, a network printer / scanner will appear under "Shared". If it is hidden, a number will appear adjacent to it, representing the number of hidden devices.
    If it still does not appear, try resetting the printing system: Mac OS X: How to reset the printing system
    After you do that you will need to add the device again according to the instructions here:
    OS X Mavericks: Set up a printer
    Follow the instructions below Add a network printer
    Also read:
    Troubleshooting printer issues in OS X

  • How do i get the java applet to stop appearing on the dock?

    how do i get the java applet to stop appearing on the dock? it seems to do this for pop-up windows.  also, the text on the popup window is different, how can I change that to normal?   this all started when i loaded MAC OS X 10.6.8

    You could try to block popup windows.
    Safari / Preferences / Security
    Also, go to Safari / Preferences / Extensions and clean out everything there.

  • How draw image into frame in applet

    How draw image into frame in applet.Please give my simple example code.

    http://search.java.sun.com/search/java/index.jsp?qt=%2Bdraw+%2Bimage+%2Bpanel+%2Bhow&nh=10&qp=&rf=1&since=&country=&language=&charset=&variant=&col=javaforums

  • How can a trusted applet get permissions on server

    Hello all,
    I have just now read some tutorial about Trusted Applet and not even experimented one. So my knowledge is absolutely zero.
    I would like to use Trusted Applets in my environment which I describe below:
    I have a database server on a Linux machine. On the same machine I have Apache web server. I want to deploy an applet in the Apache server so that all my clients can use it with a web browser. I want my applet to get permissions to connect to the database and retrieve the results etc., when any client uses my applet by connecting to the Apache server.
    According to what I understand from the Trusted Applet tutorial, they are used in an exactly opposite environment, meaning: to get permissions on the client machine to access the local file system etc., and their purpose is not to get permissions on the server.
    Could anyone please give me some detailed instructions on how to use Trusted Applet in my environment.
    Best regards,
    Gopal.

    Hello,
    I forgot to add one point: my Server machine has JDK 1.4.1_01
    Best,
    Gopal.

  • How to get image using Http and how to save in Smulator

    Hi guys,
    Am working in black berry bold. i dont know how to get image using htp connection and one more thing i need to save this image in side simulator directory............. what are the specific API i should...
    Guide me.........

    If you want the input image size you need to pass it in as parameters.
    A discussion thread on this topic is:
    http://forums.adobe.com/thread/29948
    -- Daniel R. <[email protected]> http://danielr.neophi.com/

  • How get File Type Icon Image

    how get File Type Icon Image (Windows )
    FileSystemView.getSystemIcon( File );works in swing application, can not be used for javafx.scene.image.ImageView;

    Hmm, good question.
    Looking at the FileChooser, it looks like the native chooser is used so possibly the JFX guys didn't have to expose access to the icons to make it work. You might want someone to confirm, but my guess is there is no equivalent yet in JFX.
    Assuming there's nothing, you could try the hacks in here to convert the image: Image conversion between AWT and FX
    Failing that you're probably looking at raising a JIRA feature request to get it in a future release.
    Cheers,
    zonski
    Did you find this answer useful? If so, please mark as 'Correct' or 'Helpful'.

Maybe you are looking for