Java Code Examples for javafx.scene.layout.AnchorPane#setStyle()

The following examples show how to use javafx.scene.layout.AnchorPane#setStyle() . 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 File: StageTest.java    From CustomStage with Apache License 2.0 5 votes vote down vote up
@Override
    public void start(Stage primaryStage) throws Exception {
        AnchorPane nav = new AnchorPane();
        nav.setStyle("-fx-background-color: gold;");
        CustomStage stage = new CustomStageBuilder()
//                .setDimensions(0,0,1920,1280) // change values the minW,minH,maxW,maxH of the window
//                .setActionIcons(null,null,null,null) //change default icons for action buttons
//                .setIcon("/test/logo.png")
//                .setStyleSheet(new File("test/testCss.css").getAbsolutePath())
//                .setStyleSheet(StageTest.class.getResource("testCss.css"))
                .setWindowTitle("Custom Stage")
                .setTitleColor("yellow")
                .setWindowColor("rgb(34,54,122)")
                //Dynamic navigation pane on left-side of the window with 50px space left from top of the window
                .setNavigationPane(Style.DYNAMIC,NavigationType.LEFT,nav,50,0,false)
//                .setWindowColor("rgba(34,54,122,0.6)") //With transparency (hex value [with alpha] can also be used)
//                .setButtonColor("#FF56AA") // takes the window's color by default
                .setButtonHoverColor("yellow")
                .build();

        stage.show();

        stage.getScene().getRoot().setOnMouseClicked(e->stage.dynamicDrawerEvent(NavigationType.LEFT));

//        stage.changeScene(FXMLLoader.load(getClass().getResource("/test/Dashboard.fxml")));

    }
 
Example 2
Source File: StageTest.java    From CustomStage with Apache License 2.0 5 votes vote down vote up
@Override
    public void start(Stage primaryStage) throws Exception {
        AnchorPane nav = new AnchorPane();
        nav.setStyle("-fx-background-color: lightblue;");
        CustomStage stage = new CustomStageBuilder()
//                .setDimensions(0,0,1920,1280) // change values the minW,minH,maxW,maxH of the window
//                .setActionIcons(null,null,null,null) //change default icons for action buttons

                .setIcon("/v1_2_2/Logo.png")
                .setStyleSheet(StageTest.class.getResource("testCss.css"))
//                .setWindowTitle("Normal Window Title")

                //Give positioning to title and buttons
                .setWindowTitle("Custom Stage Positions",HorizontalPos.LEFT,HorizontalPos.CENTER)

                .setTitleColor("yellow")
                .setWindowColor("rgb(34,54,122)")
                //Dynamic navigation pane on left-side of the window with 50px space left from top of the window
                .setNavigationPane(Style.DYNAMIC,NavigationType.LEFT,nav,50,0,false)
//                .setWindowColor("rgba(34,54,122,0.6)") //With transparency (hex value [with alpha] can also be used)
//                .setButtonColor("#FF56AA") // takes the window's color by default

                //Giver different colors for close,maximize,minimize buttons on hover state
                .setButtonHoverColor("gold","green","red")

                .build();

        stage.show();

        stage.getScene().getRoot().setOnMouseClicked(e->stage.dynamicDrawerEvent(NavigationType.LEFT));

//        stage.changeScene(FXMLLoader.load(getClass().getResource("/test/Dashboard.fxml")));

    }
 
Example 3
Source File: NetProtocolSettingFrame.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.setWidth(520);
	this.setHeight(120);
	this.setResizable(false);
	this.setTitlePaneStyle(2);
	this.setRadius(5);
	this.setCenter(rootPane);
	this.setTitle("服务器地址设置");

	titleLabel.setText("服务器地址设置");
	titleLabel.setFont(Font.font("微软雅黑", 14));
	titleLabel.setStyle("-fx-text-fill:rgba(255, 255, 255, 1)");

	topBox.setStyle("-fx-background-color:#2cb1e0");
	topBox.setPrefHeight(35);
	topBox.setPadding(new Insets(5, 10, 5, 10));
	topBox.setSpacing(10);
	topBox.getChildren().add(titleLabel);

	Label addressLabel = new Label("服务器地址:");

	addressField.setPromptText("服务器地址");

	addressLabel.setPrefSize(75, 25);
	addressLabel.setLayoutX(10);
	addressLabel.setLayoutY(5);
	addressField.setPrefSize(250, 25);
	addressField.setLayoutX(addressLabel.getLayoutX() + addressLabel.getPrefWidth() + 10);
	addressField.setLayoutY(addressLabel.getLayoutY());

	portField.setPromptText("端口");
	Label partLabel = new Label("端口:");

	partLabel.setPrefSize(40, 25);
	partLabel.setLayoutX(355);
	partLabel.setLayoutY(5);
	portField.setPrefSize(80, 25);
	portField.setLayoutX(partLabel.getLayoutX() + partLabel.getPrefWidth() + 10);
	portField.setLayoutY(partLabel.getLayoutY());

	AnchorPane infoPane = new AnchorPane();
	infoPane.setStyle("-fx-background-color:#ffffff");
	infoPane.getChildren().add(addressLabel);
	infoPane.getChildren().add(addressField);

	infoPane.getChildren().add(partLabel);
	infoPane.getChildren().add(portField);

	cancelButton.setText("取消");
	cancelButton.setPrefWidth(80);

	button.setText("确定");
	button.setPrefWidth(80);

	bottomBox.setStyle("-fx-background-color:#c9e1e9");
	bottomBox.setAlignment(Pos.BASELINE_RIGHT);
	bottomBox.setPadding(new Insets(5, 10, 5, 10));
	bottomBox.setSpacing(10);
	bottomBox.getChildren().add(button);
	bottomBox.getChildren().add(cancelButton);

	rootPane.setTop(topBox);
	rootPane.setCenter(infoPane);
	rootPane.setBottom(bottomBox);
	Pattern pattern = Pattern.compile("0|(-?([1-9]\\d*)?)");
	;
	TextFormatter<Integer> formatter = new TextFormatter<Integer>(new StringConverter<Integer>() {

		@Override
		public String toString(Integer value) {
			return null != value ? value.toString() : "0";
		}

		@Override
		public Integer fromString(String text) {
			int i = 0;
			if (null != text) {
				Matcher matcher = pattern.matcher(text);
				if (matcher.matches()) {
					i = Integer.parseInt(text);
				}
			}
			return i;
		}
	});
	portField.setTextFormatter(formatter);
}
 
Example 4
Source File: AddFrame.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.setWidth(460);
	this.setHeight(355);
	this.setCenter(rootPane);
	
	textInput.setTitle("输入分组");
	textInput.setContentText("名称:");

	infoPanel.setHeadSize(100);
	infoPanel.setMaxWidth(130);
	infoPanel.setStyle("-fx-background-color:#e8f0f3");

	cancelButton.setText("取消");
	cancelButton.setPrefWidth(80);

	button.setText("确定");
	button.setPrefWidth(80);

	categoryBox.getSelectionModel().select(0);
	categoryBox.setConverter(new StringConverter<KeyText>() {

		@Override
		public String toString(KeyText object) {
			return object.getText();
		}

		@Override
		public KeyText fromString(String string) {
			return null;
		}

	});
	categoryBox.setCellFactory(new Callback<ListView<KeyText>, ListCell<KeyText>>() {
		@Override
		public ListCell<KeyText> call(ListView<KeyText> param) {
			ListCell<KeyText> cell = new ListCell<KeyText>() {
				{
					super.setPrefWidth(100);
				}

				@Override
				public void updateItem(KeyText item, boolean empty) {
					super.updateItem(item, empty);
					if (item != null) {
						setText(item.getText());
					} else {
						setText(null);
					}
				}
			};
			return cell;
		}
	});

	remarkText.setPromptText("备注 选填");
	newButton.setText("新建分组");

	remarkText.setLayoutX(75);
	remarkText.setLayoutY(20);
	remarkText.setPrefSize(155, 23);

	categoryBox.setLayoutX(75);
	categoryBox.setLayoutY(55);
	categoryBox.setPrefSize(155, 23);

	newButton.setLayoutX(235);
	newButton.setLayoutY(55);
	newButton.setPrefSize(70, 23);

	AnchorPane infoPane = new AnchorPane();
	infoPane.setStyle("-fx-background-color:#ffffff");
	infoPane.getChildren().add(remarkText);
	infoPane.getChildren().add(categoryBox);
	infoPane.getChildren().add(newButton);

	bottomBox.setStyle("-fx-background-color:#c9e1e9");
	bottomBox.setAlignment(Pos.BASELINE_RIGHT);
	bottomBox.setPadding(new Insets(5, 10, 5, 10));
	bottomBox.setSpacing(10);
	bottomBox.getChildren().add(button);
	bottomBox.getChildren().add(cancelButton);

	rootPane.setLeft(infoPanel);
	rootPane.setCenter(infoPane);
	rootPane.setBottom(bottomBox);
}
 
Example 5
Source File: UpdatePasswordFrame.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.setTitle("修改密码");
	this.setWidth(330);
	this.setHeight(220);
	this.setTitlePaneStyle(2);
	this.setRadius(5);
	this.setResizable(false);
	this.setCenter(rootPane);

	oldPasswordField.setPromptText("请输入原密码");
	newPasswordField.setPromptText("请输入新密码");
	confirmPasswordField.setPromptText("请再次输入新密码");

	oldPasswordField.setLayoutX(75);
	oldPasswordField.setLayoutY(20);
	oldPasswordField.setPrefSize(155, 25);

	newPasswordField.setLayoutX(75);
	newPasswordField.setLayoutY(55);
	newPasswordField.setPrefSize(155, 25);

	confirmPasswordField.setLayoutX(75);
	confirmPasswordField.setLayoutY(90);
	confirmPasswordField.setPrefSize(155, 25);

	AnchorPane infoPane = new AnchorPane();
	infoPane.setStyle("-fx-background-color:#ffffff");
	infoPane.getChildren().add(oldPasswordField);
	infoPane.getChildren().add(newPasswordField);
	infoPane.getChildren().add(confirmPasswordField);

	cancelButton.setText("取消");
	cancelButton.setPrefWidth(80);

	button.setText("确定");
	button.setPrefWidth(80);

	bottomBox.setStyle("-fx-background-color:#c9e1e9");
	bottomBox.setAlignment(Pos.BASELINE_RIGHT);
	bottomBox.setPadding(new Insets(5, 10, 5, 10));
	bottomBox.setSpacing(10);
	bottomBox.getChildren().add(button);
	bottomBox.getChildren().add(cancelButton);

	rootPane.setTop(topBox);
	rootPane.setCenter(infoPane);
	rootPane.setBottom(bottomBox);
}
 
Example 6
Source File: InfoPane.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {

		/*** 头像部分 start ****/
		headImageView.setFitHeight(60);
		headImageView.setFitWidth(60);

		headClip.setArcHeight(60);
		headClip.setArcWidth(60);

		headClip.setWidth(60);
		headClip.setHeight(60);

		AnchorPane headImagePane = new AnchorPane();
		headImagePane.setClip(headClip);
		headImagePane.getChildren().add(headImageView);
		headImagePane.setStyle("-fx-background-color:rgba(255, 255, 255, 0.9)");

		AnchorPane pane = new AnchorPane();
		pane.getStyleClass().add("head-common-image-pane");
		pane.getChildren().add(headImagePane);

		VBox headRootPane = new VBox();

		headRootPane.getChildren().add(pane);
		headRootPane.setPadding(new Insets(5, 5, 5, 5));
		
		HBox hBox = new HBox();
		hBox.getChildren().add(headRootPane);
		/***** 头像部分 end *****/

		nameLabel.setStyle("-fx-text-fill:#000000;-fx-font-size:14px;");
		numberLabel.setStyle("-fx-text-fill:#000000;-fx-font-size:14px;");

		textArea.setEditable(false);
		textArea.setBorder(Border.EMPTY);
		textArea.getStyleClass().clear();
		textArea.setWrapText(true);

		VBox vBox = new VBox();
		vBox.setPadding(new Insets(5, 5, 5, 5));
		vBox.getChildren().add(nameLabel);
		vBox.getChildren().add(numberLabel);

		this.setPadding(new Insets(8, 15, 8, 15));
		
		baseBorderPane.setTop(hBox);
		baseBorderPane.setCenter(textArea);
		
		this.getChildren().add(baseBorderPane);
	}
 
Example 7
Source File: GroupEditFrame.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.setTitle("修改资料");
	this.setResizable(false);
	this.setTitlePaneStyle(2);
	this.setWidth(390);
	this.setHeight(520);
	this.setRadius(5);
	this.setCenter(rootPane);
	

	Label nameLabel = new Label("名 \t 称");
	Label introduceLabel = new Label("介 \t 绍");
	Label publicNoticeLabel = new Label("公 \t 告");
	
	nameField.setPromptText("名称");
	introduceTextArea.setPromptText("介 绍");
	publicNoticeTextArea.setPromptText("公 告");

	imagePanel.setHeadSize(70);
	imagePanel.setPrefSize(75, 75);
	imagePanel.setLayoutX(70);
	imagePanel.setLayoutY(20);
	
	nameLabel.setPrefSize(50, 25);
	nameLabel.setLayoutX(10);
	nameLabel.setLayoutY(120);
	nameField.setPrefSize(290, 25);
	nameField.setLayoutX(nameLabel.getLayoutX() + nameLabel.getPrefWidth() + 10);
	nameField.setLayoutY(nameLabel.getLayoutY());

	introduceLabel.setPrefSize(50, 25);
	introduceLabel.setLayoutX(10);
	introduceLabel.setLayoutY(nameField.getLayoutY() + nameField.getPrefHeight() + 15);
	introduceTextArea.setPrefSize(290, 120);
	introduceTextArea.setLayoutX(nameField.getLayoutX());
	introduceTextArea.setLayoutY(introduceLabel.getLayoutY());
	
	publicNoticeLabel.setPrefSize(50, 25);
	publicNoticeLabel.setLayoutX(10);
	publicNoticeLabel.setLayoutY(introduceTextArea.getLayoutY() + introduceTextArea.getPrefHeight() + 15);
	publicNoticeTextArea.setPrefSize(290, 120);
	publicNoticeTextArea.setLayoutX(nameField.getLayoutX());
	publicNoticeTextArea.setLayoutY(publicNoticeLabel.getLayoutY());

	AnchorPane infoPane = new AnchorPane();
	infoPane.setStyle("-fx-background-color:#ffffff");
	infoPane.getChildren().add(nameLabel);
	infoPane.getChildren().add(introduceLabel);
	infoPane.getChildren().add(publicNoticeLabel);

	infoPane.getChildren().add(nameField);
	infoPane.getChildren().add(introduceTextArea);
	infoPane.getChildren().add(publicNoticeTextArea);

	cancelButton.setText("取消");
	cancelButton.setPrefWidth(80);

	button.setText("确定");
	button.setPrefWidth(80);

	bottomBox.setStyle("-fx-background-color:#c9e1e9");
	bottomBox.setAlignment(Pos.BASELINE_RIGHT);
	bottomBox.setPadding(new Insets(5, 10, 5, 10));
	bottomBox.setSpacing(10);
	bottomBox.getChildren().add(button);
	bottomBox.getChildren().add(cancelButton);

	
	//VBox vBox=new VBox();
	
	infoPane.getChildren().add(imagePanel);
	//vBox.getChildren().add(infoPane);
	
	rootPane.setCenter(infoPane);
	rootPane.setBottom(bottomBox);
}
 
Example 8
Source File: NetSettingFrame.java    From oim-fx with MIT License 4 votes vote down vote up
private void initComponent() {
	this.setWidth(420);
	this.setHeight(120);
	this.setResizable(false);
	this.setTitlePaneStyle(2);
	this.setRadius(5);
	this.setCenter(rootPane);
	this.setTitle("服务器地址设置");

	Label nameLabel = new Label("服务器地址:");

	addressField.setPromptText("服务器地址");

	nameLabel.setPrefSize(75, 25);
	nameLabel.setLayoutX(10);
	nameLabel.setLayoutY(5);
	addressField.setPrefSize(300, 25);
	addressField.setLayoutX(nameLabel.getLayoutX() + nameLabel.getPrefWidth() + 10);
	addressField.setLayoutY(nameLabel.getLayoutY());

	AnchorPane infoPane = new AnchorPane();
	infoPane.setStyle("-fx-background-color:#ffffff");
	infoPane.getChildren().add(nameLabel);
	infoPane.getChildren().add(addressField);

	cancelButton.setText("取消");
	cancelButton.setPrefWidth(80);

	button.setText("确定");
	button.setPrefWidth(80);

	bottomBox.setStyle("-fx-background-color:#c9e1e9");
	bottomBox.setAlignment(Pos.BASELINE_RIGHT);
	bottomBox.setPadding(new Insets(5, 10, 5, 10));
	bottomBox.setSpacing(10);
	bottomBox.getChildren().add(button);
	bottomBox.getChildren().add(cancelButton);

	rootPane.setTop(topBox);
	rootPane.setCenter(infoPane);
	rootPane.setBottom(bottomBox);
}