Originally Posted by
zachbray
Excuse me for not putting any of my code. Here is my main class, which handles the frames.
import javax.swing.*;
public class Windows extends JPanel{
public static void main(String[] args){
Graphic g = new Graphic();
RunGame rungame = new RunGame();
TitleScreen title = new TitleScreen();
JFrame mainWindow = new JFrame("Main Window");
mainWindow.setSize(700,500);
mainWindow.setDefaultCloseOperation(JFrame.EXIT_ON _CLOSE);
mainWindow.setVisible(true);
mainWindow.setResizable(false);
mainWindow.setLocationRelativeTo(null);
mainWindow.add(title);
}
}
The thing I've been trying to figure out is how to (on response to clicking) remove title, then add g and rungame to mainWindow. I've tried a ton of ways but they always just keep the component title up. If you know of anyways I could do this, help, or if there is another way to do it other than what I've been trying, please tell me.
Your game will be surely in some other frame, so you just need to read about action listeners and then apply them for invoking the new frame that is in this case your game class frame.