wood burning stoves*
The moose likes Beginning Java and the fly likes How do u use a Picture as a Button Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How do u use a Picture as a Button" Watch "How do u use a Picture as a Button" New topic
Author

How do u use a Picture as a Button

Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
Hi Guys

i need help as i am doing a locker system for a buliding.
so i have an idea to let the user to click on the different locker on one picture. Now i would like to ask for suggestion from anyone if i can like let the user click on different part of the picture to go to a different form.
example like using the picture as a link.
Btw i am using frame for the application's layout.

regards,


if (!WorkHard){
System.out.println("Fail!!!");
}
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
You can use an Image Map

<input type="image" name="lockers" src="%my image location%">

should generate a request with

target?lockers.y=##&lockers.x=###

You can then get that data in your serlvet and calc what locker x and y correspond to.
Koh Khai Huat
Ranch Hand

Joined: Aug 05, 2005
Posts: 100
hi do u have a sample code that i can ake a look at because i dun quite understand wat u mean thank you very much..

regards
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
http://www.phptr.com/articles/article.asp?p=26145&seqNum=9&rl=1
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19654
    
  18

Originally posted by Gerardo Tasistro:
You can use an Image Map

<input type="image" name="lockers" src="%my image location%">

should generate a request with

target?lockers.y=##&lockers.x=###

You can then get that data in your serlvet and calc what locker x and y correspond to.

This is a JAVA forum, not HTML.

Edit: hmm, just read about the servlet. But there was never a mention of a servlet here. Probably the topic starter has an applet or application.


If you create a JLabel with an ImageIcon, you can add a MouseListener. This can trigger events like mousePressed or mouseClicked, both of which give you a MouseEvent. This MouseEvent has getX(), getY() and getPoint() methods to give you where in the label you clicked.
If possible, prefer getX() and getY() to getPoint() - the latter creates a new object every time.
[ November 05, 2005: Message edited by: Rob Spoor ]

SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
Consider Paul's rocket mass heater.
 
subject: How do u use a Picture as a Button
 
Similar Threads
lock and unlock
get different picture for different user
rotating the picture clockwise
maximize and minimize panel
help reqired