package SoloProject;
import javax.swing.JFrame;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Main
{
public static void main(String[] args)
{
MainScreen homeScreen = new MainScreen();
homeScreen.setSize(600, 400);
homeScreen.setTitle("Chris Tran's Hobby Project");
homeScreen.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
homeScreen.setLocationRelativeTo(null);
homeScreen.setVisible(true);
}//end Main
class Listen implements ActionListener
{
public void actionPerformed(ActionEvent click)
{
if (click.getSource()==buttonGuns)
System.out.println("You are now viewing my gun hobby.");
if (click.getSource()==buttonMotorcycles)
System.out.println("You are now viewing my motorcycle hobby.");
if (click.getSource()==buttonMusic)
System.out.println("You are viewing my music hobby.");
}
}//end Listen
}//end Main class
class MainScreen extends JFrame
{
protected JButton buttonGuns = new JButton("Click to view my gun hobby!");
protected JButton buttonMotorcycles = new JButton("Click to view my motorcycle hobby!");
protected JButton buttonMusic = new JButton("Click to view my music hobby!");
public MainScreen()
{
setLayout(new FlowLayout());
buttonGuns.addActionListener(new Listen());
buttonMotorcycles.addActionListener(new Listen());
buttonMusic.addActionListener(new Listen());
add(buttonGuns);
add(buttonMotorcycles);
add(buttonMusic);
}//end MainScreen constructor
}//end MainScreen Class
I'm just trying to get everything in order before I elaborate on the functions of the button but for some reason my button can not be seen anywhere!! It keeps giving me a cannot find symbol error. I'm not very good with Java so any help will be very helpful. Is it because I'm declaring my button objects as protected?