Java Code Examples for javafx.scene.Parent#lookup()

The following examples show how to use javafx.scene.Parent#lookup() . 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: DetailPCController.java    From FlyingAgent with Apache License 2.0 7 votes vote down vote up
private void addDiskBox(Disk disk) {
    try {
        Parent parentDisk = FXMLLoader.load(getClass().getResource("/resources/views/models/DiskInfo.fxml"));
        //Label lblName = (Label) parentDisk.lookup("#lblName");
        Label lblTotalSpace = (Label) parentDisk.lookup("#lblTotalSpace");
        PieChart pieData = (PieChart) parentDisk.lookup("#pieData");

        pieData.setTitle(disk.getName());
        lblTotalSpace.setText(Utils.humanReadableByteCount(disk.getTotalSpace()));

        // Data of pie chart
        ObservableList<PieChart.Data> data = FXCollections.observableArrayList();
        data.add(new PieChart.Data("Usable", Utils.humanReadableByteCountNumber(disk.getUsableSpace())));
        data.add(new PieChart.Data("Free", Utils.humanReadableByteCountNumber(disk.getFreeSpace())));

        pieData.setData(data);
        pieData.getData().forEach(d ->
                d.nameProperty().bind(Bindings.concat(d.getName(), " ", d.pieValueProperty(), " GB"))
        );
        boxContainerDisks.getChildren().add(parentDisk);
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
 
Example 2
Source File: ScanAllController.java    From FlyingAgent with Apache License 2.0 6 votes vote down vote up
private void addDiskBox(Disk disk) {
    try {
        Parent parentDisk = FXMLLoader.load(getClass().getResource("/resources/views/models/DiskInfo.fxml"));
        //Label lblName = (Label) parentDisk.lookup("#lblName");
        Label lblTotalSpace = (Label) parentDisk.lookup("#lblTotalSpace");
        PieChart pieData = (PieChart) parentDisk.lookup("#pieData");

        pieData.setTitle(disk.getName());
        lblTotalSpace.setText(Utils.humanReadableByteCount(disk.getTotalSpace()));

        // Data of pie chart
        ObservableList<PieChart.Data> data = FXCollections.observableArrayList();
        data.add(new PieChart.Data("Usable", Utils.humanReadableByteCountNumber(disk.getUsableSpace())));
        data.add(new PieChart.Data("Free", Utils.humanReadableByteCountNumber(disk.getFreeSpace())));

        pieData.setData(data);
        pieData.getData().forEach(d ->
                d.nameProperty().bind(Bindings.concat(d.getName(), " ", d.pieValueProperty(), " GB"))
        );
        boxContainerDisks.getChildren().add(parentDisk);
    } catch (IOException ioe) {
        ioe.printStackTrace();
    }
}
 
Example 3
Source File: DeployFragment.java    From Notebook with Apache License 2.0 6 votes vote down vote up
@Override
public void initData(Parent node, Map<String, String> bundle) {
	btn_deploy = (Button) node.lookup("#btn_deploy");
	progressbar = (ProgressIndicator) node.lookup("#progressbar");

	btn_deploy.setOnAction(e->{
		progressbar.isIndeterminate();// һ ��������ʾ�����ڷ�ȷ��ģʽ,����progressbar����һ����ֵ�и�Сbug������¡�
		progressbar.setVisible(true);
		progressbar.setProgress(-1f);
		progressbar.setProgress(0.5f);
		progressbar.setProgress(-1f);
		btn_deploy.setDisable(true);// �����ظ����

		AnnotationHandler.sendMessage("work",null);
	});

	AnnotationHandler.register(this);

}
 
Example 4
Source File: OCRSettingItem.java    From MSPaintIDE with MIT License 6 votes vote down vote up
@Override
public Pane getPane() throws IOException {
    FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource(this.file));
    loader.setController(this);
    Parent root = loader.load();
    Node node = root.lookup("*");

    if (!(node instanceof Pane)) throw new LoadException("Root element of " + this.file + " not a pane!");

    this.themeChanger = this.mainGUI.getThemeManager().onDarkThemeChange((Pane) node, Map.of(
            "#fontSelect", "dark",
            ".remove-entry", "remove-entry-white"
    ));

    this.themeChanger.update(100, TimeUnit.MILLISECONDS);

    return (Pane) node;
}
 
Example 5
Source File: AppearanceSettingItem.java    From MSPaintIDE with MIT License 6 votes vote down vote up
@Override
public Pane getPane() throws IOException {
    FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource(this.file));
    loader.setController(this);
    Parent root = loader.load();
    Node node = root.lookup("*");

    if (!(node instanceof Pane)) throw new LoadException("Root element of " + this.file + " not a pane!");

    this.themeChanger = this.mainGUI.getThemeManager().onDarkThemeChange((Pane) node, Map.of(
            "#fontSelect", "dark",
            ".remove-entry", "remove-entry-white"
    ));

    this.themeChanger.update(100, TimeUnit.MILLISECONDS);

    return (Pane) node;
}
 
Example 6
Source File: SyncFragment.java    From Notebook with Apache License 2.0 5 votes vote down vote up
@Override
public void initData(Parent node, Map<String, String> bundle) {
	progressbar = (ProgressIndicator) node.lookup("#progressbar");

	iv_sync = (ImageView) node.lookup("#iv_sync");
	iv_down = (ImageView) node.lookup("#iv_down");

	iv_sync.setOnMouseEntered(e-> {
		iv_sync.setImage(sync_enter);
	});
	iv_sync.setOnMouseExited(e-> {
		iv_sync.setImage(sync_defalt);
	});

	iv_down.setOnMouseEntered(e-> {
		iv_down.setImage(down_enter);
	});
	iv_down.setOnMouseExited(e-> {
		iv_down.setImage(down_default);
	});

	iv_down.setOnMouseClicked(e->{
		 download();
	});

	iv_sync.setOnMouseClicked(e->{
		sync();
	});
}
 
Example 7
Source File: EmailFragment.java    From Notebook with Apache License 2.0 5 votes vote down vote up
@Override
public void initData(Parent node, Map<String, String> bundle) {
	cb_batch = (CheckBox) node.lookup("#cb_batch");
	ta_from = (TextArea) node.lookup("#ta_from");
	ta_to = (TextArea) node.lookup("#ta_to");
	ta_content = (TextArea) node.lookup("#ta_content");
	btn_send = (Button) node.lookup("#btn_send");
	tx_url = (TextField) node.lookup("#tx_url");

	loadCache();

	btn_send.setOnAction(e -> {
		boolean batchAll = cb_batch.isSelected();
		ThreadUtils.run(new Runnable() {

			@Override
			public void run() {
				try {
					updateDB();
					EmailManager.getInstance().send(batchAll, ta_from, ta_to, ta_content, tx_url);
					System.out.println("=========> end <=========");
					Platform.runLater(new Runnable() {

						@Override
						public void run() {
							DialogHelper.alert("��Ϣ", "�ʼ��������!");
						}
					});
				} catch (IOException e1) {
					e1.printStackTrace();
				}
			}
		});
	});
}
 
Example 8
Source File: SettingFragment.java    From Notebook with Apache License 2.0 5 votes vote down vote up
@Override
public void initData(Parent node, Map<String, String> bundle) {
	et_download_path = (TextField) node.lookup("#et_download_path");
	et_deploy_path = (TextField) node.lookup("#et_deploy_path");
	et_secret = (TextField) node.lookup("#et_secret");
	et_git_username = (TextField) node.lookup("#et_git_username");
	et_git_passwd = (PasswordField) node.lookup("#et_git_passwd");
	et_app_password = (PasswordField) node.lookup("#et_app_password");
	et_app_password_second = (PasswordField) node.lookup("#et_app_password_second");
	btn_submit = (Button) node.lookup("#btn_submit");

	readFromProperty();

	btn_submit.setOnAction(e->{
		String message = "";
		if(!et_app_password.getText().trim().equals(et_app_password_second.getText().trim())){
			message = "�����������벻һ�£�";
			DialogHelper.alert("����", message);
			return;
		}
		if(!"".equals(et_app_password.getText().trim()) && et_app_password.getText().trim().length() < 5){
			message = "���볤��̫��,������ȫ��";
			DialogHelper.alert("����", message);
			return;
		}

		writeToProperty();
	});


}
 
Example 9
Source File: DefaultSettingItem.java    From MSPaintIDE with MIT License 5 votes vote down vote up
@Override
public Pane getPane() throws IOException {
    FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource(this.file));
    Parent root = loader.load();
    Node node = root.lookup("*");

    if (!(node instanceof Pane)) throw new LoadException("Root element of " + this.file + " not a pane!");

    return (Pane) node;
}
 
Example 10
Source File: LSPSettingItem.java    From MSPaintIDE with MIT License 5 votes vote down vote up
@Override
public Pane getPane() throws IOException {
    FXMLLoader loader = new FXMLLoader(getClass().getClassLoader().getResource(this.file));
    loader.setController(this);
    Parent root = loader.load();
    Node node = root.lookup("*");

    if (!(node instanceof Pane)) throw new LoadException("Root element of " + this.file + " not a pane!");

    return (Pane) node;
}
 
Example 11
Source File: MainView.java    From Notebook with Apache License 2.0 4 votes vote down vote up
@Override
public Parent getView() {
		Parent parent = LayoutInflater.inflate("activity_main", Parent.class);
		parent.getStylesheets().add("css/main.css");

		AnchorPane main_left = (AnchorPane) parent.lookup("#main_left");
		StackPane main_center = (StackPane) parent.lookup("#main_center");

		// left
		TreeView treeView = new TreeView();
		// TreeView������Ҳ�Ƿ�Node���ͣ����Բ�����SceneBuilder��ͼ��
	    TreeItem<String> treeItemRoot = new TreeItem<String>("�����˵�",rootIcon);

		TreeItem<String> item_1 = new TreeItem<String>("���¹���",oneIcon);
		TreeItem<String> item_2 = new TreeItem<String>("������",twoIcon);
		TreeItem<String> item_3 = new TreeItem<String>("���ù���",eightIcon);
		TreeItem<String> item_4 = new TreeItem<String>("�ʼ�������",emailIcon);
		TreeItem<String> item_5 = new TreeItem<String>("ϵͳ����",threeIcon);
	    treeItemRoot.getChildren().addAll(Arrays.asList(item_1, item_2, item_3, item_4, item_5));

	    TreeItem<String> item_4_1 = new TreeItem<String>("����",fourIcon);
	    TreeItem<String> item_4_2 = new TreeItem<String>("����",fiveIcon);
	    TreeItem<String> item_4_3 = new TreeItem<String>("ͬ��",sixIcon);
	    TreeItem<String> item_4_4 = new TreeItem<String>("�˳�",sevenIcon);
	    treeItemRoot.getChildren().get(4).getChildren().addAll(Arrays.asList(item_4_1, item_4_2, item_4_3, item_4_4));

	    treeItemRoot.setExpanded(true);
	    item_5.setExpanded(true);

        treeView.setShowRoot(true);
        treeView.setRoot(treeItemRoot);
        treeView.getSelectionModel().selectedItemProperty().addListener(new ChangeListener<TreeItem<String>>() {

			@Override
			public void changed(ObservableValue<? extends TreeItem<String>> observable, TreeItem<String> oldValue,
					TreeItem<String> newValue) {
				Parent container = null;
				switch (newValue.getValue()) {
				case "���¹���":
					setSelection(main_center,FRAGMENT_ARTICLE);
					break;
				case "������":
					setSelection(main_center, FRAGMENT_CATEGORY);
					break;
				case "����":
					setSelection(main_center, FRAGMENT_SETTING);
					break;
				case "����":
					setSelection(main_center, FRAGMENT_DEPLOY);
					break;
				case "ͬ��":
					setSelection(main_center, FRAGMENT_SYNC);
					break;
				case "���ù���":
					setSelection(main_center, FRAGMENT_TOOL);
					break;
				case "�ʼ�������":
					setSelection(main_center, FRAGMENT_EMAIL);
					break;
				case "�˳�":
					Platform.exit();
					break;
				default:
					break;
				}
			}

		});

        main_left.getChildren().add(treeView);
        intSelection(main_center);
        return parent;
}