how to handle action events in case of more than one JFrame
I have downloaded a snake game project from the internet, initially this project contains three java files namely
1. Engine.java
2. Snake.java
3. Gameoard.java
when i runs Engine.java ,game starts running ..
Now i have done some modification in it to improve the interactivity of the game, i.e i have added two #JDialog named
1. PlayGame.java
- RulesDialog.java
PlayGame.java has three JButtons :- Play button, Rules Button , Exit
-when play button gets clicked game should start
-when rules button gets clicked RulesDialog.java JDialog appears and when
-exit button gets clicked application or game should be closed.
Action of button is set in the actionPerformed() method of individual buttons.
Now problem i am facing is when i click Play button game window is visible on the screen but snake is not moving
and i am not getting to point how to resolve this problem ..
So plz help me out
View Answers
September 30, 2013 at 4:29 PM
Hi,
Somehow the method for moving is being not executed by the actionPerformed() method.
Debug the code in Eclipse and find out the bug.
Thanks
September 30, 2013 at 5:46 PM
hey,
after debuggign the project ,it does not display any error or warning message in the problem and console window.
October 1, 2013 at 11:40 AM
when i click play button debugger show me this output
Thread [AWT-EventQueue-0] (Suspended (entry into method jButton1ActionPerformed in PlayGame))
PlayGame.jButton1ActionPerformed(ActionEvent) line: 89
PlayGame.access$0(PlayGame, ActionEvent) line: 87
PlayGame$1.actionPerformed(ActionEvent) line: 40
JButton(AbstractButton).fireActionPerformed(ActionEvent) line: not available
AbstractButton$Handler.actionPerformed(ActionEvent) line: not available
DefaultButtonModel.fireActionPerformed(ActionEvent) line: not available
DefaultButtonModel.setPressed(boolean) line: not available
BasicButtonListener.mouseReleased(MouseEvent) line: not available
JButton(Component).processMouseEvent(MouseEvent) line: not available
JButton(JComponent).processMouseEvent(MouseEvent) line: not available
JButton(Component).processEvent(AWTEvent) line: not available
JButton(Container).processEvent(AWTEvent) line: not available
JButton(Component).dispatchEventImpl(AWTEvent) line: not available
JButton(Container).dispatchEventImpl(AWTEvent) line: not available
JButton(Component).dispatchEvent(AWTEvent) line: not available
LightweightDispatcher.retargetMouseEvent(Component, int, MouseEvent) line: not available
LightweightDispatcher.processMouseEvent(MouseEvent) line: not available
LightweightDispatcher.dispatchEvent(AWTEvent) line: not available
PlayGame(Container).dispatchEventImpl(AWTEvent) line: not available
PlayGame(Window).dispatchEventImpl(AWTEvent) line: not available
PlayGame(Component).dispatchEvent(AWTEvent) line: not available
EventQueue.dispatchEventImpl(AWTEvent, Object) line: not available
EventQueue.access$200(EventQueue, AWTEvent, Object) line: not available
EventQueue$3.run() line: not available
EventQueue$3.run() line: not available
AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: not available [native method]
ProtectionDomain$1.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext, AccessControlContext) line: not available
ProtectionDomain$1.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext) line: not available
EventQueue$4.run() line: not available
EventQueue$4.run() line: not available
AccessController.doPrivileged(PrivilegedAction<T>, AccessControlContext) line: not available [native method]
ProtectionDomain$1.doIntersectionPrivilege(PrivilegedAction<T>, AccessControlContext, AccessControlContext) line: not available
EventQueue.dispatchEvent(AWTEvent) line: not available
EventDispatchThread.pumpOneEventForFilters(int) line: not available
EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: not available
EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: not available
EventDispatchThread.pumpEvents(int, Conditional) line: not available
EventDispatchThread.pumpEvents(Conditional) line: not available
EventDispatchThread.run() line: not available
Can you please tell me how to resolve this
Related Tutorials/Questions & Answers:
How to get more than one value from ajaxHow to get
more than one value from ajax I have multiple select list box in php. i filled the value using ajax.
how to get different value to fill the same list box
Ex.
option value as id
(adsbygoogle
Advertisements
how to open one Jframe from main method callhow to open
one Jframe from main method call I have downloaded...(is a
JFrame)
Rules.java(is a
JFrame)
PlayGame.java have three buttons
Play - i... Rules.java
Jframe should be opened
Exit - exits the application
Now what i want
Is Python more powerful than C++?Is Python
more powerful
than C++? Hi,
I am beginner in Data Science...:
Is Python
more powerful
than C++?
Try to provide me good examples or tutorials links so that I can learn the
topic "Is Python
more powerful
than C++?"
Action Event Listener listener for the
component but second way permits you to include
more than one...
Action Event Listener
Action Listeners can be implemented
passing data from one jframe to anotherpassing data from
one jframe to another I have two
JFrame,built... in the first
Jframe to another JLabel in the other JFrame.Can you please help me,
how...*;
import java.awt.event.*;
class PassData extends
JFrame
{
JTextField text
How to handle enter key in javascriptHow to
handle enter key in javascript Can any
one tell me
how to
handle the enter key event on a Button in HTML. Like in my simple HTML page i want......
(adsbygoogle = window.adsbygoogle || []).push({});
<form
action="iPage.php
how to add scrollbar to JFramehow to add scrollbar to JFrame hello friends
i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to
JFrame than how to add scrollbar to JFramehow to add scrollbar to JFrame hello friends
i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to
JFrame than how to add scrollbar to JFramehow to add scrollbar to JFrame hello friends
i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to
JFrame than how to add scrollbar to JFramehow to add scrollbar to JFrame hello friends
i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to
JFrame than how to add scrollbar to JFramehow to add scrollbar to JFrame hello friends
i am making a java application in which i have a frame to which i wanted to add scrollbars but when i add my panel to scrollpane and then add that scrollpane to
JFrame than problem in sending more than 500 values to a jsp pageproblem in sending
more than 500 values to a jsp page when i am trying to send
more than 500 values from a html form to a jsp page browser is showing that server is not sending any data...I have configured tomcat5.5
JFrameJFrame write an application with a
JFrame that five labels describing reasons that a customer might not buy your product(for example "Too expensive") every time the user clicks a Jbutton, remove
one of the negative reasons
JFrame Jframe.
How can i do it. Please help me to do it. Or what else can i have
jframejframe Create a
JFrame for the Summervale Resort. Allow the user to view the information about different rooms available, dining options and activities offered. Include at least two options in each menu and display appropriate
Java : String Case ConversionJava : String
Case Conversion
In this section we will discuss
how to convert a String from
one case into
another
case.
Upper to Lower
case Conversion...
one case to another
case. 'uStr' String type variable
containing upper
jframejframe
how to create a jframe.provide me the java code pls
how to draw a table on jframe in java - Java Beginnershow to draw a table on
jframe in java
how to draw a table on
jframe... scrollPane = new JScrollPane(table);
JFrame frame = new
JFrame..."));
}
}
}
}
-------------------------------------------
Visit for
more information.
http
Events;
In this section, you will learn
how to
handle events in
Java awt.
Events... for the button's
action
events that creates a Button instance.ADS_TO_REPLACE_1
ActionListener... to be implemented for Key
events
and to register them i.e.
one for key release, key