Results 1 to 3 of 3
  1. #1
    Purple Turtle is offline Member
    Join Date
    Oct 2010
    Rep Power

    Default How to make a background image

    Im making a gui and want to put a image in the background like a water mark so that i can make panels, labels etc over it. Its a simple frame and this is what i have so far..

    import java.awt.*;
    import javax.swing.*;
    import java.awt.event.*;
    public class MyfaceProfilePage extends JFrame
    private Toolkit kit = null;
    public MyfaceProfilePage ()
    super ("MyfaceProfilePage");
    setSize (860, 700);
    setResizable (false);
    setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);

    kit = Toolkit.getDefaultToolkit ();
    Dimension screenSize = kit.getScreenSize ();
    setLocation (screenSize.width / 6, screenSize.height / 19);

    Container container = getContentPane ();
    container.setLayout (new FlowLayout ());

    show ();
    setVisible (true);

    public static void main (String[] args)
    new MyfaceProfilePage ();

    can anyone help me out with a code to make the background image

  2. #2
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Rep Power


    create a JPanel subclass and override paintComponent(Graphics g). use the drawImage method of the graphics instance to draw your image!
    see: Graphics (Java Platform SE 6)

    Panel with background image : Panel**Swing JFC**Java

    btw: show() is deprecated, use setVisible(true) instead of that

  3. #3
    podai2010 is offline Member
    Join Date
    Nov 2010
    Rep Power

Similar Threads

  1. Need help with JFrame background image
    By ProGenius in forum New To Java
    Replies: 6
    Last Post: 12-27-2009, 05:17 PM
  2. How do I make a timer run in the background?
    By caryr in forum Advanced Java
    Replies: 15
    Last Post: 09-04-2009, 02:34 AM
  3. Background image
    By leiferouis in forum New To Java
    Replies: 9
    Last Post: 03-08-2009, 06:49 PM
  4. Image as background
    By Java.child in forum AWT / Swing
    Replies: 2
    Last Post: 10-02-2008, 11:37 PM
  5. How to make the JTextArea background invisible
    By bradder in forum AWT / Swing
    Replies: 1
    Last Post: 12-05-2007, 07:30 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts