Results 1 to 3 of 3
Thread: How to make a background image
- 10-28-2010, 07:47 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 1
- Rep Power
- 0
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
- 10-28-2010, 07:52 PM #2
Senior Member
- Join Date
- Oct 2010
- Location
- Germany
- Posts
- 780
- Rep Power
- 4
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)
example:
Panel with background image : Panel*«*Swing JFC*«*Java
btw: show() is deprecated, use setVisible(true) instead of that
- 11-04-2010, 07:32 AM #3
Member
- Join Date
- Nov 2010
- Posts
- 1
- Rep Power
- 0
General
Hello!!!!
thanks for your reply!!!!!
-----------------------------------
Cheap Hotels Kanyakumari | Kanyakumari Tourist Home | Kanyakumari Sunrise and Sunset
Similar Threads
-
Need help with JFrame background image
By ProGenius in forum New To JavaReplies: 6Last Post: 12-27-2009, 04:17 PM -
How do I make a timer run in the background?
By caryr in forum Advanced JavaReplies: 15Last Post: 09-04-2009, 02:34 AM -
Background image
By leiferouis in forum New To JavaReplies: 9Last Post: 03-08-2009, 05:49 PM -
Image as background
By Java.child in forum AWT / SwingReplies: 2Last Post: 10-02-2008, 11:37 PM -
How to make the JTextArea background invisible
By bradder in forum AWT / SwingReplies: 1Last Post: 12-05-2007, 06:30 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks