Results 1 to 3 of 3
Thread: Detecting buttons
- 04-06-2012, 03:35 PM #1
Member
- Join Date
- Apr 2012
- Posts
- 68
- Rep Power
- 0
Detecting buttons
I am making a program and i need to check if by buttons get pressed here is my code
Java 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); } }Last edited by jsobel; 04-06-2012 at 04:21 PM.
- 04-06-2012, 05:16 PM #2
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.
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 04-06-2012, 05:52 PM #3
Member
- Join Date
- Apr 2012
- Posts
- 68
- Rep Power
- 0
Similar Threads
-
Detecting second application action's
By ContoNick in forum New To JavaReplies: 5Last Post: 12-30-2011, 06:33 PM -
Detecting if the player presses q or e
By meesterpickles in forum AWT / SwingReplies: 3Last Post: 12-18-2011, 04:38 PM -
Detecting Capitalization
By danthegreat in forum New To JavaReplies: 10Last Post: 09-09-2011, 09:46 PM -
Detecting if string or int
By Alk in forum New To JavaReplies: 6Last Post: 05-14-2011, 11:26 PM -
Detecting a lost X connection
By jeffpaulwilson in forum AWT / SwingReplies: 2Last Post: 03-09-2011, 07:54 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks