I am writing an application with a team, that currently uses 3 different JFrames. From what I have been reading I believe this is the wrong way to go, but I am not sure how to proceed.
When the application starts it opens a small Jframe that allows the user to click on one of 4 buttons. If start game or add images is clicked another window opens. The game window, for the game and the image editing window, for the images. When they close the window the first JFrame reappears.
I've created the first JFrame but have been unable to get the second one to open. I do not know if it is a problem in my code, or if something in the second JFrame isn't set-up properly to call it.
The first JFrame: package mmlgame;
import javax.swing.JFrame;
public class MMLGame extends javax.swing.JFrame {
public MMLGame() {
initComponents();
}
private void btnExitActionPerformed(java.awt.event.ActionEvent evt) {
System.exit(0);
}
private void btnStartGameActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
GameScreen frame = new GameScreen();
frame.setVisible(true);
}
public static void main(String args[]) {
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new MMLGame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton btnAddImage;
private javax.swing.JButton btnCredits;
private javax.swing.JButton btnExit;
private javax.swing.JButton btnStartGame;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lblLogo;
// End of variables declaration
}
I have not set-up all of the buttons yet. I like to get each one working before moving on to the next. The second JFrame: package mmlgame;
public class GameScreen extends javax.swing.JFrame {
public GameScreen() {
initComponents();
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new GameScreen().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel17;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel pnlGameScreen;
// End of variables declaration
}
The second JFrame currently has a label in it. I am the one on the team that suggested using JFrames so if I am wrong please let me know so that I can get the group moving in the right direction. Also I am currently working my way through the Creating a GUI With JFC/Swing. If there is something that explains the concepts better please let me know.