Ok I got this atm.
The thing I have a question with. Inside the ActionListener is where you put the action of clicking the button right? It works and everything the thing is when someone clicks the bottom I want to remove the button from the frame so i can build a game inside instead.PHP Code:
package rpsgui;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
import javax.swing.Icon;
import javax.swing.JDialog;
import javax.swing.JFrame;
public class RPSgui {
public static void main(String[] args) {
// Creates JFrame.
JFrame jf = new JFrame("RPS - @Xyn") ;
jf.setSize(500, 500);
jf.setVisible(true);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Create Panel
JPanel jp = new JPanel();
jp.setVisible(true);
// Creates Play JButton.
JButton pla = new JButton("Play RPS");
pla.setLocation(120, 50);
pla.setVisible(true);
jf.add(jp);
jf.add(pla);
me tyl = new me();
pla.addActionListener(tyl);
}
static public class me extends RPSgui implements ActionListener{
public void actionPerformed(ActionEvent e){
System.out.print("CLICKEDDD");
}
}}
But I run into a problem since the buttons located outside the action listener I cannot refer to the button inside the main class...
Just started doing ActionListener so sorry if they awsner is obvious.