Chat Transcript, 97-06-15

=> [David] joins at Sun Jun 15 19:55:22 1997 from 151.198.127.30

=> [Don] joins at Sun Jun 15 19:55:41 1997 from 206.173.45.35

David=> Hey Don
Don=> Whats up dave
David=> company just left, house is a mess
Don=> just got home, otherpeoples house is a mess
David=> works better that way!

=> [Rob] joins at Sun Jun 15 19:58:52 1997 from 128.122.209.58

David=> I have 7:59
Rob=> Hi everyone.
David=> Hello
Don=> let's get this show on the road
Rob=> I'm with you.
Rob=> How are you guys doing so far (coursewise)?
David=> OK, still need to invest more time.
Rob=> It does take a lot of time....
Rob=> and it's pretty strange compared with non-oop.

=> [wachsmut] joins at Sun Jun 15 20:02:07 1997 from 153.35.6.96

David=> yes
wachsmut=> Hi everybody ....
Don=> ahh, finally
wachsmut=> sorry I'm late ....
wachsmut=> First thing:
wachsmut=> happy father's day, for those who are ....

=> [Jenn] joins at Sun Jun 15 20:02:41 1997 from 199.174.133.242

Don=> thanks, you too
David=> thank youditto
wachsmut=> and, no game 7 today !
Don=> yaeh, your team got lucky
wachsmut=> well ... I did get my degree in the midwest,
wachsmut=> so I felt obliged to vote for the Bulls ...
wachsmut=> lucky me !
wachsmut=> Anyway, I hope you enjoyed the 'breather' ...
wachsmut=> no new lecture until yesterday, hope you're 'caught up'....
wachsmut=> I only have one question right now ....
wachsmut=> then we'll - try to - do something new ....
David=> no comment
wachsmut=> -:)
wachsmut=> So ..... this time, I ask you first:
wachsmut=> any questions ?
Rob=> I have a couple.... anybody else first?
wachsmut=> That's no surprise ...
wachsmut=> go ahead, maybe people will be less intimidated later ...
David=> go for it
Rob=> ok.. here goes: In our MoveBox example, what drew the outside rectangle?
Rob=> that is, the box the moving rectangle was in.
wachsmut=> you mean the outside rectangle that shows up in the lecture notes ?

=> [David] leaves at Sun Jun 15 20:07:03 1997

Rob=> Hmmm, I think I just mean the box the buttons and the rectangel were in....

=> [aisha] joins at Sun Jun 15 20:07:19 1997 from 149.150.86.4

wachsmut=> I see, we can do that ....
wachsmut=> any drawing, and I mean *any drawing*, must be done by ...
wachsmut=> well, by which method ?
Rob=> paint
wachsmut=> (that's a 'public String question()')
wachsmut=> yes, exactly !
wachsmut=> So, if you simply put, in any applet, a paint method,

=> [David] joins at Sun Jun 15 20:08:22 1997 from 151.198.127.30

wachsmut=> or better, override the paint method, with a call like this:
wachsmut=> public void paint(Graphics g)
wachsmut=> {
wachsmut=> g.drawRect(0,0, size().width-1, size().height-1);
wachsmut=> }
wachsmut=> then you'll get a 'border' around the entire applet.
wachsmut=> Probably that's what you're referring to, I hope ....
Rob=> ok. that's why I asked... this is what you did in the DrawingCanvas example.
wachsmut=> Yes ... but actually, in the DrawingCanvas example,
wachsmut=> the box is not around the drawing area AND the buttons,
Rob=> right.
wachsmut=> it is only around the drawing area - which is, in some sense,
wachsmut=> the point of using a canvas .....
wachsmut=> (that was my only question for today, I'll come back to that later)
wachsmut=> Any more questions ?
aisha=> no
Rob=> the default for action is super.action... what does super.action return?
Rob=> False?
wachsmut=> well, it depends ....
wachsmut=> return super.action(e, o)
wachsmut=> means that my action method will give the superclass
wachsmut=> a chance to handle the action event. If it does handle it,
wachsmut=> it will return true. But ...
wachsmut=> perhaps it, too, includes a call to super.action(e, o), in
wachsmut=> which case it passes the action event up one more time.
wachsmut=> An action method should return
wachsmut=> 'true' if it really handles the event, otherwise it
wachsmut=> should give the 'next' action method a chance to handle it.
wachsmut=> Matter of fact, that did cause lots of confusion
wachsmut=> in general, and that's exactly what
wachsmut=> was changed in Java 1.1 .... the event handling mechanism
wachsmut=> was improved a lot ... because people were pretty confused.
wachsmut=> For now, as a rule of thumb:
wachsmut=> - you handle the action even, you should return 'true'.
wachsmut=> - you don't handle it, you should give another action method a chance ....
wachsmut=> so much for that (from me).
wachsmut=> Anything else ?
aisha=> nope
David=> no
wachsmut=> (you are allowed to say no ....)
wachsmut=> Alright, then ....
wachsmut=> here's my question:
wachsmut=> what's a canvas, and what's it good for ?
wachsmut=> (while you're thinking, we have all five registered class members here !)
Rob=> It's a space on which to paint (no joke intended).
wachsmut=> (that's great, thanks for coming today !!!)
wachsmut=>
wachsmut=> Yes, exactly, that's what it is !
wachsmut=> but ....
wachsmut=> you can always paint by simply overriding the 'paint' method,
wachsmut=> so why is a Canvas necessary ?
wachsmut=> well ... when you 'paint' in a, say, Frame, then your drawings
Rob=> It provides a specific object within the application in which the drawing ...
Rob=> takes place....
wachsmut=> yes .... exactly, thanks, Rob.
Rob=> Or should I say applet?
wachsmut=> Anything ...
wachsmut=> a 'Canvas' can reside in anything (Frame, applet, etc)....
wachsmut=> If you simply override a 'paint' method inside a Frame, then
wachsmut=> your paintings will go 'everywhere', regardless
wachsmut=> of the GUI buttons, or anything else, that's already there.
wachsmut=> That means that often part of your drawing will be
wachsmut=> 'underneath' something else, hence it will not work right
wachsmut=> So ...
wachsmut=> if you paint inside a Canvas only, then you can
wachsmut=> use a layout manager to arrange that canvas together with
wachsmut=> the rest of your GUI componets, and then the
wachsmut=> drawing will only take place inside that canvas !
wachsmut=> Let's take a look at an example ....
wachsmut=> First, as usual, you must be using
wachsmut=> Windows 95 + Netscape .... I hope you do !
David=> ok
wachsmut=> I will be showing you an 'applet', that has two links at the bottom
wachsmut=> for some source code. Wait until the applet has loaded, then
wachsmut=> click on each of the source code links, and save the two files.
wachsmut=> to your disk.
wachsmut=> I mean the two source code files.
wachsmut=> Are you ready ?
wachsmut=> Please say 'yes' ...
Don=> yes
Rob=> yes
David=> yes
Jenn=> yes
wachsmut=> Aisha (I know, probably not using Win95 ...., oh well)
wachsmut=> Alright, here we go. Take 5 minutes to look things over,
wachsmut=> and save the source code ....
Rob=> Bert... I'm back... got these already from the lecture notes.
wachsmut=> please ... then, say 'aye' when you're back, please.
Rob=> probably....

=> [aisha] leaves at Sun Jun 15 20:25:42 1997

=> [Don] leaves at Sun Jun 15 20:25:50 1997

=> UNEXPECTED ERROR: client not found in list.

=> [Don13] joins at Sun Jun 15 20:26:01 1997 from 206.173.45.35

=> [aisha] joins at Sun Jun 15 20:26:21 1997 from 149.150.86.4

Jenn=> i'm back..
Don13=> me too but as a different name

=> [wachsmut] leaves at Sun Jun 15 20:26:53 1997

=> UNEXPECTED ERROR: client not found in list.

=> [wachsmut7] joins at Sun Jun 15 20:26:58 1997 from 153.35.6.96

aisha=> i'm still here
wachsmut7=> Alright, everybody back, then....
wachsmut7=> Now, in that code (same as in the lecture) there's an applet and

=> [Rob] leaves at Sun Jun 15 20:27:31 1997

=> UNEXPECTED ERROR: client not found in list.

wachsmut7=> a canvas class. The applet class simply arranges

=> [Rob1] joins at Sun Jun 15 20:27:38 1997 from 128.122.209.58

Rob1=> hello.. back
wachsmut7=> all components on the screen, including the 'Canvas'.
wachsmut7=> the 'Canvas' class is responsible for drawing.
David=>
wachsmut7=> Since it is a Canvas, it can draw where ever it wants to, and
wachsmut7=> it won't disturb anything else.
wachsmut7=> Alright .... let's keep that in the back of our head for now.
wachsmut7=> We will now try to change that applet you've just seen,
wachsmut7=> so that the box will move 'by itself' ....
wachsmut7=> We may not finish, but we'll start ....
wachsmut7=> Alright ....
wachsmut7=> what we want to discuss, briefly, is 'threads'.
wachsmut7=> A thread is another piece of code that can execute
wachsmut7=> independently and at the same time with the rest of your code.
wachsmut7=> One program can have many threads (no limit) that all
wachsmut7=> work simultaneously, but they can also
wachsmut7=> be synchronized, if necessary.
wachsmut7=> How does it work ?
wachsmut7=> For a program to use a thread, several things are
wachsmut7=> necessary:
wachsmut7=> 1. your applet (or frame, or anything else) must
wachsmut7=> 'implement Runnable' after the 'extends whatever'.
wachsmut7=> 2. You usually have a field of type 'Thread'
wachsmut7=> 3. You must implement a method called 'run'
wachsmut7=> 4. You should implement two methods called 'start' and 'stop'
wachsmut7=> that's all.....
wachsmut7=> here's an example .......
wachsmut7=> again, get ready for an applet, together with a link for source
wachsmut7=> code. Take 5 minutes to carefully look at the source code,
wachsmut7=> and especially try to identify the step 1 - 4 mentioned above.
wachsmut7=> Are you ready ?
David=> yes
Rob1=> yes
Jenn=> yes
Don13=> yes
aisha=> y
wachsmut7=> Alright, here we go. See you back here in 5 minutes from now....

=> [Don13] leaves at Sun Jun 15 20:34:11 1997

=> [aisha] leaves at Sun Jun 15 20:35:01 1997

=> [Don13] joins at Sun Jun 15 20:37:30 1997 from 206.173.45.35

David=> lk;lk
David=> back
wachsmut7=> lk; lk ?????
Don13=> back
wachsmut7=> Alright, every body back ?
Rob1=> yes

=> [aisha] joins at Sun Jun 15 20:38:13 1997 from 149.150.86.4

Jenn=> i'm back..
wachsmut7=> Jenn and Alisha ?
wachsmut7=> Sorry ... meant to say: aisha ?
aisha=> i'm here
wachsmut7=> Great....
wachsmut7=> So, I hope you saw something that simply counts up,
wachsmut7=> until infinity.
wachsmut7=> Here's how it works, briefly:
wachsmut7=> the class extends Applet, so it's an applet ....
wachsmut7=> when it's loaded, the 'init' method executes .... and adds
wachsmut7=> the textfield to the layout area.
wachsmut7=> Then it calls 'start'.
wachsmut7=> Since the field 'thread' is initially 'null', the 'start' method
wachsmut7=> will instantiate a new thread, with input "this", and then call
wachsmut7=> the 'thread's start' method.
wachsmut7=> When the thread's start method is called, it will automatically (!)
wachsmut7=> execute the applet's 'run' method
wachsmut7=> and that method is an infinite loop:
wachsmut7=> it increase the counter,
wachsmut7=> updates the textfield
wachsmut7=> and puts the thread to sleep for 400 milliseconds
wachsmut7=> inside some funny 'try-catch' phrase.
wachsmut7=> Since the loop inside the 'run' method is
wachsmut7=> an infinite loop, it looks as if your program will count, and count,
wachsmut7=> and count, and count, ....
wachsmut7=> but ....
wachsmut7=> what do you simply have to do to stop counting ?
wachsmut7=> Any clues ????
David=> lleave applet?
wachsmut7=> I.e. how can you interrupt the seamingly infinite loop in the 'run' method !
wachsmut7=> YES !
wachsmut7=> Actually, what do you mean, 'leave applet', and 'why'
David=> go to another url? which will stop execution
wachsmut7=> yes, and why will it stop execution ?
David=> ?
wachsmut7=> Well ... anyone ?
Rob1=> Leaving executes stop.
wachsmut7=> Right !
Don13=> wasn't there a method that happened when you leave and enter a page
wachsmut7=> Since the applet has a 'stop' method, that method will automatically
wachsmut7=> execute when you leave the page ....
wachsmut7=> Alright, great question, Don13 ....
wachsmut7=> what will happen when you revisit the page ?
wachsmut7=> and, of course, why ?
Don13=> the applet will start agaion?
wachsmut7=> Yes, because it implements the 'start' method !
wachsmut7=> Both, the 'start' and the 'stop' methods are cooked up so that

=> [aisha] leaves at Sun Jun 15 20:46:52 1997

Don13=> does it sart from 0 or pick up where it left off?
wachsmut7=> I love it ... well ???? Take a guess !!!!
Don13=> probably from 0 right??
wachsmut7=> Take another guess ....

=> [aisha] joins at Sun Jun 15 20:47:21 1997 from 149.150.86.4

Don13=> pick up where it left off
Rob1=> Nothing re-initializes it.
wachsmut7=> look at the start method : does that method 'reset' the 'count' ?
wachsmut7=> As Rob said, it does not.
Rob1=> What does it mean thread != null?
wachsmut7=> It simply checks if the variable 'thread' is set to null.
wachsmut7=> 'null' is a special keyword, that refers to a 'well-defined' nothing-ness.
Rob1=> Sort of how I feel on monday mornings.
wachsmut7=> In the field declaration, 'thread = null' is declared.
Rob1=> Got it... and stop resets it to null.
wachsmut7=> then in start, thread is not null, because it get's instantiated.
wachsmut7=> Then, if you leave the page, the stop method sets 'thread = null'.
wachsmut7=> The start method will then, again, start the thread.
wachsmut7=> What would you have to do to 'reset' to zero after you leave and
wachsmut7=> re-enter the page ?
wachsmut7=> it's one line, added exactly where ?
David=> in the sip method?
David=> stop method
wachsmut7=> yes, that woud work.
wachsmut7=> Or, perhaps better, in the 'start' method.
wachsmut7=> Alright, that's the basic framework for using *one* thread:
David=> count + 0
David=> = 0
wachsmut7=> - declare a field 'thread' of type Thread, set it to null.
wachsmut7=> - define a 'start' method, exactly as the one you've seen
wachsmut7=> - define a 'stop' method, exactly as the one you've seen
wachsmut7=> - implement a run method ....
wachsmut7=> the run method *should* include a call to 'thread.sleep(###)', but
wachsmut7=> the rest of the run method is different for different tasks.
wachsmut7=> Actually, the 'thread.sleep(###)' is always embedded inside a
wachsmut7=> 'try-catch' block, just as you've seen.
wachsmut7=> So .... wanna change our 'Moving Box' to include a thread ?
wachsmut7=> I'll show you the applet, then ....
wachsmut7=> I'll quickly discuss the steps necessary to change the first source
wachsmut7=> code into that, and then - back to happy father's day !
wachsmut7=> Alright, ready to see the final applet of the day ?
David=> yes
Rob1=> fire when ready
Jenn=> yes
aisha=> y
Don13=> sure
wachsmut7=> Alright, here we go ... be back soon, and say 'thanks' ... -:)

=> [Don13] leaves at Sun Jun 15 20:55:33 1997

=> [aisha] leaves at Sun Jun 15 20:55:39 1997

David=> back
wachsmut7=> woah, that's quick ....
Jenn=> bback
wachsmut7=> Alright .... hang on just a little longer !
wachsmut7=> David, Jenn back, how about the rest ?
Rob1=> back
wachsmut7=> Alrihgt .... two more ...
wachsmut7=> Well, here's the steps necessary to accomplish that:
wachsmut7=> First, the original code is the one we've seen, and saved, at the
wachsmut7=> beginning of our 'chat' ... two classes, one applet, one 'canvas' ....

=> [Don13] joins at Sun Jun 15 20:58:21 1997 from 206.173.45.35

David=> yes
wachsmut7=> which one will get the 'thread' ????? (That's the 'key question') !

=> [aisha] joins at Sun Jun 15 20:58:42 1997 from 149.150.86.4

David=> applet
wachsmut7=> Remember, the applet handles the events, while
wachsmut7=> the 'canvas' handles the drawing....
wachsmut7=> so, what does or thread do ?
wachsmut7=> Does it have to do with events, or does it have to do with
wachsmut7=> drawing ?
David=> drawing
wachsmut7=> Well ... the threa
wachsmut7=> Exactly !
wachsmut7=> (sorry) ...
wachsmut7=> so, here's today's wrap-up ....
wachsmut7=> Take the 'DrawingCanvas' class from earlier, and do the following:
wachsmut7=> - add a field 'thread', set it to null, of type 'Thread'
wachsmut7=> - add 'implement Runnable' to the 'extends Canvas'
wachsmut7=> - add the 'standard' 'start' and 'stop' methods, as seen before
wachsmut7=> dealing with thread (called 'standard thread control)
wachsmut7=> - add a 'run' method including a thread.sleep(100) call inside
wachsmut7=> a 'try-catch' block', just as before, nothing new.
wachsmut7=> - here's the new stuff:
wachsmut7=> add a field 'String direction = "left" to the canvas class
wachsmut7=> add if statements to the 'run' method like this:
wachsmut7=> if (direction.equals("left"))
wachsmut7=> boolean dummy = handleLeft();
wachsmut7=> else if (direction.equals("right"))
wachsmut7=> boolean dummy = handleRight();
wachsmut7=> etc.
wachsmut7=> Finally, add one more method to the 'canvas' class:
wachsmut7=> public boolean changeDirection(String _direction)
wachsmut7=> {
wachsmut7=> direction = _direction;
wachsmut7=> return true;
wachsmut7=> }
wachsmut7=> Save and compile.
wachsmut7=> Change the applet, but only two changes:
wachsmut7=> - in the ation method, change 'handleLeft()' to
wachsmut7=> changeDirection("left");
wachsmut7=> etc.
wachsmut7=> add 'drawing.start()' to the 'init()' method.
wachsmut7=>
wachsmut7=> That's it !
wachsmut7=> I'll post the solution on Tuesday, but
wachsmut7=> I hope you'll experiment before that !
wachsmut7=> Sorry I went overtime, class over -
wachsmut7=> I'll be hanging around for questions ....
wachsmut7=> if you have any !
wachsmut7=> Thanks A LOT for all showing up on a great day as today !
Rob1=> thank to YOU too.
Don13=> thanks, 'ill look this over again and post any questions to
wachsmut7=> P.S.: In case you didnt' catch it, I'll post the transcript in 30 minutes !
Don13=> the discussion board
Don13=> bye!
David=>
wachsmut7=> Bye - love quesitons !

=> [Don13] leaves at Sun Jun 15 21:06:30 1997

Rob1=> bye
David=> good night

=> [Don] leaves at Sun Jun 15 21:06:47 1997

=> [Rob1] leaves at Sun Jun 15 21:06:49 1997

=> [Rob1] joins at Sun Jun 15 21:06:53 1997 from 128.122.209.58

=> [Rob1] leaves at Sun Jun 15 21:06:55 1997

wachsmut7=> night !

=> [Rob] leaves at Sun Jun 15 21:07:06 1997

=> UNEXPECTED ERROR: client not found in list.

Jenn=> actually i have a question about the jdk...
wachsmut7=> yes ?

=> [Rob1] joins at Sun Jun 15 21:07:19 1997 from 128.122.209.58

Jenn=> well i finally got my computer to work.. and i installed it and the pfe..
wachsmut7=> GREAT !
Jenn=> and i saved the files for my protfolio and compitled the program..
wachsmut7=> so far so good ...

=> [Rob1] leaves at Sun Jun 15 21:07:57 1997

Jenn=> but i keep getting 2 errors when i compile the test file

=> [Rob1] joins at Sun Jun 15 21:08:08 1997 from 128.122.209.58

=> [David] leaves at Sun Jun 15 21:08:13 1997

aisha=> bye - great class :] - good night
wachsmut7=> Night, Aisha !
wachsmut7=> (thanks)

=> [Rob1] leaves at Sun Jun 15 21:08:29 1997

Jenn=> i mean the file with the main method...

=> [aisha] leaves at Sun Jun 15 21:08:36 1997

wachsmut7=> what are those errors, Jenn ?
Jenn=> and i think i'm typing it in right..
Jenn=> class Task not found in type declaration
wachsmut7=> Well, can you mail me the file ? I can take a look then ?
Jenn=> Task toDo = new Task();
wachsmut7=> If you mail me right away, I'll look at it and have an answer 30 minutes
wachsmut7=> after I get it .....
wachsmut7=> it's hard to discuss specifics such as that in 'chat' ....
Jenn=> but i compiled them in pico and they both compiled..
wachsmut7=> Hmmm ....
wachsmut7=> sounds strange......
wachsmut7=> perhaps you forgot another file ? Something like 'TaskTest.java' and
Jenn=> because i think the only way i can mail it to you is through my sciris account.. and i don't want to write over the files in there..
wachsmut7=> 'Task.java', both in the same directory ?
wachsmut7=> No - you have Netscape, so you can email !
Jenn=> i have Task.java as the program file
wachsmut7=> That is, send email, perhaps not receive it.
Jenn=> and TaskTest.java for the main file
wachsmut7=> Yes, that' right .... it sems ... and both in the same directory, I anm
wachsmut7=>
wachsmut7=> sure.
wachsmut7=> Wanna know how to send email with Netscape ?
Jenn=> i think i need information from the service that i dialed into for the netscape mail to work..
Jenn=> and my brother won't give it to me...
wachsmut7=> Not at all ....
wachsmut7=> it's easy, no info needed !
wachsmut7=> wanna know ?
Jenn=> oh... ok. let me try it..
Jenn=> sure..
wachsmut7=> Alright, here's the steps:
wachsmut7=> first, click on 'options', then pick 'mail and news' ....
wachsmut7=> make sure you find 'servers' or something like that, and you
Jenn=> oh yeah.. i downloaded netscape 4 and it's great!
wachsmut7=> Even better ... here's exactly what to do, then:
wachsmut7=> click on 'Edit', the 'Preferences'.....
Jenn=> uh huh...
wachsmut7=> then on 'Mail' and 'Groups'
wachsmut7=> (make sure you click on the little 'plus' sign')
wachsmut7=> click on Identity, fill in your name and email address at SHU
wachsmut7=> click on Mail server, and under SMTP server, fill in 'www.shu.edu'
wachsmut7=> That's it.
wachsmut7=> Leave incoming mail server (pop3) blank....
wachsmut7=> Then click on File, then 'new', then 'message', and send your message
wachsmut7=> to 'wachsmut@shu.edu' - simply 'cut-and-paste' your source code,
wachsmut7=> or attach via the attach button.
wachsmut7=> Got it ?
Jenn=> got it!
Jenn=> thanx.. =)
wachsmut7=> Alright .... I'll be waiting ... if that does not work,
wachsmut7=> simply 'post' your code to the discussion area (perhaps that's
wachsmut7=> the better way, and easier, anyhow (using cut-and-paste)
Jenn=> oh yeah one more thing..
wachsmut7=> yes ?
Jenn=> for me to put my program onto my homepage..
Jenn=> do i have to copy it to the sciris account?
wachsmut7=> yes, using the 'FTP' program you can download from our
wachsmut7=> homepage.
wachsmut7=> I'll post some details, it's a good point (I forgot to do that
Jenn=> ok..
wachsmut7=> so far, thanks for bringing it up )
wachsmut7=> I'll have that done tomorrow, not tonight, though .... -:)
Jenn=> great... thanks for all your help!
wachsmut7=> Alright, then, waiting for your email ! And no problem !
wachsmut7=> Bye .
Jenn=> bye

=> [wachsmut7] leaves at Sun Jun 15 21:20:21 1997

=> [Jenn] leaves at Sun Jun 15 21:20:23 1997