I am new to Java Swing, I have created a JFrame which should get displayed when there is mouse focused over it and should be hidden when the mouse is not over it. Should i add a window listener for it.
ajacintha
0
Newbie Poster
Recommended Answers
Jump to PostYou can use a MouseListener to run your code when the mouse enters or leaves the frame, but I'm not sure whether that will work when the frame is hidden - you may need to have a transparent <something> in the place of the frame when it's hidden so that …
Jump to PostI would most likely use a JPanel for such a functionality.
I would set up a method to fill and one to empty and call them from the mouseEntered() and mouseExited() calls like
private JPanel myPanel(); private void fillMyPanel(){ //add stuff here myPanel.add(...); } private void …
Jump to PostIm sorry I missunderstood what you wanted to do.
Im pretty sure it's impossible to get mouse events for anything that was setVisible to false.
All 10 Replies
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Philippe.Lahaie
42
Posting Whiz in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
ajacintha
0
Newbie Poster
ajacintha
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Philippe.Lahaie
42
Posting Whiz in Training
ajacintha
0
Newbie Poster
ajacintha
0
Newbie Poster
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.