-
Detecting buttons
I am making a program and i need to check if by buttons get pressed here is my code
Code:
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.KeyEvent;
import javax.swing.*;
public class ExitScreen {
public static void main(String[] args)
{
JFrame f = new JFrame("Exit Screen");
f.setSize(400, 150);
Container content = f.getContentPane();
content.setBackground(Color.white);
content.setLayout(new FlowLayout());
content.add(new JButton("EXIT"));
content.add(new JButton("PLAY AGAIN"));
f.setVisible(true);
}
}
-
Re: Detecting buttons
Read the API for JButton and follow the link to the tutorial on How to Use Buttons, Check Boxes, and Radio Buttons where you will find a detailed explanation and sample code.
db
-
Re: Detecting buttons
thanks sorry about old format