Results 1 to 3 of 3
  1. #1
    Join Date
    Jan 2011
    Rep Power

    Angry How can you get a custom background image for a Jframe +

    Hi, my problem is i'm trying to get a custom background for my frame, everything else works with my program and i tried a bunch of different methods but none seem to work. This is the part of my program that displays the first button and i got a custom background color, so can anyone tell me wat i should add.

    import javax.swing.*;
    import java.awt.*;

    import javax.swing.JFrame;
    public class ISU{
    public static void main(String[] args){
    Button1 go = new Button1();
    go.getContentPane().setBackground(Color.BLACK);//part i need to change

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Washington, DC
    Rep Power


    You just want your JFrame to have a background color? Or are you trying to set the background of the JButton?

    "go" is a JButton, so it doesn't have a content pane.
    How to Ask Questions the Smart Way
    Static Void Games - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

  3. #3
    Join Date
    Jan 2011
    Rep Power


    well instead of a background color i want a background image and the line go.getContentPane().setBackground(Color.BLACK); changes the background color for the frame, not the button but if this method doesn't work i can use a different one.

Similar Threads

  1. Replies: 6
    Last Post: 07-21-2010, 06:15 AM
  2. JFrame image background
    By 851marc in forum NetBeans
    Replies: 5
    Last Post: 03-09-2010, 06:27 PM
  3. How to add a background image to JFrame
    By dunafrothint in forum AWT / Swing
    Replies: 1
    Last Post: 02-26-2010, 10:17 PM
  4. Need help with JFrame background image
    By ProGenius in forum New To Java
    Replies: 6
    Last Post: 12-27-2009, 04:17 PM
  5. Replies: 2
    Last Post: 03-24-2008, 05:29 AM

Posting Permissions

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