• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 168
  • Last Modified:

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?
0
thor918
Asked:
thor918
  • 6
  • 5
1 Solution
 
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
 
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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
 
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

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now