Solved

Images in AWT

Posted on 2006-06-29
14
405 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +2
14 Comments
 
LVL 9

Expert Comment

by:riaancornelius
ID: 17008709
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
ID: 17008809
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
ID: 17008860
change the mouse cursor to hand
http://javaalmanac.com/egs/java.awt/SetCursor.html
0
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 

Author Comment

by:paramu83
ID: 17009296
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
ID: 17009326
you are correct
0
 
LVL 8

Expert Comment

by:colr__
ID: 17009754
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
ID: 17009827
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__
ID: 17009866
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
ID: 17015284
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
ID: 17362587
fine by me :)
0
 
LVL 8

Expert Comment

by:colr__
ID: 17362672
Me too ;-)
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
The viewer will learn how to implement Singleton Design Pattern in Java.

632 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