How to set a image as a background in a frame

How to set a image as a background in a frame

The following code works well in Notepad command prompt but it is not working on netbeans
I want to set a background image in a frame(awt or swings ny will do) or a panel through netbeans
1. import java.awt.*;
2. import java.awt.event.*;
3.
4. public class ImageFrame extends Frame
5. { 
6. private ImageCanvas c;
7. private Image i;
8. ImageFrame( Image i )
9. { 
10. this.i = i;
11. c = new ImageCanvas( i );
12. add( c );
13. }
14.
15. public static void main( String[] args )
16. { 
17. Toolkit tk = Toolkit.getDefaultToolkit();
18.
20. Image im = tk.getImage( "WashuChan.gif" );
21. ImageFrame f = new ImageFrame( im );
22. f.addWindowListener( new WindowAdapter()
23. { 
24. public void windowClosing( WindowEvent e )
25. {  
26. System.exit( 0 );
27. }
28. } );
29. f.setSize( 300, 300 );
30. f.show();
31. }
32.
33. private class ImageCanvas extends Canvas
34. { 
35. Image i;
36.
37. public ImageCanvas( Image i )
38. { 
39. this.i = i;
40. }
41.
42. public void paint( Graphics g )
43. { 
44. g.drawImage( i, 0, 0, this );
45. }
46.
47. public Dimension getPreferredSize()
48. { 
49. int w = i.getWidth( this );
50. int h = i.getHeight( this );
51. return new Dimension( w, h );
52. }
53. }
54. }

Similar Messages

  • How to set an image as a background in pages '09

    I'm trying to set an image as a background in pages... PLEASE HELP!!

    Hi Jerry,
    All the arrange and wrap options are greyed out for me (trying to help my daughter with a Monster background and failing miserably), do you have any suggestions for where I may be going wrong?
    Thanks
    Derek

  • How do you set a image in the background of a JTextfield?

    How do you set a image in the background of a JTextfield? Any ideas?

    You can't thats why it is called textfield!!!
    Take a look at JScrollPane API for this

  • How do you set an image into the background of a JPanel or JFrame?

    How do you set an image into the background of a JPanel or JFrame?

    Something like this, Ive thrown in an ImageIcon on a
    button too for good measure.
    import java.awt.*;
    import javax.swing.*;
    public class JFrameImage extends JFrame {
    public JFrameImage() {
    Container c    = getContentPane();
    JPanel panel = new JPanel(){
                 public void paintComponent(Graphics g)     {
    ImageIcon img = new
    = new ImageIcon("background.jpg");
                      g.drawImage(img.getImage(), 0, 0, null);
                      super.paintComponent(g);
            panel.setOpaque(false);
    ImageIcon icon = new ImageIcon("onButton.jpg");
    JButton button = new JButton(icon);
    panel.add(button);
    c.add(panel);
    public static void main(String[] args) {
    JFrameImage frame = new JFrameImage();
    frame.setSize(200,200);
    frame.setVisible(true);
    Going totally fancy pants
    ImageIcon bigImage = new ImageIcon(bgImage.getImage().getScaledInstance(getWidth(), getHeight(),Image.SCALE_REPLICATE));
    g.drawImage(bigImage.getImage(), 0, 0, this); Will scale the image to the size of the panel
    whereas
    for (int y = 0; y  < getHeight(); y = y + image.getHeight(null))
    for (int x = 0; x< getWidth(); x = x + image.getWidth(null))
    g.drawImage(image, x, y, this); Will give a tiled effect
    Try tiling with an animated gif and bring your processor to a standstill.

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

  • 6300 How to set ringtones/images/photos

    Please tell me how to set ringtones/images/photos to individual contacts/numbers. If you have more than one number for a contact can you set up each one separately. ie home/mobile/office etc.
    Thanks
    Solved!
    Go to Solution.

    to perform all the mentioned operations(expect assigning different tones to different numbers of the same contact,which isn't possible,as already indicated in the previous post)you need to move the contact to the phone memory. now what you can do is copy all the contacts to the phone memory as well.then after that you can set all the options for the your contacts.
              but, after copying the contacts to phone memory,the contact list will have two entries to the same contact(of both the memories).If you don't want them in that manner then you can configure the current memory in Contacts->Settings and set that option as 'Phone'.But this will now be the default memory for your new contact,so be careful!! Still any doubts??
    Was this post of some help? Click 'Kudos' star on the right hand side of this post. Your gesture will be highly appreciated!

  • How to set an image on JFrame

    i just want to know that how to set an image on JFrame.
    thanks in advance

    dear moazzam
    why are you coming here in the forms when you have very brillient java certified teacher
    who knows every thing:)
    just mail him and ask this questain from him.
    im sure you will be given a good replay
    take care !

  • How do I set an image as a background for a course homepage?

    I am trying to set a background image for when people visit the homepage (like MOMA and others). Yet, I can't find where/how to do that. Is there any documentation that people of found for the design side of creating an iTunes U course and nav?
    thx,
    Matthew

    Since you are asking in the Course Manager forum, I am puzzled by your question. As a teacher, you can set an image for your course, but there aren't background images for individual courses.
    If you are talking about the institutional pages in the iTunes U section of the iTunes Store, your institution's page is managed by your site administrator (using Public Site Manager), so contact him or her to make the change.

  • How to set pl/sql function as background job in apex?

    Hi,
    I wrote a function which returns boolean value based on result.This function updates a table everyday.How to set this as a background job?or do I need to use dbms_job only?
    Thanks,
    Mahender.

    No, you can use APEX_PLSQL_JOB.
    Example:
    DECLARE
    l_sql VARCHAR2(4000);
    l_job NUMBER;
    BEGIN
    l_sql := 'BEGIN MY_PACKAGE.MY_PROCESS; END;';
    l_job := APEX_PLSQL_JOB.SUBMIT_PROCESS(
    p_sql => l_sql,
    p_status => 'Background process submitted');
    --store l_job for later reference
    END;
    full documentation link [http://download.oracle.com/docs/cd/E14373_01/apirefs.32/e13369/apex_plsql_job.htm#BGBCJIJI]
    If I help you, please stamp my answer as CORRECT or HELPFULL :)

  • How to Create an image without a background?

    Hi,
    So I've been learning the ropes of photoshop all week and I started and am almost finished with my first project.
    I created a cutout and I want to make a sticker out of it, but I'm not sure how to save it without the white background.
    Here's what it looks like to get a better idea of what I'm asking, I want the player to just be on his own on a sticker, like a cutout.

    You need to save your document that has  transparency in an image file format that supports transparency. If you want to use the image on the web it needs to be an image file format that browsers supports.   That means PGN or GIF format.  GIF only supports 255 mapped colors when there is transparency. And the Transparency is complete no partial transparency.  PNG supports 8 or 16 bit color and transparency.  You should use sRGB color space for only some browsers use color management the rest assume images are sRGB. Gif file sizes are smaller the PNG files.

  • How to set an image pattern as backround for a Shape + Copy shapes

    1.)
    Is there any way to set an image as background for a geometry shape (eg. Shapes.AddTriangle) similar like setting a 'Brush#' as background with LDShapes.BrushGradientShape ??
    In the image below, eg. the yellow triangle is a rectangular image shape with transparent regions, and therefor can with 'LDShapes.GetAllShapesAt(mouseX,mouseY)'
    also be accessed/grabbed in its transp. regions eg. green or red points etc., etc, aso.. and not only in the filled 3angular area, while a real 3angular geometry shape (like on the left side) would NOT (here only
    inside the triangle area itself). I tried 'LDShapes.SetImage' but this is for image shapes/controls and did'nt work here.
    Or maybe anyone has a better solution for a more natural looking wooden 'Brush' (as alternative for a real triangle shape with gradient).
    2.)
    Is there a way to copy an existing shape/control (with its basic properties like color, text, size, vertices count, ..) to another, like LDImage.Copy does for images ??
    eg. i can simply copy an array and an image from one variable to an other variable, like
    ' arr1 copied to arr2
    arr1 = "1=1;2=2;3=4;4=8;5=16;6=32;"
    arr2 = arr1
    TextWindow.WriteLine(arr2)
    TextWindow.WriteLine(arr1)
    or
    ' img1 copied to img2 (ImageList1)
    GraphicsWindow.Show()
    img1 = ImageList.LoadImage("picPath")
    img2 = img1
    GraphicsWindow.DrawImage(img2,50,50)
    GraphicsWindow.DrawImage(img1,200,200)
    but following does'nt work
    ' Ellipse1/Text1/Image1/Button1/...  is just an object with two names: shp1 and shp2
    GraphicsWindow.Show()
    shp1 = Shapes.AddEllipse(10,10)        'or Shapes.AddText("ABC") or Shapes.AddImage("picPath") or Controls.AddButton("Demo",0,0)
    Shapes.Move(shp1, 100,100)
    shp2 = shp1
    Shapes.Move(shp2, 50,50)
    Shapes.Move(shp1, 200,200)
    Not so important (only for interest), but maybe anyone has a trick for this, to copy such objects instead of creating them new.

    Yep, that made the rest of my whole day!! Works excelllent in the demo, and i'm just replacing all the  Image<->Triangle commands. Wonderfulll & thanks a lot, LitDev. (enjoint the sb sample in your Test-DL :-))
    PS:
    Controls.SetTextBoxText(Controls.AddTextBox(10,10), "Enter your name here...")
    Controls.AddButton(".. then press the Button", 180,10)
    LDGraphicsWindow.Capture("","")
    GraphicsWindow.Clear()
    GraphicsWindow.DrawImage("ImageList1", 0,0)

  • How do set up image based navigation bar in DW CC?

    How do you set up images as the list members that form a navigation bar?

    Spry is gone, true, but CSS most definitely is part of DWCC...
    http://tv.adobe.com/watch/learn-dreamweaver-cc/using-the-css-designer-panel/
    You should be able to follow a css tutorial after familiarizing yourself with the CSS Designer.
    If you don't understand html and css in and of themselves, and you have a budget, you may want to get the Menu Magic DW Extension from Project VII. That would allow you to use the DW Design View interface to make a menu.
    If you have a fair understanding of the basics though, any "jquery menu" or "pure css menu" available freely on the web would do the trick. The vast majority of them come with a quick how to that includes mostly copy/paste instructions.

  • How to project an image onto a background image?

    Hi,
    I am looking for help with projecting an image over another image.
    I am looking for a similar effect to the image above where it looks like the image of the player as (physically) been projected onto the tunnel.
    Looking closely at the detail of the image you can see that the projection adjusts to the contours of the tunnel i.e. over the framing. This is what I specifically need some help with. I know how to overlay an image onto another using different layers but it doesn't really give a three-dimensional perspective and looks rather flat.
    Any help or advice would be greatly appreciated. Thanks
    Ravi.

    Hi Ravi -
    Could you post what you have done so far, and include your expanded layers panel? The source images would also be helpful, if possible!
    One thing you could try is creating a Displacement Map of your background tunnel image and then wrapping your overlay image to it. The video tutorial below shows you how to do this:
    Beside this, you might just have to spend time tweaking your image to create a realistic overlay. This includes adjusting lighting, but also distorting your overlay image. Have you tried using Edit > Transform > Perspective to align your image to the tunnel? The other Transform tools like Distort and Warp might also come in handy.
    I'm looking forward to helping you with this effect!
    Cheers,
    Kendall

  • How to put an Image as a background of Portal

    Hi All,
    I was exploring of possibility of how to include an image as background of portal. I want to see in backdrop ,instead of default portal them ,an image as background.
    Thanks
    Srikant

    Hi Srikant,
    This url will help you in creating a new portal theme and assigning them to your application.
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/help/sdn_nw04/saphelp_nw04/helpdata/en/1a/d7c1617dd29e4d85064b467636fada/content.htm
    Best Regards,
    Nibu.
    (Please close your queries if you get your problem solved).

  • How to set ASDM image on ASA remain factory-default

    Hi, Cisco Support Community
    I want to configure an ASA to facotry-default using the following commands.
    # configure factory-default
    # wr mem
    But when I use above commands, ASDM is to be unset !
    How can I set ASDM remain factory-default ? I don't want to include " #asdm image disk0:/~~.bin" command in configuration because it is not factory-default configuration.
    I don't know why I can do that on ASDM.
    First , Upgrade ASA&ASDM on ASDM.
    Second Operae factory-default and reboot on ASDM.
    Then ASA is to be factory-default and set ASDM image.
    I want to do that with CLI.
    Thanks in advance. 

    Thank you for reply.
    Of course I put ASDM image on ASA.
    You know we can launch ASDM on truly factory-default ASA.
    I mean how I can reset ASA to that condition using CLI.
    a problem is below.
    1. put ASDM image on asa flash
    2. (configure)#asdm image disk0:~~
    3.#show asdm image
    >> the image is set
    4 (config)#configure factory-default
    5.#show asdm image
    >> unset
    How can I truly reset to factory-default ?

Maybe you are looking for

  • ORACLE 8.1.7 INSTALLATION PROBLEM  ON LINUX (URGENT)

    HI, I AM TRYING TO INSTALL ORACLE 8.1.7 ON LINUX RED HAT(7.1). AFTER DOING ALL THE STEPS WHEN I RUN(./runInstaller) I am getting message "Initializing java virtual machine from ../stage/components/oracle.swd.jre/1.1.8/1/datafiles/Expanded/Linux/bin/j

  • Audio from MacBook to TV with HDMI not working?

    I recently purchased a HDMI cord for my MacBook, but I don't seem to get any audio from my TV when it's hooked up. I've had no problems getting the image to display on my TV, but the sound won't work. I've already gone through System Preferences to s

  • How can I complain about erroneous charges to my ITunes account?

    I have had multiple erroneous charges to my ITunes account which ITunes deny is their fault and say I have to ask bank for the refund, also they take approx 5 days to answer any email. I need an email address of someone higher up in customer service

  • ITunes has encountered a problem and needs to close!! ARRRRRGGGGGHHHHHH!!

    AppName: itunes.exe AppVer: 11.1.5.5 ModName: ***.dll ModVer: 7537.60.5.27 Offset: 000017d0 Can anyone offr any new advice, please?  I've followed every fix described on these forums and I'm still getting this message! XP Pro 32bit. I've removed all

  • Embed FLV

    Hi, I've no problem with uploading .swf file now...but facing a problem about the .flv player...what's your recommendation?i might need your suggestion of Code... Thanks!!!