Image in background

Hi i wish to make some buttons and labels in frame which has a specific Image as a background.
I make a MyJPanel extends JPanel and in override method paint i invoke drawImage() method
In construcor i create all buttons and Labels.
And after everything i apck this Panel to a frame
And the image is draw ok but i can't see any ot comopnents :(
after clicking on button it is visible
can you help me?
here is some code:
class LoginWindowPanel extends JPanel {
private JLabel enter;
     private JTextField login;
     private JButton ok;
     private JButton exit;     
     LoginWindowPanel() {
     super();
     enter = new JLabel("Enter login name");
login = new JTextField("",15);
     ok = new JButton("OK");
     exit = new JButton("EXIT");          
     JPanel panel = new JPanel();
     panel.add(enter);
     panel.add(login);
     JPanel southPanel = new JPanel();
     southPanel.add(ok);
     southPanel.add(exit);
     panel.add(southPanel);
     add(panel, BorderLayout.CENTER);
     public void paint(Graphics g) {
          Image img = Toolkit.getDefaultToolkit().getImage("images/login.jpg");
          g.drawImage(img,0,0,this);
     }

Well, the paint method is responsible for painting the child components. You have overidden the paint method, but don't paint the children. In Swing you should override the paintComponent() method not paint.
If you want further information then search the forum using the keywords "+image +background" as this question has been asked over and over again so there are lots of examples already in the forum.

Similar Messages

  • How to update the large amount of thumbnail images in background process

    in my application i want to load large number of thumbnail images(each images set as icon for separate jradiobutton) into panel. This panel is in left side of JSplitPane.
    when application is starting, now I’m loading the thumbnail buttons without image(to run the application quickly).
    now i want to update the buttons with real thumbnail images in background. i tried with thread and SwingUtilities.invokeLater ,but it stuck the application until updating finish.
    Note:im using java1.4 (not in the possession to use other versions)
    Can anybody give suggestion?
    SwingUtilities.invokeLater(new Runnable() {
    public void run() {
         for (int j = 0; j < imgPagesV.size(); j++) {
         try {
              ImageIcon icon = new ImageIcon((BufferedImage)thumImagesV.get(j)); //thumImagesV vector have thumnail bufferedimages 
              ((JRadioButton)thumButtonPanel.getComponent(j)).setIcon(icon);
              updateUI();
         } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
    });

    thax for your reply ..
    even i call new smiple thread to load the images it freeze the main gui. is any wrong in my way ?
    Thread Class
    import javax.media.jai.NullOpImage;
    import javax.media.jai.OpImage;
    import com.sun.media.jai.codec.ImageCodec;
    import com.sun.media.jai.codec.ImageDecoder;
    import com.sun.media.jai.codec.TIFFDecodeParam;
    public class TestThread extends Thread {
         File tiffImg;
         TestThread(File img) {
              this.tiffImg = img;
          * extracting form tiff images and creates thumbnail then add into vector
         public void run() {
              ImageDecoder dec = null;
              Vector thumImagesV = new Vector();
              TIFFDecodeParam param = new TIFFDecodeParam();
              param.setDecodePaletteAsShorts(true);
              param.setJPEGDecompressYCbCrToRGB(true);
              try {
                   dec = ImageCodec.createImageDecoder("tiff", tiffImg, param);
                   int start, end = 0;
                   for (int i = 0; i < dec.getNumPages(); i++) {
                        RenderedImage rm = new NullOpImage(dec.decodeAsRenderedImage(i), null, OpImage.OP_IO_BOUND, null);
                        thumImagesV.add(i, ImageHandler.createThumbnail(rm, 150));
              } catch (Exception e) {
                   e.printStackTrace();
    Main GUI Class
         private void buildGUI(File selectedFile) {
              configButtonPanel();
              configThumbnailPanel(selectedFile);//loading with out thumbnail image
              new TestThread(selectedFile).run();
         }

  • Using image as background

    hi,
    I'm having a little problem, I don't think it's very difficult but the search on this forum is down a.t.m.
    Therefore I'm hoping you guys can help :-)
    Like the title already discribes i want to use an Image as background of a JPanel (or on another Frame if it isn't possible on this one) and still be able to put JLabels, JTextfields, etc. on the JPanel with a LayoutManager.
    To show what i mean:
    -->i want to do something similar to this code
    JPanel test=new JPanel(new BorderLayout()));
    test.setBackground(Color.WHITE);
    --->but instead of setting a Color as Background i want to set an Image :)
    greetings

    The search facility may be down, but you are searching the wrong forum anyway. This is a Swing question and should be posted in the Swing forum.
    But since you made the effort to search, here is a simple example:
    ImageIcon icon = new ImageIcon("???.jpg");
    JPanel panel = new JPanel()
         public void paintComponent(Graphics g)
              //  Dispaly image at at full size
              g.drawImage(icon.getImage(), 0, 0, null);
              super.paintComponent(g);
    panel.setOpaque( false );

  • Image for background

    I have an image now that I want to use for a background on
    all of my WebPages. The image size is 2912x 4368 and I have made it
    1024x1536. On the page it looks good but what happens is the image
    repeats itself twice for width and length. I want it to only stay
    as one image no matter what resolution it is viewed as and not
    repeat the image for either length or width. Plus not look
    stretched or distorted.
    I am using Dream Weaver MX version 6 and also have Adobe PS
    CS2, any questions just ask.
    How do I achieve this?
    Thanks

    Why so huge? What is the weight of that monster?
    > I want it to only stay as one image no matter what
    resolution
    This is not a resolution issue. It's a browser window size
    issue (and
    always has been). When you say "stay as one image", do you
    mean "not tile",
    or do you mean "fill the entire width and height"? If the
    latter, then you
    cannot do that with a background image. Background images
    tile, they don't
    stretch. You can prevent the tiling with a little CSS -
    body { background-repeat:no-repeat; }
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    ==================
    "568jfe56nfg" <[email protected]> wrote in
    message
    news:fn33r3$a9a$[email protected]..
    > I have an image now that I want to use for a background
    on all of my
    > WebPages. The image size is 2912x 4368 and I have made
    it 1024x1536. On
    > the
    > page it looks good but what happens is the image repeats
    itself twice for
    > width
    > and length. I want it to only stay as one image no
    matter what resolution
    > it is
    > viewed as and not repeat the image for either length or
    width. Plus not
    > look
    > stretched or distorted.
    >
    > I am using Dream Weaver MX version 6 and also have Adobe
    PS CS2, any
    > questions
    > just ask.
    >
    > How do I achieve this?
    >
    > Thanks
    >
    >

  • Placing Image in Background

    Hi,
    When any report (in 11G) returns no data, I want to configure a custom message with an image in background. Is it possible to achieve this? How?
    I tried customizing class error text in 'views.css' but it did not help, I must be missing something...
    Regards,
    Jitendra

    Hi,
    Just to throw some light on my requirement, have a look at !http://tinypic.com/r/fm86c5/7!
    In 10g, I could achieve the same thing by custominzing class=errorinfo as given below:
    ErrorInfo {
         background: url(datanotfound.jpg) 0px 30px no-repeat;
         background-position : center center;
         text-align:left;
         color:#153977;
    And then calling this class in 'No Data View' section.
    I wonder if this is possible in 11g or not?
    Regards,
    Jitendra

  • Can i put image on background of my menu..........

    plz help i have a nokia 5233 n i want to put images on background of my menus.....plz help

    Actually, you cant put images in the background of the menu. It was never possible on symbian phones. The only way you'll get the images there through a theme, and only the theme image can be seen there. You'll have to make your own theme if you want. Just google for carbide UI.
    If you find my post helpful please click the green star on the left under the avatar. Thanks.

  • ADF 11g - PanelGroupLayout having multiple/many images as background.

    Hi,
    Could you please provide me an example code of JSPX page having set of different images as background image for (PanelGroupLayout) Rich ADF Faces Component.
    Succeed with only One image either no-repeat / repeat, but not different set of images.
    It would be realy great, If U can sent it as soon as possible.
    Thanks in Advance !!!
    Thanks
    Rani V

    multiple images tile across the screen as a background
    FMI, We have an Panel group having different set of images with it should have reflection of images as its backgound to it & its parent layout as well.
    For example, Let me consider an table having an row with 7 columns with different set of images with it.
    Where it form has corresponding images reflection around it,(that I've plan to take care with Opacity & transparency). if any better way of doing it, please add your comments.
    Thanks
    Rani V

  • How to set an image as background for a jPanel in an applet

    hi,
    I want to set an image as background for a jPanel component in an applet. I am using netbeans environment. I found that to set an image as a background for a jPanel is not possible. Could someone help me .
    Thanks in advance,
    Joshua

    public class ImagePanel extends JPanel
        private Image image = null;
        public void setImage(Image image)
            this.image = image;
        protected void paintComponent(Graphics g)
            super.paintComponent(g);
            g.drawImage(this.image, 0, 0, this);
    }Adjust to taste.

  • How do I restore images and backgrounds. Hide images and backgrounds will not unclick.

    Back grounds in email cannot be restored
    == This happened ==
    Every time Firefox opened
    == I clicked on "hide images and backgrounds" and it will not unclick.

    Check the image exceptions: Tools > Options > Content: Load Images: Exceptions - See [[Options window - Content panel]]
    A way to see which images are blocked is to click the favicon (''Site Identification'' icon) on the left side of the location bar and click the "More Information" button.
    This will open the Security tab of the ''Page Info'' window (also accessible via Tools > Page Info).
    Go to the ''Media'' tab of that Page Info window.
    Select the first image and scroll down though the list with the Down arrow.
    If an image is grayed and there is a check-mark in the box ''Block Images from...'' then remove that mark to unblock the images from that domain.
    See also [[Images or animations do not show]] and http://kb.mozillazine.org/Images_or_animations_do_not_load

  • Site loads 1/2 way down cuts images and background but fine in IE

    Site cuts background ~1/2 way down page, ~3/4 pictures load others don't (again near bottom of page), text also sometimes doesn't load at bottom of page.
    Site is perfect in IE & Chrome
    No firefox browser add on's, bone stock firefox recently updated.
    <!-- http://warmkiss.com/firefoxtestpage.html -->
    '''''Test page link removed by moderator, please create a test page with clean, non-nude images'''''
    (adult site, test page only)
    This is only a test page but I have an active page of same style having the same problems.

    Sounds like this bug that only appears on Windows (I'm on Linux).
    * [https://bugzilla.mozilla.org/show_bug.cgi?id=671302 bug 671302] - cairo-gdi: large background-images and gradients don't work beyond ~ 32735px
    See the discussion here:
    *[[/questions/882572]]

  • How to set image in background as background image in view

    hello experts,
    i am writing small program in that
    i have one view , with one group box
    i want to set an image which should appears as a background image for that view , also i want to appear the group on that image in foreground.
    i have no clue how to do that, can anybuddy help me out.
    your help is apperciated.
    thankx
    regards,
    nikhil
    Edited by: nikhil jadhav on Nov 5, 2009 10:26 AM

    hi,
    refer these threads :
    Background Image
    I guess this is not possible. : Assign Background Image to a Group (Ans by Thomas)

  • System Preferences shuts down when trying to apply .CR2 image as background

    Hello-
    I have been trying to apply a photograph taken in RAW as a desktop background image. The file is .CR2 and when I click done to set it as the background, the background does not change and the notice comes up that System Preferences has unexpectedly shut down.
    Please help !
    Thanks

    As far as I know, the things you can do with a RAW file are pretty much limited to processing it with photo editing software. You could use iPhoto and save it as a jpg file.

  • No image in background copy (after a duplicate layer)

    I Open an image.  Go to the Layers and select duplaclate layer.  However when I select the new layer background copy (and deselect the background ) they image is not there.  There is an image in the layers pane but nothing in the main screen just a checkered empty workspace.  I have tried to reset my preferences but none of the files in the list i have anywhere in my computer.  Has anyone seen this before.

    You will get that result if you turn off the eye in the Background layer and inadvertently set the Opacity slider for the Background Copy layer at 0%

  • How do you make an image a background image if the menu option is dimmed?

    I'm using the Cork Board template in a Pages layout document. I wanted to use the cork background in another page. Option dragging the cork image creates a copy in the new page. I can "Send it to back" but the Arrange->Send Object to Background command is dimmed. The problem is that "Send it to back" does not put it behind the header or footer so my page numbers are not visible.
    Oddly, if I just drag the cork image from one page to another, it remains a background object in the new page. Copying it causes it to come out of the background.
    Anybody have an idea why the Send Object to Background command is dimmed?

    In fact, my guess is that the cork.pdf object is a background object because it is a template transferred from Pages '06 to Pages '08.
    During the conversion, some properties are passed even if they aren't treated by the new version.
    If some one wish to let some of these items in the true background, as far as I know, the only available soluce is:
    create a new object from the delivered template
    unlock some items if necessary
    remove useless items
    lock back the kept item
    save the document as a template.
    Never change the background property of the kept items.
    As far as an item is a "true background" one,
    trying to move an other item to the background will leave it above the "true background object".
    Yvan KOENIG (from FRANCE mardi 9 septembre 2008 15:49:21)

  • How can I save an image with background transparency as an eps in photoshop?

    I have to submit an eps of my logo and I would like it to have a transparent background. I have googled this many times, followed all of the suggestions and I'm still having trouble.

    Follow the help text in PhS CS2. I have shown importat guidelines by bold text:
    "To save a path as an image clipping path
    Draw a work path that defines the area of the image you want to show.
    Note: Paths are vector-based; therefore, they have hard edges. You cannot preserve the softness
    of a feathered edge, such as in a shadow, when creating an image clipping path.
    In the Paths palette, save the work path as a path.
    Choose Clipping Path from the Paths palette menu, set the following options, and click OK:
    For Path, choose the path you want to save.
    For Flatness, leave the flatness value blank to print the image using the printer’s default value.
    If you experience printing errors, enter a flatness value to determine how the PostScript interpreter
    approximates the curve. The lower the flatness value, the greater the number of straight lines used
    to draw the curve and the more accurate the curve. Values can range from 0.2 to 100.
    In general, a flatness setting from 8 to 10 is recommended for high-resolution printing
    (1200 dpi to 2400 dpi), and a setting from 1 to 3 for low-resolution printing (300 dpi to 600 dpi).
    If you plan to print the file using process colors, convert the file to CMYK mode.
    Save the file by doing one of the following:
    To print the file using a PostScript printer, save in Photoshop EPS format, DCS, or PDF format.
    To print the file using a non-PostScript printer, save in TIFF format and export to Adobe InDesign,
    or to Adobe PageMaker® 5.0 or later.   "
    An image with clipping path contains everything outside the path as transparent.
    Tested actually by PhS CS6.
    Photoshop is not the right tool. Better use Illustrator or InDesign (ID for logos which are not too complex).
    Graphical objects in IL or ID reside on a transparent background without any selection or clipping path
    (PostScript concept).
    Best regards --Gernot Hoffmann

  • Image Component background color change

    Hi,
    I have am image object of an arrow in the xcelsius, I want the arrow as it is but want the background colour of the image object to be changed.
    In short how can I get the background color of an image object changed?
    Pls advice,
    Thanks in advance,
    Shreesh.

    Hi,
    In Xcelsius we dont have that option to change the background color of image. you Can edit in paint or some other image editor tools.

Maybe you are looking for

  • Unit of measure EA is not convertible to stockkeeping unit LB

    Hi, I am getting this error when doing a goods issue for a process order with 2 components that have different units of measure, like EA & LB. I am using 'BAPI_GOODSMVT_CREATE' for this. Has anybody encountered this problem before? Please share your

  • Passing complex object from JavaScript to Flex

    Is it possible to call a Flex function (defined with ExternalInterface.addCallback) and pass a complex object from Javascript?  The properties of the object are all simple types, but the object itself is an array of objects.  For example: <script typ

  • HT1727 help how do i make a purchased song my ring tone, it;s not showing on my list for ringtones

    help how do i make a purchased song my ring tone, it's not showing on my list for ringtones

  • Alternative to logical table

    Hi, How to resolve the issue given below dim1 --------<- fact ->------dim2 | | | | ▲ ▲ | | | | |________dim3_______| I want dim3 to be dimensional instead of fact ( which turns out to be fact after mapping shown above ). Is there any other alternativ

  • Splitting a Partition into smaller Volumes

    Hi, On an external drive I have 3 partitions. One of these is an empty 250gb partition. I'd like to split that into smaller 15gb sized partitions for some multiple install testing. In disk utility I have selected the partition and clicked the + sign