Solved

Images in AWT

Posted on 2006-06-29
14
391 Views
Last Modified: 2013-12-29
Suppose i have an image in a Panel. On clicking the Image some event occurs . How can I make the Image appear clickable to the User like say projected out or any others.   meaning if the user sees the screen he should feel that the image is clickable.
I am using AWT only.
--------------------------------------------------------------------------------
0
Comment
Question by:paramu83
  • 4
  • 3
  • 2
  • +2
14 Comments
 
LVL 9

Expert Comment

by:riaancornelius
Comment Utility
Maybe put a raised etchedBorder on the Panel. That should make it look more like a button?
0
 
LVL 8

Accepted Solution

by:
colr__ earned 43 total points
Comment Utility
Or even better, a blue border similar to those hyperlinsk you see in your browser, with a rollover effet that changes the colour.

colr__
0
 
LVL 14

Assisted Solution

by:hoomanv
hoomanv earned 41 total points
Comment Utility
change the mouse cursor to hand
http://javaalmanac.com/egs/java.awt/SetCursor.html
0
 

Author Comment

by:paramu83
Comment Utility
I think etchedBorder is provided by swing . I am not using swing , just plain AWT .

Correct me if I am wrong.
0
 
LVL 14

Expert Comment

by:hoomanv
Comment Utility
you are correct
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 8

Expert Comment

by:colr__
Comment Utility
You could use a JEditorPane, with the contents being html with the image defiend as a link:

http://java.sun.com/docs/books/tutorial/uiswing/components/editorpane.html
0
 
LVL 14

Expert Comment

by:hoomanv
Comment Utility
the asker asserted no swing solution
paramu83, why do you not set the mouse cursor to hand ? like when you hover an html link
0
 
LVL 8

Expert Comment

by:colr__
Comment Utility
Sorry, I was working on an old version of this page. ;-(
0
 
LVL 10

Assisted Solution

by:mukundha_expert
mukundha_expert earned 41 total points
Comment Utility
One thing is you can give a border to that image,

put the image in the panel, set the background colour to blue or black,

in the paint method,
give  (Graphics) g.drawImage ( image, 2,2,width,height,this ) ;

you will get a border on the left and the top,

to get the border on the othersides, add component listener to this panel,

implement the componentResized() method,
in that  get the size of the panel and set the size of the image sightly less than the panel size.

0
 
LVL 9

Expert Comment

by:riaancornelius
Comment Utility
fine by me :)
0
 
LVL 8

Expert Comment

by:colr__
Comment Utility
Me too ;-)
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now