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

Ads
 

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

Ads









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 option name as some string
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
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
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
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
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
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
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
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... action="iPage.php" method="post"> <input type="text" name="iText"> <
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
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
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
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
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
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: Hibernate Tutorial Thanks
Event Handling In Java
Event Handling In Java In this section you will learn about how to handle... the heavy coding. Adapter class is defined for the listener that has more than... will demonstrate you about how to handle an event. In this example we will give
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

Ads