import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
public class SpeedMathGoStartScreen extends JFrame{
JLabel background;
JLabel title;
JButton play;
JPanel playPanel;
JLabel playLabel;
JButton guide;
JPanel guidePanel;
public SpeedMathGoStartScreen() {
title = new JLabel("SPEED MATH GO");
title.setFont(new Font("Comic Sans", Font.BOLD, 96));
title.setBounds(90, 0, 900, 100);
this.add(title);
ImageIcon backgroundImage = new ImageIcon("C:\\Users\\chenr\\Documents\\Speed Math Go\\iconfinder_play-circle_2561292\\ttt.png");
background = new JLabel(backgroundImage);
background.setBounds(0, 0, 1000, 700);
this.add(background);
ImageIcon playImage = new ImageIcon("C:\\Users\\chenr\\Documents\\Speed Math Go\\iconfinder_play-circle_2561292\\iconfinder_play-circle_2561292.png");
play = new JButton("Play", playImage);
playPanel = new JPanel();
playPanel.setLayout(null);
playPanel.setBounds(345, 200, 300, 150);
play.setBounds(345, 200, 300, 150);
play.setFont(new Font("Comic Sans", Font.BOLD, 48));
play.setBackground(Color.RED);
play.setVisible(true);
playPanel.add(play);
this.add(playPanel);
ImageIcon guideImage = new ImageIcon("C:\\Users\\chenr\\Documents\\Speed Math Go\\iconfinder_play-circle_2561292\\iconfinder_thefreeforty_map_1243687.png");
guide = new JButton("Guide", guideImage);
guidePanel = new JPanel();
guidePanel.setLayout(null);
guidePanel.setBounds(320, 400, 350, 150);
guide.setBounds(320, 400, 350, 150);
guide.setFont(new Font("Comic Sans", Font.BOLD, 48));
guide.setBackground(Color.CYAN);
guide.setVisible(true);
guidePanel.add(guide);
this.add(guidePanel);
//play.addActionListener(new ActionListener()
// {
// public void actionPerformed(ActionEvent e)
// {
// new SpeedMathGoGUI();
// }
// });
play.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new SpeedMathGoGUI();
dispose();
}
});
guide.addActionListener(
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new SpeedMathGoGuide();
dispose();
}
}
);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setSize(1000, 700);
setVisible(true);
}
}
If you run this on Eclipse, only the guide button shows. When I comment out line 56 (should be this.add(guidePanel)), only the play button shows. What adjustments I must make to my code in order for both to display on the JFrame? I would also like to know if other classes may have affected this error as this transitions to two others when the buttons are pressed.