List of usage examples for javafx.scene.input MouseEvent MOUSE_EXITED
EventType MOUSE_EXITED
To view the source code for javafx.scene.input MouseEvent MOUSE_EXITED.
Click Source Link
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setWidth(300);//w w w. ja v a 2s . c om stage.setHeight(190); VBox vbox = new VBox(); vbox.setLayoutX(20); vbox.setLayoutY(20); final Button button1 = new Button("OK"); button1.addEventHandler(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { System.out.println("mouse entered"); } }); button1.addEventHandler(MouseEvent.MOUSE_EXITED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { System.out.println("mouse out"); } }); vbox.getChildren().add(button1); ((Group) scene.getRoot()).getChildren().add(vbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
@Override public void start(Stage stage) { Scene scene = new Scene(new Group()); stage.setTitle("Button Sample"); stage.setWidth(300);/*from w w w. j av a 2 s.c om*/ stage.setHeight(190); VBox vbox = new VBox(); vbox.setLayoutX(20); vbox.setLayoutY(20); final Button button1 = new Button("Accept"); button1.addEventHandler(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { button1.setEffect(shadow); } }); button1.addEventHandler(MouseEvent.MOUSE_EXITED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent e) { button1.setEffect(null); } }); vbox.getChildren().add(button1); vbox.setSpacing(10); ((Group) scene.getRoot()).getChildren().add(vbox); stage.setScene(scene); stage.show(); }
From source file:Main.java
public static java.awt.event.MouseEvent toAwt(final MouseEvent event) { final EventType type = event.getEventType(); if (null == type) { return null; }/*from w w w . j a va 2 s .co m*/ final int id; if (MouseEvent.MOUSE_MOVED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_MOVED; } else if (MouseEvent.MOUSE_DRAGGED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_DRAGGED; } else if (MouseEvent.MOUSE_CLICKED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_CLICKED; } else if (MouseEvent.MOUSE_PRESSED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_PRESSED; } else if (MouseEvent.MOUSE_RELEASED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_RELEASED; } else if (MouseEvent.MOUSE_ENTERED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_ENTERED; } else if (MouseEvent.MOUSE_EXITED.equals(type)) { id = java.awt.event.MouseEvent.MOUSE_EXITED; } else { return null; } final int button; if (event.isPrimaryButtonDown()) { button = java.awt.event.MouseEvent.BUTTON1; } else if (event.isMiddleButtonDown()) { button = java.awt.event.MouseEvent.BUTTON2; } else if (event.isSecondaryButtonDown()) { button = java.awt.event.MouseEvent.BUTTON3; } else { button = java.awt.event.MouseEvent.NOBUTTON; } final long when = -1; final int modifiers = modifiers(event); final int x = (int) event.getX(); final int y = (int) event.getY(); final int xAbs = Integer.MAX_VALUE; final int yAbs = Integer.MAX_VALUE; final int count = event.getClickCount(); boolean popup = event.isPopupTrigger(); if (MouseEvent.MOUSE_CLICKED.equals(type) && event.isMetaDown()) { // mack books use meta flag for right-clicks popup = true; } return new java.awt.event.MouseEvent(empty, id, when, modifiers, x, y, xAbs, yAbs, count, popup, button); }
From source file:com.panemu.tiwulfx.form.BaseControl.java
public BaseControl(String propertyName, E control) { this.inputControl = control; this.propertyName = propertyName; HBox.setHgrow(control, Priority.ALWAYS); setAlignment(Pos.CENTER_LEFT);/*w ww .java 2s.c om*/ control.setMaxWidth(Double.MAX_VALUE); control.setMinHeight(USE_PREF_SIZE); getChildren().add(control); getChildren().add(imagePlaceHolder); required.addListener(imageListener); valid.addListener(imageListener); this.getStyleClass().add("form-control"); value = new SimpleObjectProperty<>(); bindValuePropertyWithControl(control); bindEditablePropertyWithControl(control); addEventHandler(MouseEvent.ANY, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getEventType() == MouseEvent.MOUSE_MOVED && !isValid() && !getPopup().isShowing()) { Point2D p = BaseControl.this.localToScene(0.0, 0.0); getPopup().show(BaseControl.this, p.getX() + getScene().getX() + getScene().getWindow().getX(), p.getY() + getScene().getY() + getScene().getWindow().getY() + getInputComponent().getHeight() - 1); } else if (event.getEventType() == MouseEvent.MOUSE_EXITED && getPopup().isShowing()) { getPopup().hide(); } } }); getInputComponent().addEventHandler(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (!isValid() && getPopup().isShowing()) { getPopup().hide(); } } }); }
From source file:com.panemu.tiwulfx.form.BaseListControl.java
public BaseListControl(String propertyName, E control) { this.inputControl = control; this.propertyName = propertyName; HBox.setHgrow(control, Priority.ALWAYS); setAlignment(Pos.CENTER_LEFT);/*from w w w . j a v a 2 s .c om*/ control.setMaxWidth(Double.MAX_VALUE); control.setMinHeight(USE_PREF_SIZE); getChildren().add(control); getChildren().add(imagePlaceHolder); required.addListener(imageListener); valid.addListener(imageListener); this.getStyleClass().add("form-control"); value = new SimpleListProperty<>(); bindValuePropertyWithControl(control); bindEditablePropertyWithControl(control); addEventHandler(MouseEvent.ANY, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent event) { if (event.getEventType() == MouseEvent.MOUSE_MOVED && !isValid() && !getPopup().isShowing()) { Point2D p = BaseListControl.this.localToScene(0.0, 0.0); getPopup().show(BaseListControl.this, p.getX() + getScene().getX() + getScene().getWindow().getX(), p.getY() + getScene().getY() + getScene().getWindow().getY() + getInputComponent().getHeight() - 1); } else if (event.getEventType() == MouseEvent.MOUSE_EXITED && getPopup().isShowing()) { getPopup().hide(); } } }); getInputComponent().addEventHandler(MouseEvent.MOUSE_ENTERED, new EventHandler<MouseEvent>() { @Override public void handle(MouseEvent t) { if (!isValid() && getPopup().isShowing()) { getPopup().hide(); } } }); }