Java Code Examples for javafx.scene.layout.BorderPane#setAlignment()

The following examples show how to use javafx.scene.layout.BorderPane#setAlignment() . 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: OpenWithDialog.java    From pdfsam with GNU Affero General Public License v3.0 7 votes vote down vote up
@Inject
public OpenWithDialog(StylesConfig styles, List<Module> modules) {
    initModality(Modality.WINDOW_MODAL);
    initStyle(StageStyle.UTILITY);
    setResizable(false);
    setTitle(DefaultI18nContext.getInstance().i18n("Open with"));

    this.modules = modules.stream().sorted(comparing(m -> m.descriptor().getName())).collect(toList());

    messageTitle.getStyleClass().add("-pdfsam-open-with-dialog-title");

    BorderPane containerPane = new BorderPane();
    containerPane.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.getStyleClass().addAll("-pdfsam-open-with-dialog", "-pdfsam-open-with-container");
    containerPane.setTop(messageTitle);
    BorderPane.setAlignment(messageTitle, Pos.TOP_CENTER);

    filesList.setPrefHeight(150);
    containerPane.setCenter(filesList);

    buttons.getStyleClass().addAll(Style.CONTAINER.css());
    containerPane.setBottom(buttons);
    BorderPane.setAlignment(buttons, Pos.CENTER);

    Scene scene = new Scene(containerPane);
    scene.getStylesheets().addAll(styles.styles());
    scene.setOnKeyReleased(new HideOnEscapeHandler(this));
    setScene(scene);
    eventStudio().addAnnotatedListeners(this);
}
 
Example 2
Source File: PropertyEditorDialog.java    From JetUML with GNU General Public License v3.0 6 votes vote down vote up
private Scene createScene(PropertySheet.PropertyChangeListener pPropertyChangeListener) 
{
	PropertySheet sheet = new PropertySheet(aElement, pPropertyChangeListener);
			
	BorderPane layout = new BorderPane();
	Button button = new Button(RESOURCES.getString("dialog.diagram_size.ok"));
	
	// The line below allows to click the button by using the "Enter" key, 
	// by making it the default button, but only when it has the focus.
	button.defaultButtonProperty().bind(button.focusedProperty());
	button.setOnAction(pEvent -> aStage.close());
	BorderPane.setAlignment(button, Pos.CENTER_RIGHT);
	
	layout.setPadding(new Insets(LAYOUT_PADDING));
	layout.setCenter(sheet);
	layout.setBottom(button);
	
	return new Scene(layout);
}
 
Example 3
Source File: LogView.java    From helloiot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Node constructContent() {
    StackPane stackpaneroot = new StackPane();
    stackpaneroot.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    
    BorderPane borderpane = new BorderPane();
    
    statusview = new TextArea();
    statusview.setEditable(false);
    statusview.setFocusTraversable(false);
    statusview.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    statusview.setPrefHeight(100.0);
    statusview.getStyleClass().addAll("unitinputview", "unitinputcode");
    BorderPane.setAlignment(statusview, Pos.CENTER);
    
    borderpane.setCenter(statusview);
    
    stackpaneroot.getChildren().add(borderpane);
    
    initialize();
    return stackpaneroot;
}
 
Example 4
Source File: EditAreaView.java    From helloiot with GNU General Public License v3.0 6 votes vote down vote up
@Override
public Node constructContent() {
    
    StackPane stackpaneroot = new StackPane();
    stackpaneroot.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    
    BorderPane borderpane = new BorderPane();
    
    statusview = new TextArea();
    statusview.setEditable(false);
    statusview.setFocusTraversable(false);
    statusview.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    statusview.setPrefHeight(100.0);
    statusview.getStyleClass().add("unitinputview");
    BorderPane.setAlignment(statusview, Pos.CENTER);
    
    borderpane.setCenter(statusview);
    
    stackpaneroot.getChildren().add(borderpane);
    
    initialize();
    return stackpaneroot;
}
 
Example 5
Source File: AttachPane.java    From Recaf with MIT License 6 votes vote down vote up
private void promptPrimary(List<JavaResource> libs) {
	BorderPane pane = new BorderPane();
	Stage stage = controller.windows().window(LangUtil.translate("ui.menubar.file.newwizard"), pane);
	ResourceComboBox comboResources = new ResourceComboBox(controller);
	comboResources.setItems(FXCollections.observableArrayList(libs));
	ActionButton btn = new ActionButton(LangUtil.translate("misc.load"), () -> {
		JavaResource primary = comboResources.getSelectionModel().getSelectedItem();
		libs.remove(primary);
		controller.setWorkspace(new Workspace(primary, libs));
		stage.close();
	});
	btn.prefWidthProperty().bind(pane.widthProperty());
	btn.setDisable(true);
	comboResources.getSelectionModel().selectedItemProperty().addListener((ob, old, cur) -> {
		btn.setDisable(false);
	});
	comboResources.getSelectionModel().select(0);
	BorderPane.setAlignment(comboResources, Pos.CENTER);
	pane.setTop(comboResources);
	pane.setCenter(btn);
	stage.show();
}
 
Example 6
Source File: ImportTableColumn.java    From constellation with Apache License 2.0 5 votes vote down vote up
public ColumnHeader(String label) {
    setPadding(new Insets(2));
    this.label = new Label(label);
    BorderPane.setAlignment(this.label, Pos.CENTER);
    setTop(this.label);
    setCenter(new Label());
}
 
Example 7
Source File: Exercise_17_13.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a label
	Label lblText = new Label(
		"If the base file is named temp.txt wth three pieces,\n" +
		"temp.txt.1, temp.txt.2, and temp.txt.3 are combined into temp.txt.");

	// Create a grid pane, place labels and text fields
	// into it and set its padding an horizontal gaps
	GridPane paneForFields = new GridPane();
	paneForFields.setHgap(5);
	paneForFields.add(new Label("Enter a file"), 0, 0);
	paneForFields.add(tfFileName, 1, 0);
	paneForFields.add(new Label("Specify the number of smaller files"), 0, 1);
	paneForFields.add(tfNumberOfFiles, 1, 1);
	paneForFields.setPadding(new Insets(5, 20, 5, 0));

	// Create a button
	Button btStart = new Button("Start");

	// Create a border pane and place node into it
	BorderPane pane = new BorderPane();
	pane.setTop(lblText);
	pane.setCenter(paneForFields);
	pane.setBottom(btStart);
	pane.setAlignment(btStart, Pos.CENTER);

	// Create and register handler
	btStart.setOnAction(e -> start());

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane);
	primaryStage.setTitle("Exercise_17_13"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 8
Source File: Exercise_21_11.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
/** Returns the ranking pane */
private BorderPane getPane() {
	// Add items to cboYear
	for (int i = 2001; i <= 2010; i++)
		cboYear.getItems().add(i + "");

	// Add items to cboGender
	cboGender.getItems().addAll("Male", "Female");	
	
	// Create a grid pane
	GridPane gridPane = new GridPane();
	gridPane.setVgap(5);
	gridPane.setPadding(new Insets(5, 0, 5, 0));
	gridPane.setAlignment(Pos.CENTER);
	gridPane.add(new Label("Select a year: "), 0, 0);
	gridPane.add(cboYear, 1, 0);
	gridPane.add(new Label("Boy or girl?: "), 0, 1);
	gridPane.add(cboGender, 1, 1);
	gridPane.add(new Label("Enter a name: "), 0, 2);
	gridPane.add(tfName, 1, 2);
	gridPane.add(btFindRanking, 1, 3);

	// Create a border pane and place node in it
	BorderPane pane = new BorderPane();
	pane.setCenter(gridPane);
	pane.setBottom(lblResults);
	pane.setAlignment(lblResults, Pos.CENTER);

	return pane;
}
 
Example 9
Source File: Exercise_16_16.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Set combo box properties
	cbo.getItems().addAll("SINGLE", "MULTIPLE");
	cbo.setValue("SINGLE");

	// Create a label and set its content display
	Label lblSelectionMode = new Label("Choose Selection Mode:", cbo);
	lblSelectionMode.setContentDisplay(ContentDisplay.RIGHT);

	// Set defaut list view as single
	lv.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

	// Create and register the handlers
	cbo.setOnAction(e -> {
		setMode();
		setText();
	});

	lv.getSelectionModel().selectedItemProperty().addListener(
		ov -> {
		setMode();
		setText();
	});

	// Place nodes in the pane
	BorderPane pane = new BorderPane();
	pane.setTop(lblSelectionMode);
	pane.setCenter(new ScrollPane(lv));
	pane.setBottom(lblSelectedItems);
	pane.setAlignment(lblSelectionMode, Pos.CENTER);

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 268, 196);
	primaryStage.setTitle("Exercise_16_16"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 10
Source File: CustomOverlay.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private void init() {
  getStyleClass().add("custom-overlay");

  Label centerLbl = new Label("This is an example of a custom overlay!");
  centerLbl.getStyleClass().add("centerLbl");
  setCenter(centerLbl);

  if (blocking) {
    // only show x button if it's a blocking overlay, so it can still be closed
    Button closeBtn = new Button("", new FontAwesomeIconView(FontAwesomeIcon.CLOSE));
    closeBtn.setOnAction(event -> workbench.hideOverlay(this));
    BorderPane.setAlignment(closeBtn, Pos.TOP_RIGHT);
    setTop(closeBtn);
  }
}
 
Example 11
Source File: Exercise_15_02.java    From Intro-to-Java-Programming with MIT License 5 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	// Create a rectangle
	Rectangle rectangle = new Rectangle();
	rectangle.setWidth(90);
	rectangle.setHeight(40);
	rectangle.setFill(Color.RED);
	rectangle.setStroke(Color.BLACK);

	// Create a button
	Button btRotate = new Button("Rotate");

	// Process events
	btRotate.setOnAction(e -> 
		rectangle.setRotate(rectangle.getRotate() + 15));

	// Create a border pane and set its properties
	BorderPane pane = new BorderPane();
	pane.setCenter(rectangle);
	pane.setBottom(btRotate);
	BorderPane.setAlignment(rectangle, Pos.CENTER);
	BorderPane.setAlignment(btRotate, Pos.CENTER);
	pane.setPadding(new Insets(5, 5, 5, 5));

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 170, 170);
	primaryStage.setTitle("Exercise_15_02"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage; 
}
 
Example 12
Source File: Dialog.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
public Builder create() {
    stage = new Dialog();
    stage.initOwner(QueleaApp.get().getMainWindow());
    stage.initModality(Modality.APPLICATION_MODAL);
    stage.setIconified(false);
    stage.centerOnScreen();
    stage.borderPanel = new BorderPane();

    // icon
    stage.icon = new ImageView();
    stage.borderPanel.setLeft(stage.icon);
    BorderPane.setMargin(stage.icon, new Insets(MARGIN));

    // message
    stage.messageBox = new VBox();
    stage.messageBox.setAlignment(Pos.CENTER_LEFT);

    stage.messageLabel = new Label();
    stage.messageLabel.setWrapText(true);
    stage.messageLabel.setMinWidth(MESSAGE_MIN_WIDTH);
    stage.messageLabel.setMaxWidth(MESSAGE_MAX_WIDTH);

    stage.messageBox.getChildren().add(stage.messageLabel);
    stage.borderPanel.setCenter(stage.messageBox);
    BorderPane.setAlignment(stage.messageBox, Pos.CENTER);
    BorderPane.setMargin(stage.messageBox, new Insets(MARGIN, MARGIN, MARGIN, 2 * MARGIN));

    // buttons
    stage.buttonsPanel = new HBox();
    stage.buttonsPanel.setSpacing(MARGIN);
    stage.buttonsPanel.setAlignment(Pos.BOTTOM_CENTER);
    BorderPane.setMargin(stage.buttonsPanel, new Insets(0, 0, 1.5 * MARGIN, 0));
    stage.borderPanel.setBottom(stage.buttonsPanel);
    stage.borderPanel.widthProperty().addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> ov, Number t, Number t1) {
            stage.buttonsPanel.layout();
        }
    });

    stage.scene = new Scene(stage.borderPanel);
    if (QueleaProperties.get().getUseDarkTheme()) {
        stage.scene.getStylesheets().add("org/modena_dark.css");
    }
    stage.setScene(stage.scene);
    return this;
}
 
Example 13
Source File: DeckBuilderView.java    From metastone with GNU General Public License v2.0 4 votes vote down vote up
private void showBottomBar(Node content) {
	BorderPane.setAlignment(content, Pos.CENTER);
	setBottom(content);
}
 
Example 14
Source File: PreferencesDialog.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create a new preference dialog.
 *
 * @author Arvid
 */
public PreferencesDialog(Class parent, boolean hasVLC) {
    setTitle(LabelGrabber.INSTANCE.getLabel("options.title"));
    initModality(Modality.APPLICATION_MODAL);
    initOwner(QueleaApp.get().getMainWindow());
    getIcons().add(new Image("file:icons/options.png", 16, 16, false, true));
    mainPane = new BorderPane();

    generalPanel = new OptionsGeneralPanel(bindings);
    displayPanel = new OptionsDisplaySetupPanel(bindings);
    stageViewPanel = new OptionsStageViewPanel(bindings);
    noticePanel = new OptionsNoticePanel(bindings);
    presentationPanel = new OptionsPresentationPanel(bindings);
    biblePanel = new OptionsBiblePanel(bindings);
    optionsServerSettingsPanel = new OptionsServerSettingsPanel(bindings);
    recordingPanel = new OptionsRecordingPanel(bindings, hasVLC);

    preferencesFx =
            PreferencesFx.of(new PreferenceStorageHandler(parent),
                    generalPanel.getGeneralTab(),
                    displayPanel.getDisplaySetupTab(),
                    stageViewPanel.getStageViewTab(),
                    noticePanel.getNoticesTab(),
                    presentationPanel.getPresentationsTab(),
                    biblePanel.getBiblesTab(),
                    optionsServerSettingsPanel.getServerTab(),
                    recordingPanel.getRecordingsTab()
            );

    okButton = new Button(LabelGrabber.INSTANCE.getLabel("ok.button"), new ImageView(new Image("file:icons/tick.png")));
    BorderPane.setMargin(okButton, new Insets(5));
    okButton.setOnAction((ActionEvent t) -> {
        preferencesFx.saveSettings();
        if (displayPanel.isDisplayChange()) {
            updatePos();
        }
        displayPanel.setDisplayChange(false);
        QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getThemeNode().refresh();
        hide();
    });
    BorderPane.setAlignment(okButton, Pos.CENTER);

    mainPane.setBottom(okButton);
    mainPane.setMinWidth(1005);
    mainPane.setMinHeight(600);
    mainPane.setCenter(preferencesFx.getView().getCenter());

    Scene scene = new Scene(mainPane);
    if (QueleaProperties.get().getUseDarkTheme()) {
        scene.getStylesheets().add("org/modena_dark.css");
    }
    setScene(scene);

    getScene().getWindow().addEventFilter(WindowEvent.WINDOW_SHOWN, e -> callBeforeShowing());
    getScene().getWindow().addEventFilter(WindowEvent.WINDOW_CLOSE_REQUEST, e -> callBeforeHiding());

    bindings.forEach(this::bind);
}
 
Example 15
Source File: MessageItem.java    From helloiot with GNU General Public License v3.0 4 votes vote down vote up
public MessageItem(EventMessage message) {
    getStyleClass().add("message");
    setMaxSize(Double.MAX_VALUE, 60.0);
    setMinSize(Control.USE_COMPUTED_SIZE, 60.0);
    setPrefSize(Control.USE_COMPUTED_SIZE, 60.0);
    HBox.setHgrow(this, Priority.SOMETIMES);   
    
    StringFormat format = StringFormatIdentity.INSTANCE;
    String txt = format.format(format.value(message.getMessage()));
    
    Label messageview = new Label(txt);
    messageview.setTextOverrun(OverrunStyle.ELLIPSIS);
    messageview.getStyleClass().add("unitinputview");
    BorderPane.setAlignment(messageview, Pos.CENTER_LEFT);

    setCenter(messageview);
    
    HBox footer = new HBox();
    
    Label topictext = new Label(message.getTopic());
    topictext.setTextOverrun(OverrunStyle.ELLIPSIS);
    topictext.getStyleClass().add("messagefooter");
    topictext.setMaxWidth(Double.MAX_VALUE);
    HBox.setHgrow(topictext, Priority.ALWAYS);
    footer.getChildren().add(topictext);        
    
    DateTimeFormatter dtf = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM);
    Label datetext = new Label(LocalDateTime.now().format(dtf));
    datetext.getStyleClass().add("messagefooter");
    footer.getChildren().add(datetext);
    
    MiniVar v2 = message.getProperty("mqtt.retained");
    if (v2 != null && v2.asBoolean()) {
        Label retainedtext = new Label(resources.getString("badge.retained"));
        retainedtext.getStyleClass().addAll("badge", "badgeretained");
        footer.getChildren().add(retainedtext);            
    }    
    
    MiniVar v = message.getProperty("mqtt.qos");
    if (v != null) {
        Label qostext = new Label(String.format(resources.getString("badge.qos"), v.asInt()));
        qostext.getStyleClass().addAll("badge", "badgeqos");
        footer.getChildren().add(qostext);            
    }

    setBottom(footer);
}
 
Example 16
Source File: EditThemeScheduleActionHandler.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Edit the theme of the currently selected item in the schedule.
 *
 * @param t the action event.
 */
@Override
public void handle(ActionEvent t) {
    TextDisplayable firstSelected = selectedDisplayable;
    if (selectedDisplayable == null) {
        firstSelected = (TextDisplayable) QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getScheduleList().getSelectionModel().getSelectedItem();
    }
    InlineCssTextArea wordsArea = new InlineCssTextArea();
    wordsArea.replaceText(firstSelected.getSections()[0].toString().trim());
    Button confirmButton = new Button(LabelGrabber.INSTANCE.getLabel("ok.button"), new ImageView(new Image("file:icons/tick.png")));
    Button cancelButton = new Button(LabelGrabber.INSTANCE.getLabel("cancel.button"), new ImageView(new Image("file:icons/cross.png")));
    final Stage s = new Stage();
    s.initModality(Modality.APPLICATION_MODAL);
    s.initOwner(QueleaApp.get().getMainWindow());
    s.resizableProperty().setValue(false);
    final BorderPane bp = new BorderPane();
    final ThemePanel tp = new ThemePanel(wordsArea, confirmButton, true);
    tp.setPrefSize(500, 500);
    if (firstSelected.getSections().length > 0) {
        tp.setTheme(firstSelected.getSections()[0].getTheme());
    }
    confirmButton.setOnAction(e -> {
        if (tp.getTheme() != null) {
            ScheduleList sl = QueleaApp.get().getMainWindow().getMainPanel().getSchedulePanel().getScheduleList();
            tp.updateTheme(false);
            List<Displayable> displayableList;
            if (selectedDisplayable == null) {
                displayableList = sl.getSelectionModel().getSelectedItems();
            } else {
                displayableList = new ArrayList<>();
                displayableList.add(selectedDisplayable);
            }
            for (Displayable eachDisplayable : displayableList) {
                if (eachDisplayable instanceof TextDisplayable) {
                    ((TextDisplayable) eachDisplayable).setTheme(tp.getTheme());
                    for (TextSection ts : ((TextDisplayable) eachDisplayable).getSections()) {
                        ts.setTheme(tp.getTheme());
                    }
                    if (eachDisplayable instanceof SongDisplayable) {
                        Utils.updateSongInBackground((SongDisplayable) eachDisplayable, true, false);
                    }
                }
            }
            QueleaApp.get().getMainWindow().getMainPanel().getPreviewPanel().refresh();
        }
        s.hide();
    });
    cancelButton.setOnAction(e -> {
        s.hide();
    });
    bp.setCenter(tp);

    HBox hb = new HBox(10);
    hb.setPadding(new Insets(10));
    BorderPane.setAlignment(hb, Pos.CENTER);
    hb.setAlignment(Pos.CENTER);
    hb.getChildren().addAll(confirmButton, cancelButton);
    bp.setBottom(hb);

    Scene scene = new Scene(bp);
    if (QueleaProperties.get().getUseDarkTheme()) {
        scene.getStylesheets().add("org/modena_dark.css");
    }
    s.setScene(scene);
    s.setMinHeight(600);
    s.setMinWidth(250);
    s.showAndWait();
}
 
Example 17
Source File: Exercise_16_23.java    From Intro-to-Java-Programming with MIT License 4 votes vote down vote up
@Override // Override the start method in the Application class
public void start(Stage primaryStage) {
	final int COLUMN_COUNT = 27;
	tfSpeed.setPrefColumnCount(COLUMN_COUNT);
	tfPrefix.setPrefColumnCount(COLUMN_COUNT);
	tfNumberOfImages.setPrefColumnCount(COLUMN_COUNT);
	tfURL.setPrefColumnCount(COLUMN_COUNT);

	// Create a button
	Button btStart = new Button("Start Animation");

	// Create a grid pane for labels and text fields
	GridPane paneForInfo = new GridPane();
	paneForInfo.setAlignment(Pos.CENTER);
	paneForInfo.add(new Label("Enter information for animation"), 0, 0);
	paneForInfo.add(new Label("Animation speed in milliseconds"), 0, 1);
	paneForInfo.add(tfSpeed, 1, 1);
	paneForInfo.add(new Label("Image file prefix"), 0, 2);
	paneForInfo.add(tfPrefix, 1, 2);
	paneForInfo.add(new Label("Number of images"), 0, 3);
	paneForInfo.add(tfNumberOfImages, 1, 3);
	paneForInfo.add(new Label("Audio file URL"), 0, 4);
	paneForInfo.add(tfURL, 1, 4);


	// Create a border pane
	BorderPane pane = new BorderPane();
	pane.setBottom(paneForInfo);
	pane.setCenter(paneForImage);
	pane.setTop(btStart);
	pane.setAlignment(btStart, Pos.TOP_RIGHT);

	// Create animation
	animation = new Timeline(
		new KeyFrame(Duration.millis(1000), e -> nextImage()));
	animation.setCycleCount(Timeline.INDEFINITE);

	// Create and register the handler
	btStart.setOnAction(e -> {
		if (tfURL.getText().length() > 0) {
			MediaPlayer mediaPlayer = new MediaPlayer(
				new Media(tfURL.getText()));
			mediaPlayer.play();
		}
		if (tfSpeed.getText().length() > 0)
			animation.setRate(Integer.parseInt(tfSpeed.getText()));
		animation.play();
	});

	// Create a scene and place it in the stage
	Scene scene = new Scene(pane, 550, 680);
	primaryStage.setTitle("Exercise_16_23"); // Set the stage title
	primaryStage.setScene(scene); // Place the scene in the stage
	primaryStage.show(); // Display the stage
}
 
Example 18
Source File: ListTile.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void setPrimaryGraphic(Node node) {
    BorderPane.setAlignment(node, Pos.CENTER);
    setLeft(node);
}
 
Example 19
Source File: ListTile.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
public void setSecondaryGraphic(Node node) {
    BorderPane.setAlignment(node, Pos.CENTER);
    setRight(node);
}
 
Example 20
Source File: ControlPanelTableCell.java    From MusicPlayer with MIT License 4 votes vote down vote up
@Override
protected void updateItem(T item, boolean empty) {
	
	super.updateItem(item, empty);
	
	Song song = (Song) this.getTableRow().getItem();
	
	if (empty || item == null || song == null) {
		setText(null);
		setGraphic(null);
	} else if (!song.getSelected()) {
		setText(item.toString());
		setGraphic(null);
		song.selectedProperty().removeListener(listener);
		song.selectedProperty().addListener(listener);
	} else {
		String fileName;
		// Selects the correct control panel based on whether the user is in a play list or not.
		if (MusicPlayer.getMainController().getSubViewController() instanceof PlaylistsController) {
			fileName = Resources.FXML + "ControlPanelPlaylists.fxml";
		} else {
			fileName = Resources.FXML + "ControlPanel.fxml";
		}
		try {
			Label text = new Label(item.toString());
			text.setTextOverrun(OverrunStyle.CLIP);
               FXMLLoader loader = new FXMLLoader(this.getClass().getResource(fileName));
               HBox controlPanel = loader.load();
               BorderPane cell = new BorderPane();
               cell.setRight(controlPanel);
               cell.setCenter(text);
               BorderPane.setAlignment(text, Pos.CENTER_LEFT);
               BorderPane.setAlignment(controlPanel, Pos.CENTER_LEFT);
               setText(null);
               setGraphic(cell);
               song.selectedProperty().removeListener(listener);
   			song.selectedProperty().addListener(listener);
           } catch (Exception ex) {
               ex.printStackTrace();
           }
	}
}