Java Code Examples for javafx.scene.control.Tab#setText()

The following examples show how to use javafx.scene.control.Tab#setText() . 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: ClientSession.java    From Open-Lowcode with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * sets the title on the active tab (corresponding to the active client display)
 * 
 * @param newtitle  the text title to show
 * @param otpstatus status of OTP connection
 */
public void setTitle(String newtitle, String otpstatus) {
	logger.warning("   --- ---- Starting setting title ");
	Tab tab = this.tabpane.getTabs().get(activedisplayindex);
	if (otpstatus.equals("NONE")) {
		tab.setText((newtitle.length() > 20 ? newtitle.substring(0, 20) + "..." : newtitle));
		tab.setTooltip(new Tooltip(newtitle));
		return;
	}
	// ---------------------- Process otp status that is not null ---------------
	BorderPane borderpane = new BorderPane();
	borderpane.setCenter(new Label(newtitle));
	Color dotcolor = Color.LIGHTGREEN;
	if (otpstatus.equals("INVALID"))
		dotcolor = Color.INDIANRED;
	Circle dot = new Circle(0, 0, 4);
	dot.setFill(dotcolor);
	dot.setStroke(Color.LIGHTGRAY);
	borderpane.setRight(dot);
	BorderPane.setAlignment(dot, Pos.CENTER);
	tab.setText("");
	tab.setGraphic(borderpane);
}
 
Example 2
Source File: TabSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TabSample() {
    BorderPane borderPane = new BorderPane();
    final TabPane tabPane = new TabPane();
    tabPane.setPrefSize(400, 400);
    tabPane.setSide(Side.TOP);
    tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
    final Tab tab1 = new Tab();
    tab1.setText("Tab 1");
    final Tab tab2 = new Tab();
    tab2.setText("Tab 2");
    final Tab tab3 = new Tab();
    tab3.setText("Tab 3");
    final Tab tab4 = new Tab();
    tab4.setText("Tab 4");
    tabPane.getTabs().addAll(tab1, tab2, tab3, tab4);
    borderPane.setCenter(tabPane);
    getChildren().add(borderPane);
}
 
Example 3
Source File: TabSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public TabSample() {
    BorderPane borderPane = new BorderPane();
    final TabPane tabPane = new TabPane();
    tabPane.setPrefSize(400, 400);
    tabPane.setSide(Side.TOP);
    tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
    final Tab tab1 = new Tab();
    tab1.setText("Tab 1");
    final Tab tab2 = new Tab();
    tab2.setText("Tab 2");
    final Tab tab3 = new Tab();
    tab3.setText("Tab 3");
    final Tab tab4 = new Tab();
    tab4.setText("Tab 4");
    tabPane.getTabs().addAll(tab1, tab2, tab3, tab4);
    borderPane.setCenter(tabPane);
    getChildren().add(borderPane);
}
 
Example 4
Source File: SettingPane.java    From oim-fx with MIT License 5 votes vote down vote up
public void addTab(String text, Node node) {
	Tab tab = new Tab();
	tab.setText(text);
	tab.setContent(node);
	tab.setClosable(false);
	tabPane.getTabs().add(tab);
}
 
Example 5
Source File: CommandPane.java    From dm3270 with Apache License 2.0 5 votes vote down vote up
private Tab getTab (String name, TextArea textArea)
{
  Tab tab = new Tab ();
  tab.setText (name);
  tab.setContent (textArea);
  return tab;
}
 
Example 6
Source File: BrokerConfigView.java    From kafka-message-tool with MIT License 5 votes vote down vote up
private Tab getNodeTab(ClusterNodeInfo nodeInfo, ConfigEntriesView clusterPropertiesTableView) {
    Tab nodeTab = new Tab();
    AnchorPane nodeTabContentPane = new AnchorPane();
    nodeTabContentPane.getChildren().add(clusterPropertiesTableView);
    nodeTab.setContent(nodeTabContentPane);
    nodeTab.setText(String.format("Node id: %s", nodeInfo.getNodeId()));
    if (nodeInfo.isController()) {
        nodeTab.setText(String.format("Node id: %s [controller]", nodeInfo.getNodeId()));
    }
    return nodeTab;
}
 
Example 7
Source File: HomeWindowController.java    From Everest with Apache License 2.0 5 votes vote down vote up
/**
 * Sets up the reflection of the address in the selected tab.
 * Displays the current target if it is not empty, "New Tab" otherwise.
 */
private void onTargetChanged(Observable observable, String oldValue, String newValue) {
    Tab activeTab = tabPane.getSelectionModel().getSelectedItem();
    if (activeTab == null)
        return;

    if (newValue.equals(""))
        activeTab.setText("New Tab");
    else
        activeTab.setText(newValue);
}
 
Example 8
Source File: HomeWindowController.java    From Everest with Apache License 2.0 5 votes vote down vote up
/**
 * Adds a new tab to the tabPane initialized with
 * the ComposerState provided.
 */
private void addTab(ComposerState composerState) {
    Tab newTab = new Tab();

    /*
        Initializing the tab text based on the target in the ComposerState.
        Further handling of the tab text is done by onTargetChanged().
      */
    String target = composerState.target;
    if (target == null || target.equals(""))
        newTab.setText("New Tab");
    else
        newTab.setText(target);

    DashboardState newState = new DashboardState(composerState);
    tabStateMap.put(newTab, newState);

    /*
        DO NOT mess with the following code. The sequence of these steps is very crucial:
         1. Get the currently selected tab.
         2. Get the current state of the dashboard to save to the map.
         3. Add the new tab, since the previous state is now with us.
         4. Switch to the new tab.
         5. Call onTabSwitched() to update the Dashboard and save the oldState.
     */
    Tab prevTab = tabPane.getSelectionModel().getSelectedItem();
    DashboardState prevState = dashboard.getState();
    tabPane.getTabs().add(newTab);
    tabPane.getSelectionModel().select(newTab);
    onTabSwitched(prevState, prevTab, newTab);

    newTab.setOnCloseRequest(e -> {
        removeTab(newTab);

        // Closes the application if the last tab is closed
        if (tabPane.getTabs().size() == 0) {
            saveState();
            Stage thisStage = (Stage) homeWindowSP.getScene().getWindow();
            thisStage.close();
        }
    });
}
 
Example 9
Source File: OrsonChartsFXDemo.java    From jfree-fxdemos with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void start(Stage stage) throws Exception {
   
    TabPane tabPane = new TabPane();
    Tab tab1 = new Tab();
    tab1.setText("Demos");
    tab1.setClosable(false);
    
    SplitPane sp = new SplitPane();
    final StackPane sp1 = new StackPane();
    sp1.getChildren().add(createTreeView());
    final BorderPane sp2 = new BorderPane();
    sp2.setCenter(createChartPane());
 
    sp.getItems().addAll(sp1, sp2);
    sp.setDividerPositions(0.3f, 0.6f);
    tab1.setContent(sp);
    tabPane.getTabs().add(tab1);        
 
    Tab tab2 = new Tab();
    tab2.setText("About");
    tab2.setClosable(false);
    
    WebView browser = new WebView();
    WebEngine webEngine = browser.getEngine();
    webEngine.load(getClass().getResource("/org/jfree/chart3d/fx/demo/about.html").toString());
    tab2.setContent(browser);
    tabPane.getTabs().add(tab2);        

    Scene scene = new Scene(tabPane, 1024, 768);
    stage.setScene(scene);
    stage.setTitle("Orson Charts JavaFX Demo");
    stage.show();
}
 
Example 10
Source File: MdCheatSheetDialog.java    From zest-writer with GNU General Public License v3.0 5 votes vote down vote up
@FXML private void initialize() {
    List<String> chaptersTitles = new ArrayList<>();

    String cheatSheet = "";
    try {
        cheatSheet = IOUtils.toString(MainApp.class.getResourceAsStream(CHEAT_SHEET_LOCATION), "UTF-8");
    } catch (IOException e) {
        logger.error("Error when reading the cheatSheet stream.", e);
    }

    Matcher titleMatcher = Pattern.compile(TITLE_REGEX).matcher(cheatSheet);
    while (titleMatcher.find()) {
        chaptersTitles.add(Configuration.getBundle().getString("ui.md_cheat_sheet." + titleMatcher.group(1)));
    }

    String[] chaptersContents = cheatSheet.split(TITLE_REGEX);
    List<Tab> tabs = cheatSheetTabPane.getTabs();

    for (int i=1 ; i<chaptersContents.length; i++) {
        Tab tab = new Tab();

        tab.setText(chaptersTitles.get(i-1));

        WebView webView = new WebView();
        String chapterContent = MainApp.getMdUtils().addHeaderAndFooter(chaptersContents[i]);

        webView.getEngine().loadContent(chapterContent);

        tab.setContent(webView);
        tabs.add(tab);
    }
}
 
Example 11
Source File: CommandPane.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
private Tab getTab (String name, TextArea textArea)
{
  Tab tab = new Tab ();
  tab.setText (name);
  tab.setContent (textArea);
  return tab;
}
 
Example 12
Source File: GuiFactory.java    From xframium-java with GNU General Public License v3.0 5 votes vote down vote up
public Tab getTab(String name, TextArea textArea)
{
  Tab tab = new Tab();
  tab.setText(name);
  tab.setContent(textArea);
  return tab;
}
 
Example 13
Source File: TabController.java    From mars-sim with GNU General Public License v3.0 5 votes vote down vote up
private void configureTab(Tab tab, String title, String iconPath, AnchorPane containerPane, URL resourceURL, EventHandler<Event> onSelectionChangedEvent) {
    double imageWidth = 40.0;

    ImageView imageView = new ImageView(new Image(iconPath));
    imageView.setFitHeight(imageWidth);
    imageView.setFitWidth(imageWidth);

    Label label = new Label(title);
    label.setMaxWidth(tabWidth - 20);
    label.setPadding(new Insets(5, 0, 0, 0));
    label.setStyle("-fx-text-fill: black; -fx-font-size: 10pt; -fx-font-weight: bold;");
    label.setTextAlignment(TextAlignment.CENTER);

    BorderPane tabPane = new BorderPane();
    tabPane.setRotate(90.0);
    tabPane.setMaxWidth(tabWidth);
    tabPane.setCenter(imageView);
    tabPane.setBottom(label);

    tab.setText("");
    tab.setGraphic(tabPane);

    tab.setOnSelectionChanged(onSelectionChangedEvent);

    if (containerPane != null && resourceURL != null) {
        try {
            Parent contentView = FXMLLoader.load(resourceURL);
            containerPane.getChildren().add(contentView);
            AnchorPane.setTopAnchor(contentView, 0.0);
            AnchorPane.setBottomAnchor(contentView, 0.0);
            AnchorPane.setRightAnchor(contentView, 0.0);
            AnchorPane.setLeftAnchor(contentView, 0.0);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
Example 14
Source File: OptionsDialog.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void initComponents() {
	// JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
	tabPane = new TabPane();
	generalTab = new Tab();
	generalOptionsPane = new GeneralOptionsPane();
	editorTab = new Tab();
	editorOptionsPane = new EditorOptionsPane();
	markdownTab = new Tab();
	markdownOptionsPane = new MarkdownOptionsPane();
	stylesheetsTab = new Tab();
	stylesheetsOptionsPane = new StylesheetsOptionsPane();

	//======== tabPane ========
	{
		tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);

		//======== generalTab ========
		{
			generalTab.setText(Messages.get("OptionsDialog.generalTab.text"));
			generalTab.setContent(generalOptionsPane);
		}

		//======== editorTab ========
		{
			editorTab.setText(Messages.get("OptionsDialog.editorTab.text"));
			editorTab.setContent(editorOptionsPane);
		}

		//======== markdownTab ========
		{
			markdownTab.setText(Messages.get("OptionsDialog.markdownTab.text"));
			markdownTab.setContent(markdownOptionsPane);
		}

		//======== stylesheetsTab ========
		{
			stylesheetsTab.setText(Messages.get("OptionsDialog.stylesheetsTab.text"));
			stylesheetsTab.setContent(stylesheetsOptionsPane);
		}

		tabPane.getTabs().addAll(generalTab, editorTab, markdownTab, stylesheetsTab);
	}
	// JFormDesigner - End of component initialization  //GEN-END:initComponents
}
 
Example 15
Source File: TabsDemo.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Tabs");

    JFXTabPane tabPane = new JFXTabPane();

    Tab tab = new Tab();
    tab.setText(msg);
    tab.setContent(new Label(TAB_0));

    tabPane.getTabs().add(tab);
    tabPane.setPrefSize(300, 200);
    Tab tab1 = new Tab();
    tab1.setText(TAB_01);
    tab1.setContent(new Label(TAB_01));

    tabPane.getTabs().add(tab1);

    SingleSelectionModel<Tab> selectionModel = tabPane.getSelectionModel();
    selectionModel.select(1);

    JFXButton button = new JFXButton("New Tab");
    button.setOnMouseClicked((o) -> {
        Tab temp = new Tab();
        int count = tabPane.getTabs().size();
        temp.setText(msg + count);
        temp.setContent(new Label(TAB_0 + count));
        tabPane.getTabs().add(temp);
    });

    tabPane.setMaxWidth(500);

    HBox hbox = new HBox();
    hbox.getChildren().addAll(button, tabPane);
    hbox.setSpacing(50);
    hbox.setAlignment(Pos.CENTER);
    hbox.setStyle("-fx-padding:20");

    Group root = new Group();
    Scene scene = new Scene(root, 700, 250);
    root.getChildren().addAll(hbox);
    scene.getStylesheets().add(TabsDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());

    primaryStage.setTitle("JFX Tabs Demo");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example 16
Source File: RegexConfigFragment.java    From mdict-java with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("unchecked")
public RegexConfigFragment(PlainDictAppOptions _opt){
	super();
	tabPane = new TabPane();
	statusBar = new Text();
	tabPane.setPadding(new Insets(4,0,0,0));
	opt=_opt;

	bundle = ResourceBundle.getBundle("UIText", Locale.getDefault());

	Tab tab1 = new Tab();
	tab1.setText(bundle.getString(onegine));
	tab1.setTooltip(new Tooltip("词条、全文检索时,可选用正则引擎,或快速 .* 通配"));
	tab1.setClosable(false);
	Text lable = new Text("");
	lable.setStyle("-fx-fill: #ff0000;");
	tab1.setGraphic(lable);

	Tab tab2 = new Tab();
	tab2.setText(bundle.getString(findpage));
	tab2.setTooltip(new Tooltip("基于 Mark.js"));
	tab2.setClosable(false);
	Text lable1 = new Text("");
	lable1.setStyle("-fx-fill: #ff0000;");
	tab2.setGraphic(lable1);

	tabPane.getSelectionModel().selectedIndexProperty().addListener((observable, oldValue, newValue) -> {
		if(newValue.intValue()==1){
			if(tab2.getContent()==null)
				tab2.setContent(getSubpageContent());
		}
	});

	tabPane.setRotateGraphic(false);
	tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.SELECTED_TAB);
	tabPane.setSide(Side.TOP);
	tabPane.getTabs().addAll(tab1,tab2);
	tabPane.getStyleClass().add(TabPane.STYLE_CLASS_FLOATING);
	final String lvCss = HiddenSplitPaneApp.class.getResource("lvCss.css").toExternalForm();
	tabPane.getStylesheets().add(lvCss);

	tab1.setContent(getMainContent());

	VBox.setVgrow(tabPane, Priority.ALWAYS);

	getChildren().addAll(tabPane, statusBar);
}
 
Example 17
Source File: LibraryPanel.java    From Quelea with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Create a new library panel.
 */
public LibraryPanel() {
    LOGGER.log(Level.INFO, "Creating library panel");
    tabPane = new TabPane();

    LOGGER.log(Level.INFO, "Creating library song panel");
    songPanel = new LibrarySongPanel();
    Tab songTab = new Tab();
    songTab.setClosable(false);
    songTab.setText(LabelGrabber.INSTANCE.getLabel("library.songs.heading"));
    songTab.setContent(songPanel);
    tabPane.getTabs().add(songTab);

    LOGGER.log(Level.INFO, "Creating library bible panel");
    biblePanel = new LibraryBiblePanel();
    Tab bibleTab = new Tab();
    bibleTab.setClosable(false);
    bibleTab.setText(LabelGrabber.INSTANCE.getLabel("library.bible.heading"));
    bibleTab.setContent(biblePanel);
    tabPane.getTabs().add(bibleTab);

    LOGGER.log(Level.INFO, "Creating library image panel");
    imagePanel = new LibraryImagePanel();
    Tab imageTab = new Tab();
    imageTab.setClosable(false);
    imageTab.setText(LabelGrabber.INSTANCE.getLabel("library.image.heading"));
    imageTab.setContent(imagePanel);
    tabPane.getTabs().add(imageTab);

    if (QueleaProperties.get().getDisplayVideoTab()) {
        LOGGER.log(Level.INFO, "Creating library video panel");
        videoPanel = new LibraryVideoPanel();
        Tab videoTab = new Tab();
        videoTab.setClosable(false);
        videoTab.setText(LabelGrabber.INSTANCE.getLabel("library.video.heading"));
        videoTab.setContent(videoPanel);
        tabPane.getTabs().add(videoTab);
    }
    else {
        videoPanel = null;
    }

    LOGGER.log(Level.INFO, "Creating library timer panel");
    timerPanel = new LibraryTimerPanel();
    timerTab = new Tab();
    timerTab.setClosable(false);
    timerTab.setText(LabelGrabber.INSTANCE.getLabel("library.timer.heading"));
    timerTab.setContent(timerPanel);
    if (QueleaProperties.get().getTimerDir().listFiles() != null
            && QueleaProperties.get().getTimerDir().listFiles().length > 0) {
        tabPane.getTabs().add(timerTab);
    }

    VBox.setVgrow(tabPane, Priority.ALWAYS);
    getChildren().add(tabPane);
}
 
Example 18
Source File: CTabPane.java    From Open-Lowcode with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {

	this.tabpane = new TabPane();
	this.tabpane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE);
	for (int i = 0; i < elements.size(); i++) {
		Tab tab = new Tab();

		tab.setText(tabtitles.get(i));
		TabPane[] newtabarray = Arrays.copyOf(parenttabpanes, parenttabpanes.length + 1, TabPane[].class);
		newtabarray[parenttabpanes.length] = this.tabpane;
		Node node = elements.get(i).getNode(actionmanager, inputdata, parentwindow, newtabarray,nodetocollapsewhenactiontriggered);
		if (node instanceof Region) {
			Region region = (Region) node;
			region.setBorder(new Border(new BorderStroke(Color.LIGHTGRAY, Color.RED, Color.RED, Color.RED,
					BorderStrokeStyle.SOLID, BorderStrokeStyle.NONE, BorderStrokeStyle.NONE, BorderStrokeStyle.NONE,
					CornerRadii.EMPTY, new BorderWidths(1), Insets.EMPTY)));
			region.heightProperty().addListener(new ChangeListener<Number>() {

				@Override
				public void changed(
						ObservableValue<? extends Number> observable,
						Number oldValue,
						Number newValue) {
					double newheightfortabpane = newValue.doubleValue() + 20;
					double oldheight = tabpane.getHeight();
					if (newheightfortabpane > oldheight) {
						logger.severe("Setting min height to " + newValue.doubleValue() + 20 + ", current height = "
								+ tabpane.getHeight());
						tabpane.setMinHeight(newValue.doubleValue() + 20);
						tabpane.setPrefHeight(newValue.doubleValue() + 20);
						tabpane.setMaxHeight(newValue.doubleValue() + 20);
						region.requestLayout();
						if (tabpane.getParent() != null)
							tabpane.getParent().requestLayout();
						logger.severe("Finished layout stuff");
					}

				}

			});

		}
		tab.setContent(node);
		tabpane.getTabs().add(tab);

	}
	return tabpane;
}