hello, i seem to be having some trouble here. I am writing a little class that is a popupSlider widget. The class extends JLabel so the user would treat this component like a label. When the label is left clicked on a jpopupMenu with a slider in it appears. This works all well and good except the second i click on the slider, i still have control of the slider (i can drag it up and down), the popup menu then disappears behind the rest of the window. I'm thinking i am missing something when processing the click event or the release events.
(yea there is probably some ugly code here, but it is in development, i want to get the thing working then clean up the code.)
couple things to note:
'popup' is a JPopupMenu object with a JSlider simply 'add()'ed to it
public void mouseClicked(MouseEvent e)
{
System.out.println("clicked " + e.getSource().getClass() );
if(e.getButton() == MouseEvent.BUTTON1)
{
Point pos = getMousePosition();
pos.x += getLocationOnScreen().x;
pos.y += getLocationOnScreen().y;
popup.setLocation(pos);
popup.setVisible(true);
}
}
public void mouseReleased(MouseEvent e)
{
System.out.println("released " + e.getSource().getClass() );
if( (e.getButton() == MouseEvent.BUTTON1) &&
(e.getSource().getClass() == JSlider.class) )
{
System.out.println("mouse released on slider");
popup.setVisible(false);
}
}
any help would be appreciated.
-Undertow