jump to navigation

Event handling in Java December 19, 2006

Posted by deltawing in Java, Programming.
1 comment so far

Event handling has always confused me. So I’m going to summarise it all here.

//Handling mouse events
public boolean mouseDown (Event e, int x, int y)
{
//code here

    return true;

}

– what is an Actionlistener why is it needed?
– MouseListener? why is it needed

-actionPerformed? getSrc?

If there are several buttons, textfields, etc that need to be handled, use actionPerformed(ActionEvent e)
public void actionPerformed (ActionEvent event) {

String cmd = event.getActionCommand ();

if ( cmd.equals (“A”)){
fPushACount++;
showStatus (event.getActionCommand () +
” pushed ” + fPushACount + ” times”);
}else{
fPushBCount++;
showStatus (event.getActionCommand () +
” pushed ” + fPushBCount + ” times”);
}

} // actionPerformed()

Don’t forget to attach the listeners to the event source (ie buttons or else it wont work)!!

Redemption! December 6, 2006

Posted by deltawing in non-computing.
add a comment

Well, just got my results for Uni Semester 2 back today. The subject I was most nervous about was Data Structures and Algorithms (Software Development 3). I was relieved to see a “D” (Distinction) next to the subject title on the report paper. After plenty of heartache and frustration in the preceding subjects, Sofware Dev 2 and C++, I’ve finally gotten over a huge hurdle! Confidence and persistency is a must have when it comes to programming … well, pretty much any profession!

I’m flying Singapore Airlines to Taiwan tomorrow for a 3 week holiday AWAY from computers, programming, the Internet and games and all that! :D. Finally there’s time to rest my eyes and mind, and just travel around without being attracted to a computer monitor like a fly to a lamp. But I am also excited about the the flight itself. I don’t remember a time that I wasn’t obsessed about airplanes! Though I realized much earlier that flying for a career was just not for me, that didn’t stop me from getting hours and hours of Flight Simulator time lol! More information on the trip to Taiwan later.

My academicly oriented holidays goals after I get back from Taiwan are:

  • Mod a browser based MMORPG in PHP. It’s going to be very simple, and most of the code will not be mine, but I will do a respectable amount of my own work 😉
  • Learn how to code a CMS (in PHP) and do it.
  • Make a crappy game in DirectX/C++.
  • That’s all. Shouldn’t take a long time at all.

Got to go for now.