Created
November 20, 2018 20:54
-
-
Save tanandy/41527d120da19a7e9ff5daf919a1ed92 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package helloworld; | |
import javafx.application.Application; | |
import javafx.event.EventHandler; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Label; | |
import javafx.scene.input.MouseEvent; | |
import javafx.scene.layout.HBox; | |
import javafx.scene.layout.StackPane; | |
import javafx.scene.paint.Color; | |
import javafx.stage.Stage; | |
public class HelloWorld extends Application { | |
public class LabelLien extends Label { | |
LabelLien(String text){ | |
LabelLien lbl = this; | |
lbl.setText(text); | |
lbl.setOnMouseEntered(new EventHandler<MouseEvent>() { | |
@Override | |
public void handle(MouseEvent e) { | |
lbl.setTextFill(Color.rgb(210, 39, 30)); | |
} | |
}); | |
lbl.setOnMouseExited(new EventHandler<MouseEvent>() { | |
@Override | |
public void handle(MouseEvent e) { | |
lbl.setTextFill(Color.rgb(21, 117, 84)); | |
} | |
}); | |
} | |
} | |
public static void main(String[] args) { | |
launch(args); | |
} | |
@Override | |
public void start(Stage primaryStage) { | |
primaryStage.setTitle("Hello World!"); | |
HBox hbox = new HBox(); | |
final Label label1 = new LabelLien("Searchong long "); | |
hbox.getChildren().add((label1)); | |
StackPane root = new StackPane(); | |
hbox.setSpacing(10); | |
root.getChildren().add(hbox); | |
primaryStage.setScene(new Scene(root, 300, 250)); | |
primaryStage.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment