jdk 1.1.8 program skin/imagebuttons

Hi anyone have tips how to program
images that can start an event if they are clicked on?
it has to be with the old jdk 1.1.8.

and any good sources for skins made using jdk 1.1.8?
LVL 2
thor918Asked:
Who is Participating?
 
aozarovCommented:
You can do that programatically by checking the color of the black/white pixels image in the given x,y location and then based on that
decide if you want to react to the event (should work as long as they share the same dimensions).
0
 
petmagdyCommented:
0
 
aozarovCommented:
Special Edition Using Java 1.1 -> http://docs.rinet.ru/UJ11/
1.1 already supports the new event listeners model (which is used currently)
see chapters:
http://docs.rinet.ru/UJ11/ch28.htm (events)
http://docs.rinet.ru/UJ11/ch29.htm (components)
http://docs.rinet.ru/UJ11/ch31.htm (images)

look at: http://docs.rinet.ru/UJ11/ch31.htm (Listing 31.6Source Code for Grayer.java) of how to load and draw an image
then use the same logic to draw the image on a class which extends Canvas (in that example it was an applet).
then add to the Canvas a  MouseListener and on mouseClicked do your action.

MyCanvas  myCanvas = new MyCanvas(); // where MyCanvas extends Canvas on in its paint method draw the image.
myCanvas.addMouseListener(new MouseAdapter()
{
public void mouseClicked(MouseEvent event)
{
// Do your actin here
}
});
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
thor918Author Commented:
@ petmagdy the code there works greate.but I was looking for a non applet solution.

@aozarov I will have to look into this code
0
 
thor918Author Commented:
if I could get some examples where the images placed in a frame that would be greate
0
 
aozarovCommented:
The following link contains an example that can work even for java 1.0 which displays an image on a frame
and when the user click on the frame a pop up window shows up.
http://www.chinalinuxpub.com/doc/oreillybookself/java/awt/ch06_05.htm
Just replace the logic in "public boolean mouseDown (Event e, int x, int y)" to do what you want (instead of
poping up the window).
0
 
thor918Author Commented:
thanks I will try it out.
is there any code that will use a mask to make the x,y cordinate click area?
like have one
image that is fancy images that display self drawn buttons
and one that is black and white that is the mask to these buttons
0
 
aozarovCommented:
Not sure what you mean by using another image to mask.
If you know the coordinates of the clickable areas then you can consider only them in the mouse event callback.
0
 
thor918Author Commented:
yes but lets say that the button hotspot is formed as a round circel. how can I only react to x,y in that circel.
the easies way would be to have one image that is the layout
and one image that defines the hotspot areas with black pixels.
0
 
thor918Author Commented:
thanks.that make sence ;)
I found another one that has getcolor, that probably will work under 1.1.8

http://www.experts-exchange.com/Programming/Programming_Languages/Java/Q_20651840.html?query=getcolor+of+pixel&topics=86
0
 
thor918Author Commented:
works perfect using the code you gave me and the getpixel color code link I posted ;) only thing is that it is a little slow in the colorcheck. but that is no issu for me
0
 
aozarovCommented:
:-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.