Results 1 to 2 of 2
Thread: Center background image
- 04-16-2008, 04:57 PM #1
Center background image
Hi!
The background image is showing but I would like to center it - how can this be done!?!
Thanks.
Java Code:import java.awt.*; import java.awt.event.*; import java.awt.image.*; import java.io.*; import javax.imageio.*; import javax.swing.*; public class NewClass10 extends JPanel { final BufferedImage bi; public NewClass10() throws IOException { bi = ImageIO.read(new File("C:\\Documents and Settings\\Flo\\My Documents\\My Pictures\\bigstockphoto_Binary_Globe_55596.jpg")); } public void paintComponent(Graphics g) { g.drawImage(bi,getWidth()-bi.getWidth(),getHeight()-bi.getHeight(),null); } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); NewClass10 t7 = new NewClass10(); f.setContentPane(t7); f.setSize(1025,703); f.setVisible(true); } catch (IOException ioe) { ioe.printStackTrace(); } } }); } }
- 04-24-2008, 05:50 PM #2
Similar Threads
-
GUI... setting my background to an image, im using a JFrame
By newtojava7 in forum New To JavaReplies: 2Last Post: 03-24-2008, 05:29 AM -
center a form
By tommy in forum New To JavaReplies: 2Last Post: 08-06-2007, 08:47 PM -
Background image in java
By toby in forum AWT / SwingReplies: 1Last Post: 07-29-2007, 07:15 AM -
Why this image background is black ?
By samson in forum Java 2DReplies: 1Last Post: 07-17-2007, 04:24 AM -
Help Center Live 2.1.3
By JavaBean in forum Java SoftwareReplies: 0Last Post: 07-06-2007, 03:43 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks