how to handle action events in case of more than one JFrame

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

  1. 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 handle action events in case of more than one JFrame
how to handle action events in case of more than one JFrame   I have... button gets clicked application or game should be closed. Action of button... is not moving and i am not getting to point how to resolve this problem .. So
How to get more than one value from ajax
How 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 Display Duplicate elements from more than one List in java?
How to Display Duplicate elements from more than one List in java?  How to Display Duplicate elements from more than one List in java? //I mean... How to Display common elements Display   Hare is an example
Apply more than one xsl for single XML
Apply more than one xsl for single XML  How to apply more than one xsl for same xml file
More than one Faces Configuration file
More than one Faces Configuration file  Is it possible to have more than one Faces Configuration file
more than one struts-config.xml file
more than one struts-config.xml file  Can we have more than one struts-config.xml file for a single Struts application
Can a Class extend more than one Class?
Can a Class extend more than one Class?   Hi, Can a Class extend more than one Class? thanks
Hi.. how to write more than one sheets in a excel file... pls anybody help me....
Hi.. how to write more than one sheets in a excel file... pls anybody help me... more than one sheets.. For example: first sheet have complete mean automatically... "+tableName+" having more than 65536 rows"); System.out.println
Implementing more than one Job Details and Triggers
will learn how to implement more than one triggers and jobs with a quartz... Implementing more than one Job Details and Triggers... of more than one job details and triggers. Description of program:ADS
how to restrict user against marking same event more than one times - JSP-Servlet
how to restrict user against marking same event more than one times  Hi I am developing student feedback system for educational institution...(event) is stored in final database. Now how can I restrict the student against
how can retrieve more than one values in text field using ajax?
how can retrieve more than one values in text field using ajax?  im using php and ajax. Problem is that i want to search seat numbers bases of batch and semester condition on onchange event eg. if i search batch 2008 and semester
for writting java program why we are taking more than one class
for writting java program why we are taking more than one class  for writting java program only one class is enough but why we are taking more than one class
Deployment on Server that can be used simultaneously by more than one user
Deployment on Server that can be used simultaneously by more than one user  Sir, I have deployed my web application developed using JSP & sevlet. how could i access it on the network using xp os. I have deployed it on Tomcat
Writing more than one cards in a WML deck.
   Writing more than one cards in a deck.In this lesson... seconds. <go> element opens a new URL, in this case
How to write more than 65536 rows in single excel file but more than 1 sheets?
How to write more than 65536 rows in single excel file but more than 1 sheets?  Hi, i want to write more than 65536 rows in single excel file but more than 1 sheets.. now i can write only less than 65536 rows.. but in my office
To get the value of more than one text box in an HTML page to a jsp page - JSP-Interview Questions
To get the value of more than one text box in an HTML page to a jsp page ...... the value of text boxes to a jsp page and how to access the same... all inputs in STRING type only. In this Case (JSP) also all inputs should
Server side validation on dynamically generated fields from more than one table on spring framework.
Server side validation on dynamically generated fields from more than one table on spring framework.   Server side validation on dynamically generated fields from more than one table in spring mvc framework
J query event for selecting the more than one div in tablet browser(Select and drag)?
J query event for selecting the more than one div in tablet browser(Select... to select the more than one tag using the touch and drag event... than one div using the ctrl and shift in web application. But in tablet or ipad
Error in connecting to the mySQL database in TOMCAT using more than one PC (database connection pooling)
Error in connecting to the mySQL database in TOMCAT using more than one PC (database connection pooling)  how do i implement connection pooling...(); I was able to successfully connect using one PC. But when I use another PC
how to open one Jframe from main method call
how 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
Use of "|" separator for selecting more than one path
Use of  "|" separator for selecting more than one path       You can execute.... It allows you more flexibility by allowing you to execute multiple expressions
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
More than 1 preparedStatement object - Java Beginners
More than 1 preparedStatement object  Hey but I want to use more than one prepared Statement object using batch update.. Explain with a code using java... Thanks  Hi Friend, You can use more than one prepared
How to Handle Event Handlers?
How to Handle Event Handlers?  How to Handle Event Handlers
passing data from one jframe to another
passing 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 reset JFrame
how to reset JFrame  how to reset JFrame
how to move label in jframe in java?
how to move label in jframe in java?  please any one can give me code for moving a java label in Jframe
How to handle enter key in javascript
How 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 handle MySQLIntegrityConstraintViolationException?
how to handle MySQLIntegrityConstraintViolationException?  Cannot add or update a child row: a foreign key constraint fails (outerdb.outerpatient, CONSTRAINT outerpatient_ibfk_1 FOREIGN KEY (xrayno) REFERENCES xray (xrayno
Two forms submission to one Action Class in Struts2.0
Two forms submission to one Action Class in Struts2.0  Hi, I have two forms.I want to submit two forms with only one submit button to the same action, same method. How can i get this. Please reply me
how to add scrollbar to JFrame
how 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 JFrame
how 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 JFrame
how 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 JFrame
how 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 JFrame
how 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 handle the text using Key Listener Interface
How to handle the text using Key Listener Interface       In this section, you will learn how to handle the text using the key events on the Java Awt component. All the key events
problem in sending more than 500 values to a jsp page
problem 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
JFrame
JFrame  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
navigating the value of JTextField from one JFrame to another - Swing AWT
navigating the value of JTextField from one JFrame to another  hello I m doing one project where I m retriving the data from databse in JTextField... JFrame .... Can anyone plz tell me how we can do this...can anybody give me
mapping between java class and more than 2 tables
mapping between java class and more than 2 tables  Association mapping of table in hibernate   Hi Friend, Please visit the following link:ADS_TO_REPLACE_1 Hibernate Tutorial Thanks
navigating the value of JTextField from one JFrame to another - Swing AWT
navigating the value of JTextField from one JFrame to another  Hello... is working also.. but only first record is comming... how can I fetch all... JFrame{ JLabel label1,label2; JTextField text1,text2; JPanel panel; JButton
JFrame
Jframe. How can i do it. Please help me to do it. Or what else can i have
jframe
jframe  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 Conversion
Java : 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
How to use java.net.URLConnection to fire and handle HTTP requests?
How to use java.net.URLConnection to fire and handle HTTP requests?  How to use java.net.URLConnection to fire and handle HTTP requests
How does Java handle integer overflows and underflows?
How does Java handle integer overflows and underflows?   hi, How does Java handle integer overflows and underflows? Thanks
jframe
jframe  how to create a jframe.provide me the java code pls
how to draw a table on jframe in java - Java Beginners
how 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

Ads