I would like to show an image as a tooltip. It works OK but at some random points it shows fluctuation. I want to show it normally without getting fluctuate.
I show a new scene (in which i added my image-view with image) on mouse enter event and close it on mouse leave event event
// MOUSE ENTER PHOTO CORRECTIO
@FXML
private void mouseEnterPhotoCorrection(MouseEvent event) {
if (f_ShowToolTip) {
Stage stg = funShowImageTooltip();
double x, y;
x = event.getScreenX();
y = event.getScreenY();
stg.setX(x);
stg.setY(y);
stg.show();
f_ShowToolTip = false;
}
}
// MOUSE LEAVE PHOTO CORRECTIO
@FXML
private void mouseLeavePhotoCorrection(MouseEvent event) {
funHideImageTooltip();
f_ShowToolTip = true;
}
/****************************** FUNCTIONS *******************************/
Stage s;
boolean f_ShowToolTip;
// FUNCTION TO SET INITAL STATE OF PHOTOS AND CORRECTION
private void funInitPhotosCorrection()
{
f_ShowToolTip = true;
}
private Stage funShowImageTooltip()
{
try {
s = new Stage();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("frmImageToolTip.fxml"));
Parent root = (Parent) fxmlLoader.load();
Scene scene = new Scene(root);
s.setScene(scene);
s.setResizable(false);
s.initModality(Modality.WINDOW_MODAL);
s.initStyle(StageStyle.UNDECORATED);
s.setResizable(false);
double x, y;
//x = btn_Red.
s.show();
}catch(Exception e1)
{
}
return s;
}
private void funHideImageTooltip()
{
try {
s.close();
} catch (Exception e) {
}
}