Click here to Skip to main content
15,884,298 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created frame in Java using JFrame and I want to set background image for it.I don't know how to do it in easiest way possible. I tried using JComponent but that doesn't help. I have attached the code below

What I have tried:

 * Created by KAVITA on 11/12/2017.
import javax.swing.*;
import java.awt.*;

public class page1 {
    JFrame frame;
    JButton play,settings;
        frame = new JFrame("GameName");
        frame.setLayout(new FlowLayout());
        play = new JButton ("Play");
        settings = new JButton ("Settings");

    public static void main (String args[]) {
        new page1();
Updated 18-Dec-17 21:59pm

1 solution

Share this answer
Member 13583984 19-Dec-17 11:23am    
Thanks for the help. But I'm totally new to Java and I tried editing my code according to all methods possible. Can someone show me how can I edit my code ? I need modifications in my above code.
Richard MacCutchan 19-Dec-17 13:07pm    
If you do not understand the basics, then you are going to struggle. I strongly suggest you go to The Java™ Tutorials[^] and work through all the basics and then the graphics.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900