Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help fixing bug related to JButton-->Mouse Adaptor-->Mouse Entered and Exited  RSS feed

 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just run the following code and move the mouse next to the text of the button and you will see exactly what I am talking about. Anyway to prevent this continuous flash?

 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know... what do you expect to happen instead?

It looks to me like you have a design where when you mouse over a button, a form -- including that button -- disappears. And when you mouse away from the button, the form is supposed to reappear. Only problem is, how is the code supposed to tell when you mouse away from an invisible button? It's pretty clear to me that the code thinks that when the button disappears, you've moused away from it, and therefore it makes the form reappear right away. So that's why the flashing happens.

Problem is, the design doesn't quite make sense (because of what I described there). Can you describe what you actually wanted?
 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul Clapham wrote:I don't know... what do you expect to happen instead?

It looks to me like you have a design where when you mouse over a button, a form -- including that button -- disappears. And when you mouse away from the button, the form is supposed to reappear. Only problem is, how is the code supposed to tell when you mouse away from an invisible button? It's pretty clear to me that the code thinks that when the button disappears, you've moused away from it, and therefore it makes the form reappear right away. So that's why the flashing happens.

Problem is, the design doesn't quite make sense (because of what I described there). Can you describe what you actually wanted?


I see what you are saying....Im trying to make it where when I mouse over a JComponent that a list of buttons is shown for selection. I pretty much used an undecorated Jframe to hold the list of buttons in which is hiding the parent frame and button.....
 
Charles Sexton
Ranch Hand
Posts: 273
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

There are other design options for the interface I can do....this one I just wanted to really try.
 
Paul Clapham
Sheriff
Posts: 22374
42
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Charles Sexton wrote:Im trying to make it where when I mouse over a JComponent that a list of buttons is shown for selection. I pretty much used an undecorated Jframe to hold the list of buttons in which is hiding the parent frame and button.....


Okay, but making the whole application disappear seems like overkill to me. Here's what I would do: put the list of buttons into your application in a JPanel (with a suitable layout manager) from the very start, and make it not visible (i.e. call setVisible(false) on the JPanel). Then when you mouse over the component, just call setVisible(true) on the JPanel.

(Of course making that panel visible might cause the mouse-controller component to move as part of the redrawing, so you might still have a similar problem, so you should design your application's GUI so that doesn't happen.)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!