Computer Science 15-100, Spring 2009
JComponentWithEvents information
Current version=4
- JComponentWithEvents.class downloads:
- Current download:
JComponentWithEvents.class (v4)
Also available in a zip file:
JComponentWithEvents.zip (v4)
- EventsDemo
- EventsDemo.java
- EventsDemo.jar
- To create this jar file:
- Create "classes" directory
- Copy all necessary class files into classes directory
- Create manifest
- Must live in top-level of classes directory
- Delete any pre-existing manifest file!
- Case-sensitive, space-sensitive, and must end in a blank
line!
- Main-Class should be the class where your "main" method
resides
- Here is our manifest.txt
file (note that it ends with a blank line!)
Main-Class: EventsDemo
- Create the jar file
- Run command shell and cd to classes directory
- Run this command:
jar cvfm MyProgram.jar manifest.txt .
(Don't forget that trailing dot!)
You may have to specify the full path to your java
installation, something like this:
"C:\program files\Java\jdk1.5.0_12\bin\jar" cvfm
MyProgram.jar manifest.txt .
- EventsDemo.html (as an applet
using the jar file)!
- To create this html page:
- Create the jar file as above, but also include the file
JComponentWithEventsApplet.class
- Use this html to run the applet (changing "EventsDemo" to
your application's name in both places!):
<html>
<head>
<title>My Graphics Applet</title>
</head>
<body bgcolor="#BBBBBB">
Here is my graphics applet:
<hr>
<applet code="JComponentWithEventsApplet.class" archive="EventsDemo.jar" width="500" height="400" >
<param name="ComponentClass" value="EventsDemo">
</applet>
<hr>
And there was my graphics applet!
</body>
</html>
- Place the applet on a web server (note: the applet
can only access files on that same web server!)
- Previous downloads: v1,
v2,
v3
Change Log
- Planned for v5:
- javadoc documentation
- improved exception handling due to file + reflection security exceptions
in applet mode
- v4:
- kinder, gentler version checker (in background so app still runs
passably well with old version)
- non-final helper methods (getFileScanner, etc) (added on 20-Dec-09)
- getResourceAsStream +
resource-friendly image and sound loading
- loadBufferedImage (resource-friendly) and saveBufferedImage methods
- more key constants:
SPACE, BACK_SPACE, ENTER, ESCAPE, SHIFT,
CAPS_LOCK, CONTROL, ALT
- v3 (1-Oct-08)
- field modification check in paint
- v2 (27-Sep-08)
- version checking at "launch"
- more responsive timer
- event methods:
componentResized, keyReleased, keyTyped,
getMouseEvent, getKeyEvent
- key constants:
DELETE, HOME, PAGE_UP, PAGE_DOWN, END, F1, F2,
..., F12
- v1 (~15-Sep-08)
- adapted from CoStarsComponent w/numerous additions, revisions, and
some bug fixes
carpe diem -
carpe diem - carpe diem - carpe
diem - carpe diem - carpe diem
- carpe diem - carpe diem -
carpe diem