javafx.geometry.Pos Java Examples

The following examples show how to use javafx.geometry.Pos. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: bisq   Author: bisq-network   File: AddressWithIconAndDirection.java    License: GNU Affero General Public License v3.0 8 votes vote down vote up
public AddressWithIconAndDirection(String text, String address, boolean received) {
    Label directionIcon = new Label();
    directionIcon.getStyleClass().add("icon");
    directionIcon.getStyleClass().add(received ? "received-funds-icon" : "sent-funds-icon");
    AwesomeDude.setIcon(directionIcon, received ? AwesomeIcon.SIGNIN : AwesomeIcon.SIGNOUT);
    if (received)
        directionIcon.setRotate(180);
    directionIcon.setMouseTransparent(true);

    setAlignment(Pos.CENTER_LEFT);
    Label label = new AutoTooltipLabel(text);
    label.setMouseTransparent(true);
    HBox.setMargin(directionIcon, new Insets(0, 3, 0, 0));
    HBox.setHgrow(label, Priority.ALWAYS);

    hyperlink = new ExternalHyperlink(address);
    HBox.setMargin(hyperlink, new Insets(0));
    HBox.setHgrow(hyperlink, Priority.SOMETIMES);
    // You need to set max width to Double.MAX_VALUE to make HBox.setHgrow working like expected!
    // also pref width needs to be not default (-1)
    hyperlink.setMaxWidth(Double.MAX_VALUE);
    hyperlink.setPrefWidth(0);

    getChildren().addAll(directionIcon, label, hyperlink);
}
 
Example #2
Source Project: pdfsam   Author: torakiki   File: SplitModule.java    License: GNU Affero General Public License v3.0 8 votes vote down vote up
private VBox settingPanel() {
    VBox pane = new VBox();
    pane.setAlignment(Pos.TOP_CENTER);

    TitledPane prefixTitled = Views.titledPane(DefaultI18nContext.getInstance().i18n("File names settings"),
            prefix);
    prefix.addMenuItemFor(Prefix.CURRENTPAGE);
    prefix.addMenuItemFor(Prefix.FILENUMBER);
    prefix.addMenuItemFor("[TOTAL_FILESNUMBER]");

    pane.getChildren().addAll(selectionPane,
            Views.titledPane(DefaultI18nContext.getInstance().i18n("Split settings"), splitOptions),
            Views.titledPane(DefaultI18nContext.getInstance().i18n("Output settings"), destinationPane),
            prefixTitled);
    return pane;
}
 
Example #3
Source Project: mars-sim   Author: mars-sim   File: ProgressIndicatorTest.java    License: GNU General Public License v3.0 6 votes vote down vote up
private Parent createRoot() {
	StackPane stackPane = new StackPane();

	BorderPane controlsPane = new BorderPane();
	controlsPane.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
	stackPane.getChildren().add(controlsPane);
	controlsPane.setCenter(new TableView<Void>());

	ProgressIndicator indicator = new ProgressIndicator();
	indicator.setMaxSize(120, 120);
	stackPane.getChildren().add(indicator);
	StackPane.setAlignment(indicator, Pos.BOTTOM_RIGHT);
	StackPane.setMargin(indicator, new Insets(20));

	return stackPane;
}
 
Example #4
Source Project: constellation   Author: constellation-app   File: AttributeList.java    License: Apache License 2.0 6 votes vote down vote up
public AttributeList(final ImportController importController, final RunPane runPane, final AttributeType attributeType) {
    this.runPane = runPane;

    this.importController = importController;
    this.attributeType = attributeType;
    attributeNodes = new HashMap<>();
    keys = new HashSet<>();

    setAlignment(Pos.CENTER);
    setMinSize(50, 100);
    setSpacing(1);
    setPadding(new Insets(2));
    setFillWidth(true);

    setAlignment(Pos.TOP_CENTER);
}
 
Example #5
Source Project: Learn-Java-12-Programming   Author: PacktPublishing   File: HelloWorld.java    License: MIT License 6 votes vote down vote up
public void start(Stage primaryStage) {
    try {
        Text txt = new Text("What a beautiful image!");

        FileInputStream input = new FileInputStream("src/main/resources/packt.png");
        Image image = new Image(input);
        ImageView iv = new ImageView(image);

        VBox vb = new VBox(txt, iv);
        vb.setSpacing(20);
        vb.setAlignment(Pos.CENTER);
        vb.setPadding(new Insets(10, 10, 10, 10));

        Scene scene = new Scene(vb, 300, 200);

        primaryStage.setScene(scene);
        primaryStage.setTitle("JavaFX with embedded image");
        primaryStage.onCloseRequestProperty()
                .setValue(e -> System.out.println("Bye! See you later!"));
        primaryStage.show();
    } catch (Exception ex){
        ex.printStackTrace();
    }
}
 
Example #6
Source Project: gluon-samples   Author: gluonhq   File: TrainingView.java    License: BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
public TrainingView() {

        label = new Label();

        Button button = new Button("train network model");
        button.setOnAction(e -> {
            Task task = train();
            button.disableProperty().bind(task.runningProperty());
        });
        series = new Series();
        series.setName("#iterations");
        Chart chart = createChart(series);

        VBox controls = new VBox(15.0, label, button, chart);
        controls.setAlignment(Pos.CENTER);

        setCenter(controls);
    }
 
Example #7
Source Project: medusademo   Author: HanSolo   File: PollenDashboard.java    License: Apache License 2.0 6 votes vote down vote up
private HBox getHBox(final String TEXT, final Gauge GAUGE) {
    Label label = new Label(TEXT);
    label.setPrefWidth(150);
    label.setFont(Font.font(26));
    label.setTextFill(MaterialDesign.GREY_800.get());
    label.setAlignment(Pos.CENTER_LEFT);
    label.setPadding(new Insets(0, 10, 0, 0));

    GAUGE.setBarBackgroundColor(Color.rgb(232, 231, 223));
    GAUGE.setAnimated(true);
    GAUGE.setAnimationDuration(1000);

    HBox hBox = new HBox(label, GAUGE);
    hBox.setSpacing(20);
    hBox.setAlignment(Pos.CENTER_LEFT);
    return hBox;
}
 
Example #8
Source Project: SmartCity-ParkingManagement   Author: TechnionYP5777   File: MessageBox.java    License: Apache License 2.0 6 votes vote down vote up
public void display(final String title, final String message) {
	window = new Stage();
	window.initModality(Modality.APPLICATION_MODAL);
	window.setTitle(title);
	window.setMinWidth(250);
	window.setMinHeight(100);
	window.getIcons().add(new Image(getClass().getResourceAsStream("Smart_parking_icon.png")));

	final Label label = new Label();
	label.setText(message);

	final VBox layout = new VBox();
	layout.getChildren().addAll(label);
	layout.setAlignment(Pos.CENTER);

	final Scene scene = new Scene(layout);
	scene.getStylesheets().add(getClass().getResource("mainStyle.css").toExternalForm());
	window.setScene(scene);
	window.showAndWait();

}
 
Example #9
Source Project: gef   Author: eclipse   File: DotHTMLLabelJavaFxNode.java    License: Eclipse Public License 2.0 6 votes vote down vote up
private void applyTableAlignAttributesOnTdPane(GridPane wrapper) {
	/*
	 * Graphviz documentation specifies for the ALIGN attribute on cells: If
	 * the cell does not contain text, then the contained image or table is
	 * centered.
	 *
	 * Further, by observation, unless the fixedsize attribute is set, in
	 * graphviz the inner table grows in both horizontal and vertical
	 * direction.
	 *
	 * TODO: revise these settings when the align attribute on table tags is
	 * implemented, as this may change some behaviour.
	 */
	GridPane.setHgrow(wrapper.getChildren().get(0), Priority.ALWAYS);
	GridPane.setVgrow(wrapper.getChildren().get(0), Priority.ALWAYS);
	wrapper.setAlignment(Pos.CENTER);
}
 
Example #10
Source Project: trex-stateless-gui   Author: cisco-system-traffic-generator   File: StatisticCellWithArrows.java    License: Apache License 2.0 6 votes vote down vote up
public StatisticCellWithArrows(double width, boolean odd, String unit) {
    this.unit = unit;
    setPrefSize(width, 22);
    setSpacing(5);
    setAlignment(Pos.CENTER_RIGHT);
    Platform.runLater(() -> {
        getStyleClass().add("statsTableColCell");
        if (odd) {
            getStyleClass().add("statsTableColCellOdd");
        }
    });
    imageView = new ImageView();
    getChildren().add(imageView);
    value = new Label();
    getChildren().add(value);
}
 
Example #11
Source Project: marathonv5   Author: jalian-systems   File: ColorPickerSample.java    License: Apache License 2.0 6 votes vote down vote up
public ColorPickerSample() {
    final ColorPicker colorPicker = new ColorPicker(Color.GRAY);
    ToolBar standardToolbar = ToolBarBuilder.create().items(colorPicker).build();

    final Text coloredText = new Text("Colors");
    Font font = new Font(53);
    coloredText.setFont(font);
    final Button coloredButton = new Button("Colored Control");
    Color c = colorPicker.getValue();
    coloredText.setFill(c);
    coloredButton.setStyle(createRGBString(c));

    colorPicker.setOnAction(new EventHandler() {

        public void handle(Event t) {
            Color newColor = colorPicker.getValue();
            coloredText.setFill(newColor);                          
            coloredButton.setStyle(createRGBString(newColor));
        }
    });

    VBox coloredObjectsVBox = VBoxBuilder.create().alignment(Pos.CENTER).spacing(20).children(coloredText, coloredButton).build();        
    VBox outerVBox = VBoxBuilder.create().alignment(Pos.CENTER).spacing(150).padding(new Insets(0, 0, 120, 0)).children(standardToolbar, coloredObjectsVBox).build();
    getChildren().add(outerVBox);
}
 
Example #12
Source Project: oim-fx   Author: oimchat   File: TrayDemo.java    License: MIT License 6 votes vote down vote up
@Override
public void start(final Stage stage) throws Exception {
	enableTray(stage);

	GridPane grid = new GridPane();
	grid.setAlignment(Pos.CENTER);
	grid.setHgap(20);
	grid.setVgap(20);
	grid.setGridLinesVisible(true);
	grid.setPadding(new Insets(25, 25, 25, 25));

	Button b1 = new Button("测试1");
	Button b2 = new Button("测试2");
	grid.add(b1, 0, 0);
	grid.add(b2, 1, 1);

	Scene scene = new Scene(grid, 800, 600);
	stage.setScene(scene);
	stage.setOnCloseRequest(new EventHandler<WindowEvent>() {

		@Override
		public void handle(WindowEvent arg0) {
			stage.hide();
		}
	});
}
 
Example #13
Source Project: arma-dialog-creator   Author: kayler-renslow   File: CanvasViewColorsPopup.java    License: MIT License 6 votes vote down vote up
public CanvasViewColorsPopup() {
	super(ArmaDialogCreator.getPrimaryStage(), new VBox(10), null, false, true, false);

	ResourceBundle bundle = Lang.ApplicationBundle();

	setTitle(bundle.getString("Popups.Colors.popup_title"));

	myStage.initStyle(StageStyle.UTILITY);
	setupColorPickers();
	myStage.setMinWidth(400);
	myRootElement.setPadding(new Insets(5, 5, 5, 5));
	myRootElement.setAlignment(Pos.TOP_LEFT);
	myRootElement.getChildren().addAll(
			colorOption(bundle.getString("Popups.Colors.selection"), cpSelection),
			colorOption(bundle.getString("Popups.Colors.abs_region"), cpAbsRegion),
			colorOption(bundle.getString("Popups.Colors.grid"), cpGrid),
			colorOption(bundle.getString("Popups.Colors.background"), cpEditorBg)
	);
}
 
Example #14
Source Project: ApkToolPlus   Author: linchaolong   File: Popup.java    License: Apache License 2.0 6 votes vote down vote up
private Popup() {
    super();
    // 设置背景颜色
    setBackgroundColor(20,20,20,0.5f);
    contentBox = new VBox();

    // 间隔
    Region topRegion = new Region();
    topRegion.setPrefHeight(30);
    contentBox.getChildren().add(topRegion);

    // 提示信息
    text = new Text();
    text.setStyle("-fx-fill: white; -fx-font-size:24;-fx-font-family: \"Microsoft YaHei\";-fx-text-alignment: CENTER;");
    contentBox.getChildren().add(text);

    // 设置内容居中
    contentBox.alignmentProperty().set(Pos.CENTER);
    // 设置布局居中
    setAlignment(contentBox,Pos.CENTER);
    getChildren().add(contentBox);
}
 
Example #15
Source Project: chart-fx   Author: GSI-CS-CO   File: RunUiSamples.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void start(final Stage primaryStage) {
    final BorderPane root = new BorderPane();

    final FlowPane buttons = new FlowPane();
    buttons.setAlignment(Pos.CENTER_LEFT);
    root.setCenter(buttons);
    root.setBottom(makeScreenShot);

    buttons.getChildren().add(new MyButton("AcqButtonTests", new AcqButtonTests()));

    final Scene scene = new Scene(root);

    primaryStage.setTitle(this.getClass().getSimpleName());
    primaryStage.setScene(scene);
    primaryStage.setOnCloseRequest(evt -> System.exit(0));
    primaryStage.show();
}
 
Example #16
Source Project: milkman   Author: warmuuh   File: JfxTableEditor.java    License: MIT License 6 votes vote down vote up
public JfxTableEditor() {
	table.setShowRoot(false);
	table.setEditable(true);
	table.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);

	JavaFxUtils.publishEscToParent(table);
	this.getChildren().add(table);
	addItemBtn = new JFXButton();
	addItemBtn.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
	addItemBtn.setGraphic(new FontAwesomeIconView(FontAwesomeIcon.PLUS, "1.5em"));
	addItemBtn.getStyleClass().add("btn-add-entry");
	StackPane.setAlignment(addItemBtn, Pos.BOTTOM_RIGHT);
	StackPane.setMargin(addItemBtn, new Insets(0, 20, 20, 0));
	this.getChildren().add(addItemBtn);

	final KeyCombination keyCodeCopy = PlatformUtil.getControlKeyCombination(KeyCode.C);
	final KeyCombination keyCodePaste = PlatformUtil.getControlKeyCombination(KeyCode.V);
    table.setOnKeyPressed(event -> {
        if (keyCodeCopy.match(event)) {
            copySelectionToClipboard();
        }
        if (keyCodePaste.match(event)) {
        	pasteSelectionFromClipboard();
        }
    });
}
 
Example #17
Source Project: tools-ocr   Author: AnyListen   File: ProcessController.java    License: GNU Lesser General Public License v3.0 6 votes vote down vote up
public ProcessController(){
    VBox vBox = new VBox();
    vBox.setAlignment(Pos.BASELINE_CENTER);
    vBox.setMinWidth(300);
    vBox.setBackground(new Background(new BackgroundFill(Color.rgb(250, 250, 250), CornerRadii.EMPTY, Insets.EMPTY)));
    ProgressIndicator progressIndicator = new ProgressIndicator();
    progressIndicator.setStyle(CommUtils.STYLE_TRANSPARENT);
    int circleSize = 75;
    progressIndicator.setMinWidth(circleSize);
    progressIndicator.setMinHeight(circleSize);
    Label topLab = new Label("正在识别图片,请稍等.....");
    topLab.setFont(Font.font(18));
    vBox.setSpacing(10);
    vBox.setPadding(new Insets(20, 0, 20, 0));
    vBox.getChildren().add(progressIndicator);
    vBox.getChildren().add(topLab);
    Scene scene = new Scene(vBox, Color.TRANSPARENT);
    setScene(scene);
    initStyle(StageStyle.TRANSPARENT);
    CommUtils.initStage(this);
}
 
Example #18
Source Project: RichTextFX   Author: FXMisc   File: LineNumberFactory.java    License: BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public Node apply(int idx) {
    Val<String> formatted = nParagraphs.map(n -> format(idx+1, n));

    Label lineNo = new Label();
    lineNo.setFont(DEFAULT_FONT);
    lineNo.setBackground(DEFAULT_BACKGROUND);
    lineNo.setTextFill(DEFAULT_TEXT_FILL);
    lineNo.setPadding(DEFAULT_INSETS);
    lineNo.setAlignment(Pos.TOP_RIGHT);
    lineNo.getStyleClass().add("lineno");

    // bind label's text to a Val that stops observing area's paragraphs
    // when lineNo is removed from scene
    lineNo.textProperty().bind(formatted.conditionOnShowing(lineNo));

    return lineNo;
}
 
Example #19
Source Project: pdfsam   Author: torakiki   File: RotateModule.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
private VBox settingPanel() {
    VBox pane = new VBox();
    pane.setAlignment(Pos.TOP_CENTER);
    VBox.setVgrow(selectionPane, Priority.ALWAYS);

    TitledPane prefixTitled = Views.titledPane(DefaultI18nContext.getInstance().i18n("File names settings"),
            prefix);
    prefix.addMenuItemFor(Prefix.FILENUMBER);
    prefix.addMenuItemFor("[TOTAL_FILESNUMBER]");

    TitledPane options = Views.titledPane(DefaultI18nContext.getInstance().i18n("Rotate settings"), rotateOptions);

    pane.getChildren().addAll(selectionPane, options,
            Views.titledPane(DefaultI18nContext.getInstance().i18n("Output settings"), destinationPane),
            prefixTitled);
    return pane;
}
 
Example #20
Source Project: ChatRoom-JavaFX   Author: Laity000   File: ChatController.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 处理通知信息的显示
 * @param notice
 */
public void addNotification(String notice){
	Platform.runLater(() ->{
		SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");//设置日期格式
		String timer = df.format(new Date());// new Date()为获取当前系统时间
		String content = timer +  ": " + notice;
		BubbledTextFlow noticeBubbled = new BubbledTextFlow(EmojiDisplayer.createEmojiAndTextNode(content));
		//noticeBubbled.setTextFill(Color.web("#031c30"));
		noticeBubbled.setBackground(new Background(new BackgroundFill(Color.WHITE,
                   null, null)));
           HBox x = new HBox();
           //x.setMaxWidth(chatPaneListView.getWidth() - 20);
           x.setAlignment(Pos.TOP_CENTER);
           noticeBubbled.setBubbleSpec(BubbleSpec.FACE_TOP);
           x.getChildren().addAll(noticeBubbled);
           chatPaneListView.getItems().add(x);
	});
}
 
Example #21
Source Project: fx2048   Author: brunoborges   File: Board.java    License: GNU General Public License v3.0 6 votes vote down vote up
private void createToolBar() {
    // toolbar
    var hPadding = new HBox();
    hPadding.setMinSize(gridWidth, TOOLBAR_HEIGHT);
    hPadding.setPrefSize(gridWidth, TOOLBAR_HEIGHT);
    hPadding.setMaxSize(gridWidth, TOOLBAR_HEIGHT);

    hToolbar.setAlignment(Pos.CENTER);
    hToolbar.getStyleClass().add("game-backGrid");
    hToolbar.setMinSize(gridWidth, TOOLBAR_HEIGHT);
    hToolbar.setPrefSize(gridWidth, TOOLBAR_HEIGHT);
    hToolbar.setMaxSize(gridWidth, TOOLBAR_HEIGHT);

    vGame.getChildren().add(hPadding);
    vGame.getChildren().add(hToolbar);
}
 
Example #22
Source Project: milkman   Author: warmuuh   File: ManageEnvironmentsDialog.java    License: MIT License 6 votes vote down vote up
public ManageEnvironmentsDialogFxml(ManageEnvironmentsDialog controller){

			setHeading(label("Manage Environments"));

			StackPane stackPane = new StackPane();
			var list = controller.environmentList = new JFXListView<>();
			list.setVerticalGap(10.0);
			list.setMinHeight(400);
			stackPane.getChildren().add(list);

			var btn = button(icon(FontAwesomeIcon.PLUS, "1.5em"), controller::onCreateEnvironment);
			btn.getStyleClass().add("btn-add-entry");
			StackPane.setAlignment(btn, Pos.BOTTOM_RIGHT);
			stackPane.getChildren().add(btn);

			setBody(stackPane);

			JFXButton close = cancel(controller::onClose, "Close");
			close.getStyleClass().add("dialog-accept");
			setActions(close);

		}
 
Example #23
Source Project: pdfsam   Author: torakiki   File: Notification.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
Notification(String title, Node content) {
    requireNotNullArg(content, "Notification content cannot be blank");
    getStyleClass().add("notification");
    getStyleClass().addAll(Style.CONTAINER.css());
    setId(UUID.randomUUID().toString());
    Button closeButton = FontAwesomeIconFactory.get().createIconButton(FontAwesomeIcon.TIMES);
    closeButton.getStyleClass().addAll("close-button");
    closeButton.setOnAction(e -> eventStudio().broadcast(new RemoveNotificationRequestEvent(getId())));
    Label titleLabel = new Label(title);
    titleLabel.setPrefWidth(Integer.MAX_VALUE);
    titleLabel.getStyleClass().add("notification-title");
    StackPane top = new StackPane(titleLabel, closeButton);
    top.setAlignment(Pos.TOP_RIGHT);
    getChildren().addAll(top, content);
    setOpacity(0);
    setOnMouseEntered(e -> {
        fade.stop();
        setOpacity(1);
    });
    setOnMouseClicked(e -> {
        setOnMouseEntered(null);
        setOnMouseExited(null);
        fade.stop();
        eventStudio().broadcast(new RemoveNotificationRequestEvent(getId()));
    });
    fade.setFromValue(1);
    fade.setToValue(0);
}
 
Example #24
Source Project: marathonv5   Author: jalian-systems   File: CursorSample.java    License: Apache License 2.0 5 votes vote down vote up
private Node createBox(Cursor cursor) {
    Label label = new Label(cursor.toString());
    label.setAlignment(Pos.CENTER);
    label.setPrefSize(85, 85);
    label.setStyle("-fx-border-color: #aaaaaa; -fx-background-color: #dddddd;");
    label.setCursor(cursor);
    return label;
}
 
Example #25
Source Project: Java-9-Cookbook   Author: PacktPublishing   File: BarChartDemo.java    License: MIT License 5 votes vote down vote up
@Override
public void start(Stage stage) throws IOException {

	GridPane gridPane = new GridPane();
	gridPane.setAlignment(Pos.CENTER);
	gridPane.setHgap(10);
	gridPane.setVgap(10);
	gridPane.setPadding(new Insets(25, 25, 25, 25));

	StudentDataProcessor sdp = new StudentDataProcessor();
	List<Student> students = sdp.loadStudent();
	System.out.println("students : " + students.size());
	

	BarChart<String, Number> avgGradeByMotherEdu = 
		getAvgGradeByEducationBarChart(
			students, 
			Student::getMotherEducation
		);
	avgGradeByMotherEdu.setTitle("Average grade by Mother's Education");
	gridPane.add(avgGradeByMotherEdu, 1,1);

	BarChart<String, Number> avgGradeByFatherEdu = 
		getAvgGradeByEducationBarChart(
			students, 
			Student::getFatherEducation
		);
	avgGradeByFatherEdu.setTitle("Average grade by Father's Education");
	gridPane.add(avgGradeByFatherEdu, 2,1);

	Scene scene = new Scene(gridPane, 800, 600);
	stage.setTitle("Bar Charts");
	stage.setScene(scene);
	stage.show();
}
 
Example #26
Source Project: FXTutorials   Author: AlmasB   File: GameMenuDemo.java    License: MIT License 5 votes vote down vote up
public MenuButton(String name) {
    text = new Text(name);
    text.setFont(text.getFont().font(20));
    text.setFill(Color.WHITE);

    Rectangle bg = new Rectangle(250, 30);
    bg.setOpacity(0.6);
    bg.setFill(Color.BLACK);
    bg.setEffect(new GaussianBlur(3.5));

    setAlignment(Pos.CENTER_LEFT);
    setRotate(-0.5);
    getChildren().addAll(bg, text);

    setOnMouseEntered(event -> {
        bg.setTranslateX(10);
        text.setTranslateX(10);
        bg.setFill(Color.WHITE);
        text.setFill(Color.BLACK);
    });

    setOnMouseExited(event -> {
        bg.setTranslateX(0);
        text.setTranslateX(0);
        bg.setFill(Color.BLACK);
        text.setFill(Color.WHITE);
    });

    DropShadow drop = new DropShadow(50, Color.WHITE);
    drop.setInput(new Glow());

    setOnMousePressed(event -> setEffect(drop));
    setOnMouseReleased(event -> setEffect(null));
}
 
Example #27
Source Project: pdfsam   Author: torakiki   File: NotificationsController.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
private void addDonationNotification(long usages) {
    VBox content = new VBox(3,
            buildLabel(DefaultI18nContext.getInstance().i18n("You performed {0} tasks with PDFsam, did it help?",
                    Long.toString(usages)), NotificationType.GO_PRO),
            styledUrlButton(DefaultI18nContext.getInstance().i18n("Give something back"),
                    pdfsam.property(ConfigurableProperty.DONATE_URL), null));
    content.setAlignment(Pos.TOP_RIGHT);

    container.addStickyNotification(DefaultI18nContext.getInstance().i18n("PDFsam worked hard!"), content);
}
 
Example #28
Source Project: FXTutorials   Author: AlmasB   File: MKXMenuApp.java    License: MIT License 5 votes vote down vote up
public ContentFrame(Node content) {
    setAlignment(Pos.CENTER);

    Rectangle frame = new Rectangle(200, 200);
    frame.setArcWidth(25);
    frame.setArcHeight(25);
    frame.setStroke(Color.WHITESMOKE);

    getChildren().addAll(frame, content);
}
 
Example #29
Source Project: FXTutorials   Author: AlmasB   File: Alarm.java    License: MIT License 5 votes vote down vote up
public Alarm(LocalTime time) {
    this.time = time;

    getStyleClass().add("alarm");

    Text text = new Text(time.toString());
    text.getStyleClass().add("alarm_text");

    getChildren().add(text);
    setAlignment(Pos.CENTER_LEFT);
}
 
Example #30
Source Project: Enzo   Author: HanSolo   File: IconSwitchSkin.java    License: Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    Font.loadFont(getClass().getResourceAsStream("/eu/hansolo/enzo/fonts/opensans-semibold.ttf"), (0.5 * PREFERRED_HEIGHT)); // "OpenSans"
    font = Font.font("Open Sans", 0.5 * PREFERRED_HEIGHT);

    background = new Region();
    background.getStyleClass().setAll("background");
    background.setStyle("-switch-color: " + Util.colorToCss((Color) getSkinnable().getSwitchColor()) + ";");

    symbol = getSkinnable().getSymbol();
    symbol.setMouseTransparent(true);

    text = new Label(getSkinnable().getText());
    text.setTextAlignment(TextAlignment.CENTER);
    text.setAlignment(Pos.CENTER);
    text.setTextFill(getSkinnable().getSymbolColor());
    text.setFont(font);

    thumb = new Region();
    thumb.getStyleClass().setAll("thumb");
    thumb.setStyle("-thumb-color: " + Util.colorToCss((Color) getSkinnable().getThumbColor()) + ";");
    thumb.setMouseTransparent(true);

    pane = new Pane(background, symbol, text, thumb);
    pane.getStyleClass().setAll("icon-switch");

    moveToDeselected = new TranslateTransition(Duration.millis(180), thumb);
    moveToSelected = new TranslateTransition(Duration.millis(180), thumb);

    // Add all nodes
    getChildren().setAll(pane);
}