use of javafx.scene.control.Label in project JFoenix by jfoenixadmin.
the class ToolBarDemo method start.
@Override
public void start(Stage primaryStage) throws Exception {
try {
JFXToolbar jfxToolbar = new JFXToolbar();
jfxToolbar.setLeftItems(new Label("Left"));
jfxToolbar.setRightItems(new Label("Right"));
StackPane main = new StackPane();
main.getChildren().add(jfxToolbar);
Scene scene = new Scene(main, 600, 400);
scene.getStylesheets().add(ToolBarDemo.class.getResource("/resources/css/jfoenix-components.css").toExternalForm());
primaryStage.setScene(scene);
primaryStage.show();
} catch (Exception e) {
e.printStackTrace();
}
}
use of javafx.scene.control.Label in project JFoenix by jfoenixadmin.
the class JFXBadge method refreshBadge.
public void refreshBadge() {
badge.getChildren().clear();
if (enabled) {
// final double scaledWidth = control.getLayoutBounds().getWidth() / getBadgeScale().doubleValue();
// final double scaledHeight = control.getLayoutBounds().getHeight() / getBadgeScale().doubleValue();
// Shape background = new Rectangle(scaledWidth, scaledHeight);
// Shape clip = new Rectangle(scaledWidth, scaledHeight);
//
// if (maskType.get().equals(JFXBadge.BadgeMask.CIRCLE)) {
// double radius = Math.min(scaledWidth / 2, scaledHeight / 2);
// background = new Circle(radius);
// clip = new Circle(radius);
// }
//
//
// if (badgeFill.get() instanceof Color) {
// Color circleColor = new Color(((Color) badgeFill.get()).getRed(), ((Color) badgeFill.get()).getGreen(),
// ((Color) badgeFill.get()).getBlue(), ((Color) badgeFill.get()).getOpacity());
// background.setStroke(circleColor);
// background.setFill(circleColor);
// } else {
// background.setStroke(badgeFill.get());
// background.setFill(badgeFill.get());
// }
Label labelControl = new Label(text.getValue());
StackPane badgePane = new StackPane();
// badgePane.getChildren().add(background);
badgePane.getStyleClass().add("badge-pane");
badgePane.getChildren().add(labelControl);
//Adding a clip would avoid overlap but this does not work as intended
//badgePane.setClip(clip);
badge.getChildren().add(badgePane);
StackPane.setAlignment(badge, getPosition());
FadeTransition ft = new FadeTransition(Duration.millis(666), badge);
ft.setFromValue(0);
ft.setToValue(1.0);
ft.setCycleCount(1);
ft.setAutoReverse(true);
ft.play();
}
}
use of javafx.scene.control.Label in project JFoenix by jfoenixadmin.
the class ComboBoxDemo method start.
@Override
public void start(Stage primaryStage) throws Exception {
JFXComboBox<Label> c = new JFXComboBox<>();
c.getItems().add(new Label("Java 1.8"));
c.getItems().add(new Label("Java 1.7"));
c.getItems().add(new Label("Java 1.6"));
c.getItems().add(new Label("Java 1.5"));
c.setEditable(true);
c.setPromptText("Select Java Version");
HBox pane = new HBox(100);
HBox.setMargin(c, new Insets(20));
pane.setStyle("-fx-background-color:WHITE");
pane.getChildren().add(c);
final Scene scene = new Scene(pane, 300, 300);
scene.getStylesheets().add(ComboBoxDemo.class.getResource("/resources/css/jfoenix-components.css").toExternalForm());
primaryStage.setTitle("JFX ComboBox Demo");
primaryStage.setScene(scene);
primaryStage.setResizable(false);
primaryStage.show();
}
use of javafx.scene.control.Label in project mastering-java by Kingminghuang.
the class FlashText method start.
@Override
public void start(Stage primaryStage) throws Exception {
StackPane stackPane = new StackPane();
Label label = new Label("Talk is cheap, show me the code");
label.setStyle("-fx-font-size: 20");
label.setStyle("-fx-color: blue");
stackPane.getChildren().add(label);
new Thread(() -> {
try {
while (true) {
if (label.getText().trim().length() == 0) {
text = "Welcome";
} else {
text = "";
}
Platform.runLater(() -> label.setText(text));
Thread.sleep(200);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
}).start();
Scene scene = new Scene(stackPane, 200, 100);
primaryStage.setTitle("Flash Text");
primaryStage.setScene(scene);
primaryStage.show();
}
use of javafx.scene.control.Label in project DistributedFractalNetwork by Budder21.
the class NetworkCreationTool method getParams.
private Pair<Double, Double> getParams() {
Dialog<Pair<String, String>> dialog3 = new Dialog<>();
dialog3.setTitle("Create Network");
dialog3.setHeaderText("Step 3");
dialog3.setContentText("Choose Parameters:");
dialog3.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
GridPane grid = new GridPane();
grid.setHgap(10);
grid.setVgap(10);
grid.setPadding(new Insets(20, 150, 10, 10));
TextField zoomField = new TextField(".25");
TextField zoomSpeedField = new TextField("1.1");
grid.add(new Label("Zoom Level:"), 0, 0);
grid.add(zoomField, 1, 0);
grid.add(new Label("Zoom Speed:"), 0, 1);
grid.add(zoomSpeedField, 1, 1);
dialog3.getDialogPane().setContent(grid);
dialog3.setResultConverter(dialogButton -> {
if (dialogButton == ButtonType.OK)
return new Pair<String, String>(zoomField.getText(), zoomSpeedField.getText());
return null;
});
Optional<Pair<String, String>> result = dialog3.showAndWait();
// Traditional way to get the response value.
Double speed = null;
try {
speed = Double.valueOf(result.get().getValue());
} catch (NumberFormatException e) {
AlertMenu aMenu = new AlertMenu("INVALID INPUT: Zoom speed must be a real number.", "Please try again.");
return getParams();
} catch (Exception e) {
return null;
}
if (speed <= 0) {
AlertMenu aMenu = new AlertMenu("INVALID INPUT: Zoom speed must be greater than 0.", "Please try again");
return getParams();
}
Double zoom = null;
try {
zoom = Double.valueOf(result.get().getKey());
} catch (NumberFormatException e) {
AlertMenu aMenu = new AlertMenu("INVALID INPUT: Zoom level must be a real number.", "Please try again.");
return getParams();
} catch (Exception e) {
return null;
}
if (zoom <= 0) {
AlertMenu aMenu = new AlertMenu("INVALID INPUT: Zoom level must be greater than 0.", "Please try again");
return getParams();
}
return new Pair<Double, Double>(zoom, speed);
}
Aggregations