Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how to handle action events in case of more than one JFrame

Have Programming Question? Ask it here!
 
 
 


Ankush Pruthi
how to handle action events in case of more than one JFrame
3 Answer(s)      9 months ago
Posted in : Java Beginners


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


Advertisement
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 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
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
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: Here, we
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
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
Writing more than one cards in a WML deck.
   Writing more than one cards in a deck.In this lesson... opens a new URL, in this case it opens the second card
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
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... to successfully connect using one PC. But when I use another PC to access
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
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. ActionListener can... events and to register them i.e. one for key release, key typed and one
How to Handle Event Handlers?
How to Handle Event Handlers?  How to Handle Event Handlers
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
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 reset JFrame
how to reset JFrame  how to reset JFrame
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
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 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 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
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
What are events? Explain how Event handling in Java?
What are events? Explain how Event handling in Java?  What are events? Explain how Event handling in Java?   Hi, The Events are the integral part of the java platform. Sometimes we want one object to perform shorten
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
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
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
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
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
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
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
JFrame
Jframe. How can i do it. Please help me to do it. Or what else can i have
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
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
How to handle Transaction IN and OUT in Inventory using java
How to handle Transaction IN and OUT in Inventory using java  Hi.... And one more thing is Add New OUT Transaction, I have a jsp page where i have all... in the database with one submit. Now the problem is i have no idea how to do
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 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
Advertisements
 

 

 

DMCA.com