How to use a backgroud image in a JPanel.....

hi,
How can I display a background image for a JPanel.....
I have searched this forum but all solutions I found are where JPanel at the end has to be displayed on a frame in an application...
I need to use JPanel on Applet.......
Actually I am switching JPanels on JApplet as screens for a game....
I need to display background image for one of the JPanel class that has to be called by an Applet class....
Thanks a lot for any help.

Thanks a lot for your help.
How do we specify URL to use an image from net. Is itt like I open an image file on some website & use its address? Kindly add here some website too so that its more clear for me.
Thanks a lot for any help & all help your provided previously.
String imageFilePath = "urlOfMyImageFile"; // I am asking about parameter to be used here
ImageIcon ii = new ImageIcon(imageFilePath);
Image image = ii.getImage();

Similar Messages

  • How to use recursion with images

    Ok, for this program I'm trying to recursively repeat an image 3 times with varying widths and heights, and I don't know how to do that with images. With rectangles and other shape objects it's easy because all I had to do was override the draw method, but with images I'm not sure what to override to allow me to repeat the drawing of it with a different height and width. Any help would be greatly appreciated.

    Would I be able to work that in with recursion? Currently I have a JPanel with the paintComponent method being overridden, and I've tried setting up the paintComponent method to call itself to repaint the image, but I've realized everytime I resize the application's window paintComponent gets called again making the images go out of site. Is there a way to override the drawImage method to allow me to change the width and height of the image without causing the panel to repaint itself?

  • How do I draw an image on a JPanel?

    To be honest I have no idea even where to start. I tried hacking through the tutorials but it just didn't help me (normally they do, I don't what's up).
    Anyway, so what I'm trying to do is build a game. The Graphics2D is great for simple shapes but drawing characters is getting kind of ridiculous (tedious + difficult + looks bad). So, I need to figure out how to display an image on a JPanel.
    To that end I have several questions.
    1 - What image type do I use? Like jpeg, bmp, gif, etc.
    2 - How do I make parts of it transparent?
    3 - How do I make it appear on the screen, given some coordinates on the JPanel?

    To draw an image directly to a JPanel given certain coordinates, you have to create a custom JPanel and override its paintComponent() method. Like this:
    class PaintPanel extends JPanel{
    public void paintComponent(Graphics g){
    super.paintComponent(g);
    //painting code goes here}
    }Java can load in and draw GIF and JPEG images. If you decide to use GIF files, any good image editor like Adobe Photoshop should be able to make them transparent for you before the fact. If you want to set transparency within your java program you will have to create a BufferedImage and make certain colors within it transparent, but I would like to know how to do that as much as you do.

  • How do you change the image in a JPanel?

    Hey! (firstly, i need to use image on a JPanel, label&icon not an option).
    I've made my JPanel class
        public class DrawingPanel extends JPanel {
            Image img;
            DrawingPanel() {
                Image img = Toolkit.getDefaultToolkit().getImage("13.jpg"); //default image at startup
            public void paintComponent (Graphics g) {
                super.paintComponent (g);
                // Use the image width & height to find the starting point
                int imgX = getSize ().width/2 - img.getWidth (this);
                int imgY = getSize ().height/2 - img.getHeight (this);
                //Draw image centered in the middle of the panel   
                g.drawImage (img, 0, 0, this);
            } // paintComponent
        } // DrawingPanelAnd I've made my instance of it and added it to the Frame:
        DrawingPanel imagePanel = new DrawingPanel();Now, I need to change the image on the JPanel according to the user's input. I have the string of the location of the new image. How do I update the JPanel to display this new image? Any help greatly appreciated!!

    Well... You could just add a method in your class which sets the image according to the new image name you provided. Something like this:
        public class DrawingPanel extends JPanel {
            Image img;
            DrawingPanel() {
                img = Toolkit.getDefaultToolkit().getImage("13.jpg"); //default image at startup
            public void setImage(String imageName) {
                    img = Toolkit.getDefaultToolkit().getImage(imageName); //Loading the desired image
            public void paintComponent (Graphics g) {
                super.paintComponent (g);
                // Use the image width & height to find the starting point
                int imgX = getSize ().width/2 - img.getWidth (this);
                int imgY = getSize ().height/2 - img.getHeight (this);
                //Draw image centered in the middle of the panel   
                g.drawImage (img, 0, 0, this);
            } // paintComponent
        } // DrawingPanel

  • How to use a backgound image for a page?

    Hi all,
    How can I tell Apex to use an image as the background for a page?  This particular page needs to be more visually interesting due to the audience that will be viewing it.
    Thanks,
    Kim
    P.S. I'm using Apex 4.2.2 and Oracle 11g.

    Use css to set the background of your page body - http://www.w3schools.com/cssref/pr_background-image.asp
    To know where to set this in APEX, see 8.2 Altering Page Attributes and scroll to CSS section

  • How to use free floating images on a page?

    Using DW CS4 and being a noob, I have a stupid question.
    How can I achieve this:
    Here is the webpage: http://ppbm5.com/Poffertjes-4.html

    Using good layout practices, it would be a piece of cake.  The page is really a two-column page with the right-hand column split into a form container on the right and a content container on the left.
    Check out the two-column sample pages built into DW for a reasonable start at this.  The form container would be floated right, and the images would simply stack vertically in the remaining space to its left.

  • How to use high resolution image as glyphs in icon editor?

    i want to use a hiigh resolution image in icon editor . how do i use it?

    Icons can be up to 32x32 px in size, so first you need to reduce the resolution of the image. Save as .bmp, .jpg or .png.
    From the icon editor, select Edit -> Import Glyph from File... and choose your image. Done.
    -Benjamin
    CLA

  • Premier pro cs6: how to use 400 jpg images to make a movie?

    I want to use about 400 jpg images to make a movie.  is there a way to add them to a sequence in a random order?

    I'm not aware of a randomize feature either, but here is a suggested workflow that may make it easier than shuffling 400 images around in Premiere:
    Open your images in Bridge
    Move them around to meet your random requirement
    Highlight all images (Ctrl-A)
    Right-click / batch rename and add a sequence number to the front of each name (I like to add a text "_" too) and copy the resulting set of images to an empty directory
    Import the whole directory into Premiere
    Automate to timeline
    I used to use Liquid and it had a wonderful freestyle way to pre-order your clips or images prior to dumping them onto your timeline, and the above workflow is how I have come to approximate the same.
    Regards,
    Jim

  • How to use the same image map over and over

    Sorry, I posted this a couple of years ago and got a good answer by Murray. I'm so rusty with it, I can understand how it works anymore.
    Question:
    I have a large jpeg image map for a hundred pages. The jpegs are all the same except I changed the city name for each one.
    So for each corresponding htm page, the 4-5 links out are the same.
    Waht is the trick to not have to create by hand hotspots? thanks.
    I have previous notes, but I don't understand anymore, (too rusty) what they mean:
    The good news is that you really don't need a template at all.
    Just open one of your existing pages in DW, select that central image, browse to select the correct replacement image, and save the page with a new name.  It will have all of the image maps already there, from the original image.  One and done as they say."
    My old interpretation of this:
    select the large jpeg and then in link field drag over to the new city jpeg

    Ok, Nancy, code copy/ paste did work fine.
    what does this mean:
    "Change the image in the properties panel to display your new image."
    (the image is displaying ok)
    NEverthesless, I think I got Murrays old notes.
    Here is my new version of Murrays writing, easiest way I think:
    You open up a pre-existing html, say Chicago. Then drag over with pointer to the new jpeg you want (Buffalo). It replaces Chicago with the buffalo jpeg, all links work perfectly. Then do a save as called Buffalo.

  • How to use CSS and images in a plsql-dbms_output reports?

    Hi.
    Windows 2000 SP4
    SQL Developer 1.2.1.32.13
    Java 1.5.0_07
    Oracle 9.2.0.6
    I'm trying to create a plsql-dbms_output report with HTML that uses a stylesheet (CSS) and an image. These seem to be ignored by the report viewer.
    The following example works fine in Internet Explorer 6 but the stylesheet is ignored by the viewer and the viewer does not show the images (shows broken images instead). I've tried with various image types (PNG, GIF and JPEG).
    <!--
    begin
    dbms_output.put_line('<head><link rel="stylesheet" type="text/css" href="file://c:/temp/core.css"/></head><body>');
    dbms_output.put_line('<H1>This is Level-1 Heading</H1>');
    dbms_output.put_line('<H2>This is a Level-2 Heading</H2>');
    dbms_output.put_line('<p>This is regular paragraph text.</p>');
    dbms_output.put_line('<img src="file://c:/temp/fig01.png"><br>');
    dbms_output.put_line('<img src="file://c:/temp/fig01.gif"><br>');
    dbms_output.put_line('<img src="file://c:/temp/fig01.jpg"><br>');
    dbms_output.put_line('</body>');
    end;
    -->
    Is the HTML viewer limited to not support stylesheets and images?
    Thanks in advance.
    Cheers
    Finn Ellebaek Nielsen

    It also seems that links don't work. The mouse cursor changes to a hand when hovering over links and the links are shown in blue and underlined but nothing happens when clicking on them.
    Example:
    <!--
    <html>
    <head><link rel="stylesheet" type="text/css" href="file://c:/temp/core.css"/></head><body>
    <p>First heading</p>
    <p>Second heading</p>
    <H1 id="x1">This is Level-1 Heading</H1>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    a<br>
    <H2 id="x2">This is a Level-2 Heading</H2>
    <p>This is regular paragraph text.</p>
    <img src="file://c:/temp/fig01.png"><br>
    <img src="file://c:/temp/fig01.gif"><br>
    <img src="file://c:/temp/fig01.jpg"><br>
    <p>First heading</p>
    <p>Second heading</p>
    <p>Other document</p>
    </body>
    </html>
    -->

  • How to use Text and Image variables for printing

    I have been working on product configurator with AS3 for several months now.
    I am not proficient with AS3.
    Now, it seems that maybe my design is all wrong.
    Is there a proper way to do this?
    I have a main timeline that has movie clips showing images of different options for the product.
    On the first frame, I use buttons to select the choice for option 1 from the Option1_mc.
    Then I store the choice in a variable.
    I use a button to go to the next choice (frame 10.)
    On frame 10, I use buttons to select the choice for option 2 from the Option2_mc.
    This is stored in another variable.
    There are about 10 options that are selected and stored in variables.
    Some are text values and others are instances of images from the Option movie clips.
    I made a Print_mc to use for printjob.
    I can't get the values of the variables to display in the first frame for printing.
    Any helpl would be appreciated.

    you're welcome.
    you won't insert a variable into a textfield.  you'll assign the text property of your textfield to be the value one of your variables points to.
    so, for example, if you have:
    var var1:String="this is a test";
    you can use:
    tf.text=var1;

  • Desktop Office Integration - How to use Weblinks for Images in linkserver?

    Hello experts,
    I want to add an image from the internet (e.g. Link: www.images.de/image.jpeg) to the linkserver in order to paste it in my word document. As I know it should be possible to do so with the link server. I tried it before with business documents "BDS" and it works fine. But in my opinion this place is not the best place to store pictures. So I want to use the pictures, which are currently stored in our portal and are available via weblink.
    So, actually, I have to give the information about the link to the link server method "add_binary_item", but with something like that "http://www......" it doesnt work! Do I have to enter a prefix or something like this???
    I hope someone could help me with that issue.
    THanks and regards,
    marcus

    Hello,
    I did it and it works fine!
    But I had to use the BDS Business Document Service with Class cl_bds_document_set.
    So I used the method "get_with_url" to get the url from the document/picture.
    After that I cann add a binary item with the URL and it works fine if my pictures are stored in BDS.
    But that is not what I want to do. I want to store the pictures in my mime repository for example. Are there any other possibilities to do that? Or is Desktop Office Integrations supporting just documents/pictures which are stored in BDS???
    Regards, Marcus
    Edited...........................................................
    In best case I am able to user internet urls for the pictures. So "http://www.xcxy.de/picture.jpeg", but with this URL information it doesn´t work!
    So, my question is if I have to add a prefix or something like this in order to use weblinks.
    Edited by: Marcus Findeisen on Apr 19, 2011 9:16 AM

  • Jdev11g: How to use a Ord.image data type with ADF Faces 11g

    Where to find an example about Ord.image data type with ADF Faces 11g preview3

    Hi,
    such a sample doesn't yet exist.
    Frank
    Btw.: The Jdeveloper 11 forum is JDeveloper and OC4J 11g Technology Preview

  • Using a System Image to Restore an HP Computer in Windows 8

    Hello everyone,
    I would like to bring to everyone's attention, the latest HP Help video for PSG.  It demonstrates how to use a System Image to restore an HP Computer in Windows 8.
    Learn how to restore your HP computer using a system image in Windows 8. With Windows 8, you can backup every file and setting on your computer at once and save it as a system image. If you ever have a software problem, you can restore your PC back to exactly as it was when you created the system image.
    For other helpful videos go to hp.com/supportvideos or youtube.com/howto4u.
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓
    This question was solved.
    View Solution.

    I hope this video helps.
    ↙-----------How do I give Kudos?| How do I mark a post as Solved? ----------------↓

  • How to repeat a background image to cover the height of the page?

    Hi
    I have a page with an image alinged to the top in a table and
    I have a pattern in the background of the cell in the same table
    I need that background of the cell to repeat it self along
    the height of the page, so when someone views the page at a higher
    resolution, the background image will repeat it self to cover the
    extra space.
    I've tried setting the height of the table to percentage, but
    the table doesn't cover the height of the page.
    I could also make the table really long so when viewed at
    higher resolution there wont be any blank space at the bottom, but
    this makes an unnecessary and long scroll when viewed at lower
    resolution.
    Someone told me to use css but i have now idea how to
    implement that.

    make sure you have set your page margins to 0 if you don't
    want the default
    margin top left. Cut and paste the following into the head of
    your document
    just before the closing </head> tag.
    then if you want to repeat a background image in a cell, you
    need to create
    a rule to do this:
    .cellback {
    /*this repeats the image across the page horizontally*/
    /* if you want to repeat down the page, then change to
    repeat-y */
    background: url(pics/whatever.gif) repeat-x;
    you can combine this background image rule with the other
    margin setting so
    you have:
    <style type="text/css">
    <!--
    body {
    margin: 0;
    padding:0;
    .cellback {
    background: url(pics/whatever.gif) repeat-x;
    -->
    </style>
    You then apply to the class to your cell
    <td clas="cellback">
    Examples here:
    http://www.dreamweaverresources.com/tutorials/pagebackgrounds/cellbackground.htm
    this shows how to use a background image for your entire
    page:
    http://www.dreamweaverresources.com/tutorials/pagebackgrounds/examplehor.htm
    Nadia
    Adobe� Community Expert : Dreamweaver
    http://www.csstemplates.com.au
    - CSS Templates | Free Templates
    http://www.perrelink.com.au
    - Web Dev
    http://www.DreamweaverResources.com
    - Dropdown Menu Templates|Tutorials
    http://www.adobe.com/devnet/dreamweaver/css.html
    > I have a page with an image alinged to the top in a
    table and I have a
    > pattern
    > in the background of the cell in the same table
    > I need that background of the cell to repeat it self
    along the height of
    > the
    > page, so when someone views the page at a higher
    resolution, the
    > background
    > image will repeat it self to cover the extra space.

Maybe you are looking for