Solved

Images in AWT

Posted on 2006-06-29
14
401 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
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
Technology Partners: 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!

 

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

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!

Question has a verified solution.

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

Suggested Solutions

Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

733 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