Adding a JPanel into a JFrame
I know this sounds like an easy question, but I am making a simple text
adventure with buttons and such, and I cant figure out how to add my
Jpanel into my JFrame. My JPanel has a bunch of buttons and graphics and
stuff if that makes a difference. I have provided the code below. frame
panel=new frame(); is the other class which extends JPanel. I know its
confusing that its called "frame", its because I used to have it extend
JFrame. Anyways my code doesnt produce the buttons, graphics etc, from the
other class like it should. Thanks,
package sonomaroller;
import javax.swing.*;
import java.awt.*;
import static javax.swing.JFrame.*;
public class SonomaRoller extends JFrame {
public static Dimension size = new Dimension(550,550); //Dimension of
Frame
public static String title = "Sonoma Roller v0.00" ;
public SonomaRoller(){
setTitle(title);
setSize(size);
setResizable(false);
setLocationRelativeTo(null); // null centers window on screen
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
System.out.println("hello?");
//setLayout(null);
setVisible(true);
}
public static void main(String[] args) {
SonomaRoller object1=new SonomaRoller();
frame panel=new frame();
}
}
No comments:
Post a Comment