Welcome to Dream.In.Code
Getting Java Help is Easy!

Join 86,258 Java Programmers. There are 2,030 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Java Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

Image Display Help

 
Reply to this topicStart new topic

Image Display Help, working with multiple images, with mouselisteners

Chopster
post 7 May, 2008 - 05:51 PM
Post #1


New D.I.C Head

*
Joined: 29 Mar, 2008
Posts: 30



Hello all,

First of all i would like to say i have googled my problem many times, i can only apologise if the solution is simple, and maybe it is if you know what your looking for, but i am however stuck.

My problem is this, i am working on a world clock in java. I have a big picture (displayed in a JLabel) which shows all the 24 different time zones, now what i want to happen is, add a mouselistener so that when the mouse cursor goes over a specific time zone an new image is shown (one thats exactly the same size as that time zone, only darker).

Now i have the big picture,and the 24 other darker pictures, and there all added and i know they there, but my problem lies in getting them to appear over the big image, the mouselistener wont pick up the smaller images sitting behind the big image, so what can i do?

I tried making the smaller darker images transparent using the setOpague code, but that didn't work, using setVisible, but that did work, but again the mouselistener wont pick it up.

to be a little clearer i was writing code like this

CODE
public void mouseEntered(MouseEvent e){
        if(e.getComponent()==p1)
            p1.setVisible(true);


but the mouselistener wont pick up the JLabel p1, as it's sitting behind the big image.

what i think is the easiest option is if i can get the whole image transparent, so that the mouselistener will pick it up, but you wont actually see it there, until i want it to be there.

god i really hope that all makes sense and you can see my dilema, please be kind, i am trying to learn.

ask if you need more info, or more code to all my program

Thanks in advance
Jason
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


pbl
post 7 May, 2008 - 06:21 PM
Post #2


D.I.C Addict

Group Icon
Joined: 6 Mar, 2008
Posts: 843

QUOTE(Chopster @ 7 May, 2008 - 05:51 PM) *

what i think is the easiest option is if i can get the whole image transparent, so that the mouselistener will pick it up, but you wont actually see it there, until i want it to be there.

transparent or not if the JLabel is under it, the mouseListener will not react... bad design
sorry
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Chopster
post 7 May, 2008 - 07:00 PM
Post #3


New D.I.C Head

*
Joined: 29 Mar, 2008
Posts: 30

Ok, obviously i meant adding the JLabels over the top of the big JLabel, THEN making them transparent, would that allow the mouselistener to pick them up?

and please if i am completly wrong about the whole thing still, which is entirely possible as i am only learning, i have not been doing it long could you be a little more specific as to why its a bad design, i did mention i was completly stuck.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

pbl
post 7 May, 2008 - 07:34 PM
Post #4


D.I.C Addict

Group Icon
Joined: 6 Mar, 2008
Posts: 843

QUOTE(Chopster @ 7 May, 2008 - 07:00 PM) *

Ok, obviously i meant adding the JLabels over the top of the big JLabel, THEN making them transparent, would that allow the mouselistener to pick them up?

and please if i am completly wrong about the whole thing still, which is entirely possible as i am only learning, i have not been doing it long could you be a little more specific as to why its a bad design, i did mention i was completly stuck.

Sorry didn't want to insult you or to be rude with you... just wanted to give you a response ASAP
The fact that a component is visible because the one over it is +/- visible does not mean that this component will react to mouse or keyboard event. It is the component in the top off all the other ones (even if visible at 1%) that will react.
The GUI does not have the concept that "mouse is over X but Y is visible under iy so if user click both must react"

Without your code difficult to give you more advanced guideline.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Chopster
post 8 May, 2008 - 03:23 AM
Post #5


New D.I.C Head

*
Joined: 29 Mar, 2008
Posts: 30

No problem, thanks for the detailed answer, i understand the concept now, i've just had an idea..i'll post back if i got it to work.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/16/08 09:48AM

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month