Hey, I am trying to make a little MDI control with tabs, but my problems lies in the following:
I want it so that when the mouse is over a tab, a close button i.e. an X is displayed on the tab, then the user may click this button to close the corresponding tab. I have managed to get everything going except that when the mouseover event handler has been reached, the close button is displayed but when i try to move over the close button, the mouseexit event is triggered which then makes the close button invisible again. I want it so that when the mouse is over the tab the close button becomes visible and then the mouse can move over the still visible close button so it can be clicked.
I would like to keep it as simple as possible and only go into using the mouse coordinates and the coordinates of controls etc to do this is absolutely necessary. Below is a snippet of my current code:
Thanks in advance,
Jonathon.
// This code is part of the tab class i.e. "this" is referring to the tab itself, and closeButton is a JButton that is added to the tab.
public void mouseEntered(MouseEvent e)
{
if ( e.getSource() == this.closeButton || e.getSource() == this )
{
this.closeButton.setVisible( true );
}
}
public void mouseExited(MouseEvent e)
{
System.out.println(e.getComponent());
this.closeButton.setVisible( false );
}