Who is the caller and who is the callee in this callback pattern?
Hi,
Could someone tell me which method is the caller and which is the callee in the following code? Please be as detailed as possible in your explanation.
Thank you in advance!
public class TimePrinter implements ActionListener {
public void actionPerformed(ActionEvent evt) {
Date now = new Date();
System.out.println("At the tone, the time is " + now);
Toolkit.getDefaultToolkit().beep();
public class TimerTest {
public static void main(String[] args) {
ActionListener listener = new TimePrinter();
int delay = 10000; //Delays 10 seconds
//Constructs a timer that calls the listener once every 10 seconds.
Timer t = new Timer(delay, listener);
t.start();
JOptionPane.showMessageDialog(null, "Quit program?");
System.exit(0);
}
jverd,
Thank you again for responding to this thread!
Here is the code:
//TimePrinter.java
import java.util.*;
import java.awt.*;
import java.awt.event.*;
public class TimePrinter implements ActionListener {
public void actionPerformed(ActionEvent evt) {
Date now = new Date();
System.out.println("At the tone, the time is " + now);
Toolkit.getDefaultToolkit().beep();
//TimerTest.java
import java.awt.event.*;
import javax.swing.*;
import javax.swing.Timer;
import java.util.*;
import java.awt.*;
public class TimerTest {
public static void main(String[] args) {
ActionListener listener = new TimePrinter();
int delay = 10000; //Delays 10 seconds
//Constructs a timer that calls the listener once every 10 seconds.
Timer t = new Timer(delay, listener);
t.start();
JOptionPane.showMessageDialog(null, "Quit program?");
System.exit(0);
}Prior to posting to this forum, I actually have done some research and learned the following:
"A callback in programming is executable code that is passed as an argument to other code. "
With this definition, in the above example "actionPerformed" in the TimePrinter class is the executable code, it's being passed to Timer(delay, listener). So the caller here is Timer(delay, listener), callee is the actionPerformed() method, as it is the method that is being called. This is how I interpret it. Am I correct? My question is still which is the caller and callee in this example.
Note, I don't come here often and didn't even know that you could format the text. I formated my msg as you requested, don't know how the text will turn out.
Regards,
Eric
One more question: I tried formatting by placing my code like this my source, what it did is to place the text in a blue area but didn't indent like the source did (I manually indented it). How do I keep the format as the original code?
Edited by: ericdunn on Jul 29, 2009 12:40 PM
Edited by: ericdunn on Jul 29, 2009 12:45 PM
Similar Messages
-
Nokia N70 disconnect the calls and turn on the lou...
Hi Dudes,
I have Nokia N70 now i am facing the problem in N70 that is my Nokia N70 disconnect the calls and turn on the loud speaker automatically. i had gave my phone to nokia care center to fix this Bug. When i gave the phone the IEMI Number was same that is mentioned on the N70 Box, but now i have took my N70 back from the nokia care center i am facing the same problem again and my IEMI Number do not match my actual N70 Box.
I am confused and afraid that something has happened to my phone.
Please tell me what to do know...
Urgent and quick response neededsounds like you there could of been a mix up or you got a recondintioned unit back try a factory reset and see how you get on did you not get a report from nokia?
If i have helped at all a click on the white star below would be nice thanks.
Now using the Lumia 1520 -
my eraphone of my iphone 4s white unlocked make strange noises during the call and still doing the noise like an interference or saturing the spekaer
This is a common problem with iPhone 4s (and IOS 5) There isn't ' anything you can do about it, so you're best bet is to go down to the store and get an exchange. If you have an older iPhone (3gs/4) roll back your update from IOS 5 to IOS 4.
-
What are the charges, and who pays if I send a text overseas?
What are the charges, and who pays if I send a text overseas?
You pay as part of your cellular/telephone bill unless you use Wi-Fi which is free.
-
My iphone 4S has problem in making and receiving the calls. While making the call , call fails and netwrok disappears. Like wise no voice is heard for incoming calls. This happened after return from the overseas travel.
Hello SamSax
Check out the assist page below for troubleshooting call connectivity.
Calls and connection issues
http://www.apple.com/support/iphone/assistant/calls/
Thanks for using Apple Support Communities.
Regards,
-Norm G. -
I updated my Ipod touch 4th gen (IO6 or whatever its called) And it has the picture that says to connect my ipod to Itunes, and I did, now it says "ITunes has detected an Ipod in recovery mode. You must restore this Ipod before it can be used with ITunes." I just updated it and now I have to restore it??! I don't wanna lose all my things on my ipod just for a stupid update! Please someone help!
Once the Device is asking to be Restored with iTunes... it is too late to save anything... and you must continue with the Recovery...
See Here > http://support.apple.com/kb/HT1808
You may need to try this More than Once... Be sure to Follow ALL the Steps...
Take your time... Pay particular attention to Steps 3 and 4.
After you have Recovered your Device...
Re-Sync your Content or Restore from the most recent Backup...
Restore from Backup > http://support.apple.com/kb/ht1766
Note:
Make sure you have the Current Version of iTunes Installed on your computer
iTunes free download from www.itunes.com/download -
my phone has been losing calls and according to the apple store i need to reset it due to a software fault - i have done this and still have the same problems. how do i reset the phone without reinstalling the soft ware fault by way of icloud backup
Well, it appears that your backup is corrupt, thus causing your issue. So, you'll have to restore as a new device, & not from backup. Follow this by syncing your content back to your phone:
http://support.apple.com/kb/ht1414
Do not restore from backup. -
I have a problem in the iPhone 4 is an inability to make or receive calls, and must restore the information from iTunes, how do I do this and what is the way?
iPhone User Guide (For iOS 4.2 and 4.3 Software)
-
In incoming call, why iphone 4S (ios 7.04) sometimes gives option to decline the call and sometimes not?
Try to do this experience.
Ask a person with a block phone to call you and the option to reject doesn´t appear. Try with a non-blocked phone and the option of reject appears.
I think it´s an iOS 7 problem. -
I occasionally get a call and at the end of the call, it sounds like the camera is taking a picture. Anyone else ever experience this?
No, but when the other party hangs up first I have heard the click of the disconnect.
-
ipad can work as a cellphone by putting a SIM card, reciving calls and messages? The messages are send to other cellphones. that don't belong to apple
No. The iPad cannot make/receive cellular calls or send/receive cellular text messages. It can only send and receive cellular data, if equipped with 3G.
-
I have done all the above. I am in Germany using an iPad 2, trying to call an iPad 2 in the UK. My IPad goes through the call and then times out. I have been on the phone to the receiver at the time so know they had their iPad on.
What do you mean that you can't "call" an iPad in the UK?? That doesn't particularly make sense. You can email to an iPad or text them, but the iPad is not a phone, so how do you expect to "call" them??
Hope this helps -
Get the name and path of the calling JSP
Hi all,
I have a code structure like this
class MyBaseServlet extends HttpServlet{
doPost(){processRequest();}
doGet(){processRequest();}
processRequest(req, resp){}
myPrivateMethod(req,resp){
//I want the name of the JSP which invoked the servlet that extends this(MyBaseServlet) here
class MySerlvet extends MyBaseServlet{
processRequest(req, resp){}
I have a JSP which submits in the <FORM> action calls MyServlet. Since MyServlet extends MyBaseServlet, and this has the doPost() and doGet() methods, the control goes here first, and then since MyServlet has overridden the processRequest() method , the control comes here.
My query isthat, while in MyBaseServlet (either in doPost() or doGet(), say I call myPrivateMethod(), is there any way here, inside myPrivateMethod() to get the name of the JSP which called MyServlet.
Note:
The constraint here is that we are not in a position to include any code into either the JSP or MyServlet. I'm running this in a J2EE environment on Websphere.
Thanks in advance.You can use the methods of the HTTPServletRequest class to get the URI/URL info...for example request.getRequestURI() /URL()/ServletPathInfo()
http://java.sun.com/products/servlet/2.3/javadoc/javax/servlet/http/HttpServletRequest.html -
My phone randomly doesn't ring when people call and not sound the text alert. I checked all the settings and them seem to be correct. Sometimes it rings, many times it doesn't. I have missed several calls. Same with texts. Anyone know how to fix this?
Symptoms
No ringer sound
Go to Settings > Sounds > Ringtone and select a ringtone. Does the device ring? (YES: Issue resolved) (NO: Go to step 2)
Go to Settings> General> Reset> Erase All Content and Settings. Warning: This will delete all user data on the device. Verify that you have a backup before proceeding. Go to Settings > Sounds > Ringtone and select a ringtone. Does the device ring? (YES: Issue resolved) (NO: Go to step 3)
Restore device using latest version of iTunes. Go to Settings > Sounds > Ringtone and select a ringtone. Does the device ring? (YES: Issue resolved) (NO: Contact Apple for service options) -
I have an I Phone 5 White 64G, 1/12 month old , and I was an a call and I use the speaker mode , then all the sudden I couldn't hear anything ... I reset the mute switch , I reset setting to factory setting and still no sound... I think speaker just burn out:(
sunshinesunshine wrote:
So basically if a iphone has a fault after the 1 year warranty period is over, there is nothing the consumer can do but purchase a new phone??
Pretty much. Except that Apple will replace it for a fixed fee that is far less than the cost of a new phone. In the US the replacement cost for an iPhone 4 is $149. It is comparable in the UK. Unless you can prove that the fault was present at the time of purchase. A switch wearing out would probably be considered normal wear and tear, not a "fault".
Maybe you are looking for
-
my lock button is jammed and i read somewhere that you can turn your phone on through itunes. i have tried plugging it up to a charger and doing everything you can imagine to get the button unjammed. i cant figure out how to use itunes to get it to t
-
Calculating Accumulative Value for a particular period
Hi, I want to calculate acumulative values based on 0calmonth for a key figure. In Rows, i want 0calmonth and a key figure in Columns. If we select the property of the key figure as "Cumulative". It is adding values like in first month, first month v
-
hi I am in PI 7.1. I have a file to AII scenario. The file server guys gaveme the xsd. I need to two mappings for the target. depending on the value of one field I have to use one of the mappings. I am planning to use multiple operations in single in
-
How do I delete time capsule files and starting over
I installed a time capsule last week and backed up my HD using TM. After doing that, I started moving large movie files from my HD to an external drive, and backing up both the HD and external on the TC. Even though I have only 130 G worth of files i
-
Getting lot of errors like :0x408 in /var/adm/messages file in Solaris 10
Hi, Can anyone help me regarding the following errors being found in the /var/adm/messages file: Nov 24 03:36:07 x9ce1 :0x408 Nov 24 03:36:07 x9ce1 dtcp: [ID 702911 kern.notice] WARNING GW (dtcp_klib.c,198) (53449,33458) (0xac120fd5,0xac126503) Nov 2