This file contains 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
import javafx.application.Application; | |
import javafx.event.ActionEvent; | |
import javafx.event.EventHandler; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Button; | |
import javafx.scene.input.KeyCode; | |
import javafx.scene.input.KeyEvent; | |
import javafx.scene.layout.StackPane; | |
import javafx.stage.Stage; | |
public class TrackerClient extends Application { | |
@Override | |
public void start(Stage primaryStage) { | |
Button btn = new Button(); | |
btn.setText("Submit"); | |
StackPane root = new StackPane(); | |
root.getChildren().add(btn); | |
final Scene scene = new Scene(root, 300, 250); | |
primaryStage.setScene(scene); | |
primaryStage.show(); | |
scene.getStylesheets().add(getClass().getResource("style1.css").toExternalForm()); | |
primaryStage.addEventHandler(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() { | |
@Override | |
public void handle(KeyEvent keyEvent) { | |
if (keyEvent.getCode().equals(KeyCode.F5)) { | |
scene.getStylesheets().clear(); | |
scene.getStylesheets().add(getClass().getResource("style.css").toExternalForm()); | |
} else { | |
scene.getStylesheets().clear(); | |
scene.getStylesheets().add(getClass().getResource("style1.css").toExternalForm()); | |
} | |
} | |
}); | |
} | |
public static void main(String[] args) { | |
launch(args); | |
} | |
} | |
//style.css | |
.button{ | |
-fx-text-fill: rgb(49, 89, 23); | |
-fx-border-color: rgb(49, 89, 23); | |
-fx-border-radius: 5; | |
-fx-padding: 3 6 6 6; | |
} | |
//style1.css | |
.button{ | |
-fx-text-fill: rgb(149, 189, 123); | |
-fx-border-color: rgb(149, 189, 123); | |
-fx-border-radius: 7; | |
-fx-padding: 5 8 8 8; | |
} |