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

Similar Messages

  • Help! How to Open a Frame from applet with

    Hey all. I need help =).
    I want:
    1. Have 1 class extends applet with running thread (this far no prob)
    2. Open a new frame from the applet (no prob)
    3. Start a new thread which is operating "inside" the new Frame/class
    4. Draw a simple Rect in the new Frame with the new thread to test that the graphics work.
    Plz help,
    ~Trobsky

    �rr..... i cant draw on the Frame =(.
    Heres the code:

    public class Fonster extends java.applet.Applet {
         Frame myFrame;
         Fri friFonster=new Fri();
         public void init() {
              myFrame=new Frame();
              myFrame.resize(300,300);
              myFrame.show();
              myFrame.add(friFonster);
              friFonster.init();
              friFonster.start();
         public void paint(Graphics g)
              g.drawRect(10,10,100,100);
    public class Fri extends java.applet.Applet {
         public void init(){
              repaint();
         public void paint(Graphics g)
              g.drawRect(10,10,200,200);

  • How to call java frame in applet?

    i have a frame which i want to show in web browser i dont want to convert frame into applet if there is any pls tell

    Weren't you just told that a frame is a top level
    component?!Probably hoping for a magic solution. If I ask for the easiest path through the Himalaya often enough, the mountains might vanish...

  • Draw Image on Frame without Graphics

    I'm using:
    public class Main extends Frame {And I want to draw an image inside the frame WITHOUT{b} using:
    java.awt.Graphics;Edited by: Nickasaur on Aug 28, 2009 4:25 PM

    There´s a tutorial on that matter here .
    But for the beginning, it might be helpful for you to know that you can at any time call the getGraphics() Method of any child of java.awt.Component to get its Graphics object. Still, I´m not sure if that is good practice.
    I´d take the tutorial if I were you.
    Edited by: anotherAikman on Aug 28, 2009 4:45 PM

  • Putting images into frames

    I'm making diamnond shaped frames to put images in and I need some help. I'm making a square and rotating it but the image rotates as well. How do I do this? I have indesign CS5. Thanks!

    Thanks! I'm attaching a screen shot. I'm trying to duplicate the pdf that's on the right. Thanks again!

  • How to load a frame in applet...

    i tried this code but ,i cannot see anything on the screen....
         Panel p=new Panel();
         Frame cf=new CheckFrame();
         p.add(cf);
         add(p);
         cf.show();
         cf.setVisible(true);
         cf.setSize(300,300);

         Panel p=new Panel();
         Frame cf=new CheckFrame();
         p.add(cf);You're sure you want to add the frame to the panel and not the panel to the frame? I think you've messed something up there.
    I use frames opened up from an applet myself and usually get them to work by doing..
    JFrame f = new JFrame();
    //add the components
    f.pack();
    f.show();..as you would do it when writing a standalone application.
    HTH,
    kelysar

  • Automatically placing images into frames?

    Hello all, I really hope im in the right part of this forum
    anyway, I work at a print shop, we layout our gang runs in indesign, our files are automatically renamed to 88888-F.xxx and 88888-B.xxx (front/back, xxx being the extension jpg/pdf/tiff/etc)
    the layouts are vertically symmetrical
    is there anyway I can manually drag 88888-F into its frame and have 88888-B automatically be placed into the frame on the other side?
    Thanks in advance!

    I not aware of a process that allows you to use a manual drag and drop.  Not sure if the event listener would work here. What you could do is using the ImageCatalog.jsx that comes in the sample JavaScript is create a script that selects a folder or files and places then in the order you require.

  • CS3-style of placing the images inside frames in CS4.

    Hi everyone,
    I'm trying to find a way to have the cs3 - style of placing the images into frames in the new Indy CS4. I mean when I hit cmd+D and draw a frame I don't want any scaling / fitting of the placed image. I know there's no scaling if you drop an image into existing frame but when you draw one on-the-fly it's either the frame that keeps the proportions of the image or when you hold shift the image gets scaled to fit into.
    I'd rather have the old style placing as an option - but didn't find such a switch anywhere in the prefs.
    Thnx.
    R.

    Interesting request. I wouldn't have thought anyone would want the older way of creating images in frames, but I guess there's always someone who wants the old ways.
    I can't find any preference to restore the behavior back to the pre-CS4 way.
    But if you want to work with images the old way, you can. Your commands are just a little different, in a different order. But you may actually save a step.
    Consider:
    b In CS3 you had to do the following:
    1. Drag to create a frame.
    2. Switch to the Direct Selection tool.
    3. If desired, change the position the image inside the frame
    4. If desired, scale the image inside the frame
    5. If desired, use the Fitting commands to fit the image inside the frame.
    b In CS4 you have to do the following:
    1. Drag to create a frame.
    2. Switch to the Direct Selection tool.
    3. Scale the image inside the frame.
    4. Position the image inside the frame.
    However, step 5 is probably eliminated as you already started with the image fitting inside the frame.
    I agree no one likes to need to learn new work habits, but it's not such a big deal.

  • 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

  • How to put image into pdf file in which image is set it in particuler frame size

    hi, i m creating app for generate pdf in which i can set image into pdf but the image sizze is large so the image is display over the text and how can i set text into pdf and also how to set textfilelds data into pdf or tableview data into pdf.help me plz

    Are you looking for image in selection column or as a separate column?
    --Shiv                                                                                                                                                                               

  • How do I insert an image into a Frame?

    Hi!
    I need to insert an image into a Frame(java.awt.Frame) and I can't use swing, I need to use only awt.
    Witch class do I use to insert an image?
    Using swing I used a JLabel and the setIcon method. But now I can use only AWT.

    Out of curiosity, why are you limiting yourself to AWT? Why not use Swing / JFrame, etc..
    I think this is a situation where answering your direct question is the wrong way to go. Perhaps its more of a design question that needs to be addressed.
    Message was edited by:
    petes1234

  • Loading an image into an Applet from a JAR file

    Hello everyone, hopefully a simple question for someone to help me with!
    Im trying to load some images into an applet, currently it uses the JApplet.getImage(url) method just before registering with a media tracker, which works but for the sake of efficiency I would prefer the images all to be contained in the jar file as oppossed to being loaded individually from the server.
    Say I have a class in a package eg, 'com.mydomain.myapplet.class.bin' and an images contained in the file structure 'com.mydomain.myapplet.images.img.gif' how do I load it (and waiting for it to be loaded before preceeding?
    I've seen lots of info of the web for this but much of it is very old (pre 2000) and im sure things have changed a little since then.
    Thanks for any help!

    I don't touch applets, so I can't help you there, but here's some Friday Fun: tracking image loading.
    import java.awt.*;
    import java.awt.image.*;
    import java.beans.*;
    import java.io.*;
    import java.net.*;
    import javax.imageio.*;
    import javax.imageio.event.*;
    import javax.imageio.stream.*;
    import javax.swing.*;
    public class ImageLoader extends SwingWorker<BufferedImage, Void> {
        private URL url;
        private JLabel target;
        private IIOReadProgressAdapter listener = new IIOReadProgressAdapter() {
            @Override public void imageProgress(ImageReader source, float percentageDone) {
                setProgress((int)percentageDone);
            @Override public void imageComplete(ImageReader source) {
                setProgress(100);
        public ImageLoader(URL url, JLabel target) {
            this.url = url;
            this.target = target;
        @Override protected BufferedImage doInBackground() throws IOException {
            ImageInputStream input = ImageIO.createImageInputStream(url.openStream());
            try {
                ImageReader reader = ImageIO.getImageReaders(input).next();
                reader.addIIOReadProgressListener(listener);
                reader.setInput(input);
                return reader.read(0);
            } finally {
                input.close();
        @Override protected void done() {
            try {
                target.setIcon(new ImageIcon(get()));
            } catch(Exception e) {
                JOptionPane.showMessageDialog(null, e, "Error", JOptionPane.ERROR_MESSAGE);
        //demo
        public static void main(String[] args) throws IOException {
            final URL url = new URL("http://blogs.sun.com/jag/resource/JagHeadshot.jpg");
            EventQueue.invokeLater(new Runnable(){
                public void run() {
                    launch(url);
        static void launch(URL url) {
            JLabel imageLabel = new JLabel();
            final JProgressBar progress = new JProgressBar();
            progress.setBorderPainted(true);
            progress.setStringPainted(true);
            JScrollPane scroller = new JScrollPane(imageLabel);
            scroller.setPreferredSize(new Dimension(800,600));
            JPanel content = new JPanel(new BorderLayout());
            content.add(scroller, BorderLayout.CENTER);
            content.add(progress, BorderLayout.SOUTH);
            JFrame f = new JFrame("ImageLoader");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setContentPane(content);
            f.pack();
            f.setLocationRelativeTo(null);
            f.setVisible(true);
            ImageLoader loader = new ImageLoader(url, imageLabel);
            loader.addPropertyChangeListener( new PropertyChangeListener() {
                 public  void propertyChange(PropertyChangeEvent evt) {
                     if ("progress".equals(evt.getPropertyName())) {
                         progress.setValue((Integer)evt.getNewValue());
                         System.out.println(evt.getNewValue());
                     } else if ("state".equals(evt.getPropertyName())) {
                         if (SwingWorker.StateValue.DONE == evt.getNewValue()) {
                             progress.setIndeterminate(true);
            loader.execute();
    abstract class IIOReadProgressAdapter implements IIOReadProgressListener {
        @Override public void imageComplete(ImageReader source) {}
        @Override public void imageProgress(ImageReader source, float percentageDone) {}
        @Override public void imageStarted(ImageReader source, int imageIndex) {}
        @Override public void readAborted(ImageReader source) {}
        @Override public void sequenceComplete(ImageReader source) {}
        @Override public void sequenceStarted(ImageReader source, int minIndex) {}
        @Override public void thumbnailComplete(ImageReader source) {}
        @Override public void thumbnailProgress(ImageReader source, float percentageDone) {}
        @Override public void thumbnailStarted(ImageReader source, int imageIndex, int thumbnailIndex) {}
    }

  • How do I turn an image into a transparency?

    Hi,
    There's a question I've seen asked dozens or hundreds of times, and I thought I found an answer a few years ago. I've since forgotten how to do it:
    Turn an image into a transparency.
    Now, the obvious solution is to set the layer to "multiply." Yes, this is the effect I want. However, I want the layer to be transparent instead.
    Another solution is to draw an image on a transparent layer. This works great, but only applies if I create the image from scratch. I want to convert an existing image.
    Another solution is multiple steps:
    1) Copy image
    2) Click "edit in quick mask mode."
    3) Paste image
    4) Exit quick mask mode.
    5) Invert selection.
    6) Ctrl+backspace to fill selection with black, on a blank transparent layer.
    Result? The image is now transparent! However, this converts the image to greyscale! Great for linework and text, terrible for photos or art!
    In an older version of Photoshop 7, I believe I got the following to work:
    A) Follow the previous steps 1-6, creating a layer with transparency
    B) Copy the original picture to a layer above the transparency
    C) Group the layer with the transparency layer below. (Note, grouping doesn't work the same any more.)
    D) The top layer provides the colors, but the bottom layer provides the transparency.
    E) It is too light, so you take the top layer, and maximize "saturation" 100%.
    F) Merge the two layers. It retains the transparency of the bottom layer, with the hue of the top layer.
    This no longer works, because I don't know how grouping layers works anymore.
    So, I need white pixels to be transparent. Black pixels to have zero transparency. Red pixels to have zero transparency. Etc.
    Meanwhile, grey pixels are solid black, but partly transparent. Pink pixels are solid red, but partly transparent.
    All pixels are 100% saturated, and the "lightness" is determined by how transparent they are.
    So, an analogy would be printing a photo on a transparency. I need to convert an image to a transparency.
    If the image/layer were overlaid on white, it would look exactly like the original photo.
    Does anyone know how to accomplish this? Mathematically, it's easy. But I don't know about any filter, process, or method to make the conversion using CS5.
    Thanks,
    Ben

    Hello!
    I hope that I understand what you need.
    (One could just put the image on a layer, and lower its opacity, but you seem to be looking for an effect in wich the tranparency is not the same for all pixels.)
    Try this:
    1) Turn your image image as a layer (double-click it if it is a background layer) [In order to add a mask]
    2) Select all, Copy (CTRL+a, CTRL+C)
    3) add a layer mask (click the rectangle with a circle in the bottom of the layers panel) [to be able to change transparency]
    4) target the mask [so that you can past an image in it] ALT+click the mask, paste the image.
    5) Invert the colors of the mask (CTRL+I) [in order for the white to be transparent and the black opaque].
    You now have a layer whose transparency is based on the lightness of the pixels.
    Hope that's what you are after!
    Pierre

  • How to draw images at a particular spot in a subview

    When you load an image into a UIImageView:
    {CODE}
    UIImageView* page1 = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"page1.jpg"]];
    [myparentview addSubView:page1];
    {CODE}
    That works fine, and you get an UIImageView object with the picture at (0,0).
    If you add another UIImageView to the parent UIView object, then when that UIView is drawn you get the picture at 0,0 again, and it overwrites the first picture. I want to draw a series of sub-picutures into a giant view. When you add a subview is there any coordinate translation that happens, I tried zapping the frame() or bounds() variables of the subview to make it draw differently but that doesn't seem to change anything.

    Do this:
    UIImageView *page1 = [[UImageView alloc] initWithImage:[UIImage imageNamed:@"page1.jpg"]];
    CGRect frame = page1.frame;
    frame.origin.x = newX;
    frame.origin.y = newY;
    page1.frame = frame;
    [myParentView addSubView:page1];
    And use {code}, not {CODE}

  • InDesign CS3 Scripting XML Import Multiple Images into same Text Frame

    I am having trouble importing multiple images into the same Text Frame using XML import. I imported 5 images into the text frame. However, all 5 images are laying on top of one another. Does anyone know if there is a way to have all images laying out like how Microsoft Word handles inline images, i.e., laying out next image to the right of previsous image in the same line and if there is not enough space left in the line, then wrap to next line. Thanks in advance. I understand I could use JavaScript to do post import processing, e.g, calculate the image size and place each images accordingly. But I am trying to see whether there is a way to do this without scripts.

    You can apply an object style to all anchored images by script. A text frame containing main flow should be selected.
    var doc = app.activeDocument;
    var textFrame =  app.selection[0];
    var rectangles = textFrame.texts[0].rectangles;
    if (rectangles.length > 0) {
         for (var i=0; i < rectangles.length; i++) {
              rectangles[i].appliedObjectStyle = doc.objectStyles.item("Cover");
    However, there is a better approach:
    Step 1
    Create place holders for a single "Book" element and format it as needed -- apply an object style to the cover.
    Step 2
    Import the xml file -- the placeholders are replaced with data from the 1st xml element
    Step 3
    Drag & drop the element containing all "Books" elements into the main flow -- all elements are placed and formatted the same way as in step 1.
    Finally, add a new page, click the overset text icon and autoflow text to add pages so that to fit all the text.
    Hope this helps.
    Kasyan

Maybe you are looking for

  • Urgent : Deleting a row in a sql report region

    Hi I have an SQL report, i must have an icon "delete row", when clicing this icon the row must be deleted from the report, what I have do but not sure of this : in my query I am containing some html in witch I have an icon, when the user click on thi

  • Tcode to check GL account for billing document

    Hi, can i check the commercial billing document will pick which GL account.   Is there is any T Code to check before releasing the document .

  • Libraries on mac

    hi I'm using an Imac 2009 with 2.66 Ghz processor Intel Core i5: Untill one moth ago I had all my libraries (aperture and itunes) located ,as defaoult, on my mac HD. Then I had a problem with the system because I'm usyng too much space (700 GB used a

  • Set variant for PNP LDB select option of pernr

    Hi All, I want to set variant for PERNR of PNP LDB in one of the program through other program using RS_CREATE_VARIANT FM. Please help to solve this problem. Thanks, Shailesh S. Malkar.

  • Compiler is not recognizing MDM jar classes

    hi Experts,                   I am trying to cretae  a java wrapper on top of MDM using Java API's. I created a simple java program and i was able to access the MDM repository. But when I created a Java DC I am getting the build errors in the same co