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

The following examples show how to use javafx.scene.control.Tab#setGraphic() . 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: ScriptingAspectEditor.java    From milkman with MIT License 6 votes vote down vote up
private Tab getTab(Supplier<String> getter, Consumer<String> setter, String title) {
	ContentEditor postEditor = new ContentEditor();
	postEditor.setEditable(true);
	postEditor.setContent(getter, setter);
	postEditor.setContentTypePlugins(Collections.singletonList(new JavascriptContentType()));
	postEditor.setContentType("application/javascript");
	postEditor.setHeaderVisibility(false);

	Tab postTab = new Tab("", postEditor);
	Label label = new Label(title);
	label.setRotate(90);
	label.setMinWidth(150);
	label.setMaxWidth(150);
	label.setMinHeight(40);
	label.setMaxHeight(40);
	label.setPadding(new Insets(0));
	postTab.setGraphic(label);
	return postTab;
}
 
Example 2
Source File: OptionsDialog.java    From milkman with MIT License 6 votes vote down vote up
public void showAndWait(List<OptionPageProvider> optionPageProviders) {
	JFXDialogLayout content = new OptionsDialogFxml(this);
	content.setPrefWidth(600);
	for(OptionPageProvider<?> p : optionPageProviders) {
		OptionDialogPane pane = p.getOptionsDialog(new OptionDialogBuilder());
		Tab tab = new Tab("", pane);
		Label label = new Label(pane.getName());
		label.setRotate(90);
		label.setMinWidth(100);
		label.setMaxWidth(100);
		label.setMinHeight(40);
		label.setMaxHeight(40);
		tab.setGraphic(label);
		tabs.getTabs().add(tab);
		
	}

	dialog = FxmlUtil.createDialog(content);
	
	dialog.showAndWait();
}
 
Example 3
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 4
Source File: WebBrowserController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
protected void manageBypass() {
    try {
        FXMLLoader fxmlLoader = new FXMLLoader(FxmlStage.class.getResource(
                CommonValues.SecurityCertificatesBypassFxml), AppVariables.currentBundle);
        Pane pane = fxmlLoader.load();
        Tab tab = new Tab(message("SSLVerificationBypassList"));
        ImageView tabImage = new ImageView("img/MyBox.png");
        tabImage.setFitWidth(20);
        tabImage.setFitHeight(20);
        tab.setGraphic(tabImage);
        tab.setContent(pane);
        tabPane.getTabs().add(tab);
        tabPane.getSelectionModel().select(tab);

    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
Example 5
Source File: WebBrowserController.java    From MyBox with Apache License 2.0 6 votes vote down vote up
@FXML
protected void manageHistories() {
    try {
        FXMLLoader fxmlLoader = new FXMLLoader(FxmlStage.class.getResource(
                CommonValues.WebBrowserHistoryFxml), AppVariables.currentBundle);
        Pane pane = fxmlLoader.load();
        Tab tab = new Tab(message("ManageHistories"));
        ImageView tabImage = new ImageView("img/MyBox.png");
        tabImage.setFitWidth(20);
        tabImage.setFitHeight(20);
        tab.setGraphic(tabImage);
        tab.setContent(pane);
        tabPane.getTabs().add(tab);
        tabPane.getSelectionModel().select(tab);

        WebBrowserHistoryController controller = (WebBrowserHistoryController) fxmlLoader.getController();
        controller.parent = this;

    } catch (Exception e) {
        logger.error(e.toString());
    }
}
 
Example 6
Source File: MPFConfigurationStage.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
private TabPane createTabPane() {
    tabPane = new TabPane();
    tabPane.setId("ConfigurationTabPane");
    tabPane.setTabClosingPolicy(TabClosingPolicy.UNAVAILABLE);
    layouts = mpfConfigurationInfo.getProperties(this);
    for (IPropertiesLayout layout : layouts) {
        String name = layout.getName();
        Node content = layout.getContent();
        content.getStyleClass().add(StyleClassHelper.BACKGROUND);
        Tab tab = new Tab(name, content);
        tab.setId(name);
        tab.setGraphic(layout.getIcon());
        tabPane.getTabs().add(tab);
    }
    VBox.setVgrow(tabPane, Priority.ALWAYS);
    return tabPane;
}
 
Example 7
Source File: FxDockTabPane.java    From FxDock with Apache License 2.0 6 votes vote down vote up
protected Tab newTab(Node nd)
{
	Node n = DockTools.prepareToAdd(nd);
		
	Tab t = new Tab(null, n);
	if(n instanceof FxDockPane)
	{
		FxDockPane p = (FxDockPane)n;
		t.setGraphic(p.titleField);
		t.setOnClosed((ev) -> 
		{
			Node pp = DockTools.getParent(this);
			DockTools.collapseEmptySpace(pp);
		});
	}
	return t;
}
 
Example 8
Source File: TabsRepresentation.java    From phoebus with Eclipse Public License 1.0 6 votes vote down vote up
private void addTabs(final List<TabItemProperty> added)
{
    for (TabItemProperty item : added)
    {
        final String name = item.name().getValue();
        final Pane content = new Pane();

        // 'Tab's are added with a Label as 'graphic'
        // because that label allows setting the font.

        // Quirk: Tabs will not show the label unless there's also a non-empty text
        final Tab tab = new Tab(" ", content);
        final Label label = new Label(name);
        tab.setGraphic(label);
        tab.setClosable(false); // !!
        tab.setUserData(item);

        final int index = jfx_node.getTabs().size();
        jfx_node.getTabs().add(tab);

        addChildren(index, item.children().getValue());

        item.name().addPropertyListener(tab_title_listener);
        item.children().addPropertyListener(tab_children_listener);
    }
}
 
Example 9
Source File: ViewportTabs.java    From Recaf with MIT License 6 votes vote down vote up
/**
 * @param resource
 * 		Resource containing the resource.
 * @param name
 * 		Name of resource to open.
 *
 * @return Viewport of the file.
 */
public FileViewport openFile(JavaResource resource, String name) {
	if(nameToTab.containsKey(name)) {
		return getFileViewport(name);
	}
	// Create new tab
	FileViewport view = new FileViewport(controller, resource, name);
	view.updateView();
	Tab tab = createTab(name, view);
	BorderPane wrap = new BorderPane(UiUtil.createFileGraphic(name));
	UiUtil.createFileGraphic(name).fitWidthProperty().bind(wrap.widthProperty());
	tab.setGraphic(wrap);
	// Setup context menu
	tab.setContextMenu(ContextBuilder.menu().view(view).ofFileTab());
	// Select and return
	select(tab);
	return view;
}
 
Example 10
Source File: ViewportTabs.java    From Recaf with MIT License 6 votes vote down vote up
/**
 * @param resource
 * 		Resource containing the class.
 * @param name
 * 		Name of class to open.
 *
 * @return Viewport of the class.
 */
public ClassViewport openClass(JavaResource resource, String name) {
	if(nameToTab.containsKey(name))
		return getClassViewport(name);
	// Create new tab
	ClassViewport view = new ClassViewport(controller, resource, name);
	view.updateView();
	Tab tab = createTab(name, view);
	int access = ClassUtil.getAccess(resource.getClasses().get(name));
	tab.setGraphic(UiUtil.createClassGraphic(access));
	// Setup context menu
	tab.setContextMenu(ContextBuilder.menu().view(view).ofClassTab());
	// Select & return
	select(tab);
	return view;
}
 
Example 11
Source File: IndexService.java    From xJavaFxTool-spring with Apache License 2.0 6 votes vote down vote up
/**
 * @Title: addWebView
 * @Description: 添加WebView视图
 */
public void addWebView(String title, String url, String iconPath) {
    WebView browser = new WebView();
    WebEngine webEngine = browser.getEngine();
    if (url.startsWith("http")) {
        webEngine.load(url);
    } else {
        webEngine.load(IndexController.class.getResource(url).toExternalForm());
    }
    if (indexController.getSingleWindowBootCheckBox().isSelected()) {
        JavaFxViewUtil.getNewStage(title, iconPath, new BorderPane(browser));
        return;
    }
    Tab tab = new Tab(title);
    if (StringUtils.isNotEmpty(iconPath)) {
        ImageView imageView = new ImageView(new Image(iconPath));
        imageView.setFitHeight(18);
        imageView.setFitWidth(18);
        tab.setGraphic(imageView);
    }
    tab.setContent(browser);
    indexController.getTabPaneMain().getTabs().add(tab);
    indexController.getTabPaneMain().getSelectionModel().select(tab);
}
 
Example 12
Source File: ContractRFXApp.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
private Tab createIconTab(Font iconFont, char icon, String text) {
    Tab tab = new Tab();
    Label iconLabel = new Label(String.valueOf(icon));
    iconLabel.setFont(iconFont);
    iconLabel.getStyleClass().add("icon-tab-icon");
    Label textLabel = new Label(text);
    textLabel.getStyleClass().add("icon-tab-label");
    VBox content = new VBox(iconLabel, textLabel);
    content.setAlignment(Pos.CENTER);
    content.getStyleClass().add("icon-tab-container");
    tab.setGraphic(content);
    tab.getStyleClass().add("icon-tab");
    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: PluginLoader.java    From xJavaFxTool-spring with Apache License 2.0 5 votes vote down vote up
public static void loadPluginAsTab(PluginJarInfo plugin, TabPane tabPane) {
    try {
        FXMLLoader generatingCodeFXMLLoader = new FXMLLoader(PluginLoader.class.getResource(plugin.getFxmlPath()));

        if (StringUtils.isNotEmpty(plugin.getBundleName())) {
            ResourceBundle resourceBundle = ResourceBundle.getBundle(plugin.getBundleName(), Config.defaultLocale);
            generatingCodeFXMLLoader.setResources(resourceBundle);
        }

        Tab tab = new Tab(plugin.getTitle());

        if (StringUtils.isNotEmpty(plugin.getIconPath())) {
            ImageView imageView = new ImageView(new Image(plugin.getIconPath()));
            imageView.setFitHeight(18);
            imageView.setFitWidth(18);
            tab.setGraphic(imageView);
        }

        tab.setContent(generatingCodeFXMLLoader.load());
        tabPane.getTabs().add(tab);
        tabPane.getSelectionModel().select(tab);

        tab.setOnCloseRequest(
            event -> JavaFxViewUtil.setControllerOnCloseRequest(generatingCodeFXMLLoader.getController(), event)
        );
    } catch (Exception e) {
        log.error("加载插件失败", e);
    }
}
 
Example 15
Source File: TabUtil.java    From jfxutils with Apache License 2.0 5 votes vote down vote up
/**
 * Helper method to create a new tab with the given label and make it draggable with {@link #makeDraggable}.
 */
public static Tab newDraggableTab( String label ) {
	Tab rr = new Tab();
	rr.setGraphic( new Label( label ) );
	makeDraggable( rr );
	return rr;
}
 
Example 16
Source File: TabDockingContainer.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private Tab newTab(Dockable dockable) {
    DockKey dockKey = dockable.getDockKey();
    Tab tab = new Tab(dockKey.getName(), dockable.getComponent());
    if (dockKey.getPolicy() == TabPolicy.NotClosable) {
        tab.setClosable(false);
    }
    if (dockKey.isCloseOptionsNeeded()) {
        MenuItem closeMenuItem = new MenuItem("Close");
        closeMenuItem.setOnAction((e) -> requestClose(tab));
        ContextMenu contextMenu = new ContextMenu(closeMenuItem);
        contextMenu.showingProperty().addListener((obs, wasShowing, isNowShowing) -> {
            if (isNowShowing) {
                populateMenuItems(contextMenu, tab);
            }
        });
        tab.setContextMenu(contextMenu);
    }
    dockKey.nameProperty().addListener((event, o, n) -> tab.setText(n));
    tab.setOnClosed((event) -> {
        remove(dockable);
    });
    tab.setGraphic(dockKey.getIcon());
    tab.setOnCloseRequest((event) -> {
        desktop.fireDockableStateWillChangeEvent(dockable, State.DOCKED, State.CLOSED, event);
    });
    return tab;
}
 
Example 17
Source File: WebBrowserController.java    From MyBox with Apache License 2.0 5 votes vote down vote up
protected WebBrowserBoxController newTabAction(String address, boolean focus) {
    try {
        FXMLLoader fxmlLoader = new FXMLLoader(FxmlStage.class.getResource(
                CommonValues.WebBrowserBoxFxml), AppVariables.currentBundle);
        Pane pane = fxmlLoader.load();
        Tab tab = new Tab();
        ImageView tabImage = new ImageView("img/MyBox.png");
        tabImage.setFitWidth(20);
        tabImage.setFitHeight(20);
        tab.setGraphic(tabImage);
        tab.setContent(pane);
        tabPane.getTabs().add(tab);
        if (focus) {
            tabPane.getSelectionModel().select(tab);
        }

        WebBrowserBoxController controller = (WebBrowserBoxController) fxmlLoader.getController();
        controller.parent = this;
        controller.tab = tab;
        tabControllers.put(tab, controller);
        tab.setOnClosed(new EventHandler<Event>() {
            @Override
            public void handle(Event event) {
                tabControllers.remove(tab);
            }
        });

        if (address != null) {
            controller.loadLink(address);
        }
        return controller;

    } catch (Exception e) {
        logger.error(e.toString());
        return null;
    }
}
 
Example 18
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 19
Source File: Perspective.java    From phoebus with Eclipse Public License 1.0 4 votes vote down vote up
public Perspective(final boolean minimal)
{
    property_panel = new PropertyPanel(model, plot.getPlot().getUndoableActionManager());
    properties_tab = new Tab(Messages.PropertiesTabName, property_panel);
    properties_tab.setGraphic(Activator.getIcon("properties"));
    properties_tab.setOnClosed(event ->
    {
        // Update pref that properties were last closed
        prefs.putBoolean(SHOW_PROPERTIES, false);
        autoMinimizeBottom();
    });

    if (! minimal)
    {
        // Check preferences
        if (prefs.getBoolean(SHOW_PROPERTIES, true))
            bottom_tabs.getTabs().setAll(properties_tab);
    }

    plot_and_tabs.setOrientation(Orientation.VERTICAL);
    plot_and_tabs.setDividerPositions(0.8);

    getItems().setAll(left_tabs, plot_and_tabs);
    setDividerPositions(0.2);

    createContextMenu();
    setupDrop();

    controller = new Controller(model, plot);
    try
    {
        controller.start();
    }
    catch (Exception ex)
    {
        logger.log(Level.SEVERE, "Cannot start data browser", ex);
    }

    // As pane is resized, assert that the minimzed left or bottom region stays minimized
    widthProperty().addListener(prop -> Platform.runLater(() -> autoMinimizeLeft()));
    heightProperty().addListener(prop -> Platform.runLater(() -> autoMinimizeBottom()));
}
 
Example 20
Source File: BowlerStudioController.java    From BowlerStudio with GNU General Public License v3.0 4 votes vote down vote up
public ScriptingFileWidget createFileTab(File file) {
	if (openFiles.get(file.getAbsolutePath()) != null && widgets.get(file.getAbsolutePath()) != null) {
		BowlerStudioModularFrame.getBowlerStudioModularFrame()
				.setSelectedTab(openFiles.get(file.getAbsolutePath()));
		return widgets.get(file.getAbsolutePath()).getScripting();
	}

	Tab fileTab = new Tab(file.getName());
	openFiles.put(file.getAbsolutePath(), fileTab);

	try {
		Log.warning("Loading local file from: " + file.getAbsolutePath());
		LocalFileScriptTab t = new LocalFileScriptTab(file);
		
		new Thread() {
			public void run() {
				BowlerStudioMenuWorkspace.add(t.getScripting().getGitRepo());
			}
		}.start();

		String key = t.getScripting().getGitRepo() + ":" + t.getScripting().getGitFile();
		ArrayList<String> files = new ArrayList<>();
		files.add(t.getScripting().getGitRepo());
		files.add(t.getScripting().getGitFile());
		if(key.length()>3 && files.get(0).length()>0 && files.get(1).length()>0)// catch degenerates
			ConfigurationDatabase.setObject("studio-open-git", key, files);

		fileTab.setContent(t);
		fileTab.setGraphic(
				AssetFactory.loadIcon("Script-Tab-" + ScriptingEngine.getShellType(file.getName()) + ".png"));

		addTab(fileTab, true);
		widgets.put(file.getAbsolutePath(), t);
		fileTab.setOnCloseRequest(event -> {
			widgets.remove(file.getAbsolutePath());
			openFiles.remove(file.getAbsolutePath());
			ConfigurationDatabase.removeObject("studio-open-git", key);
			t.getScripting().close();
			System.out.println("Closing " + file.getAbsolutePath());
		});

		t.setFontSize(size);
		return t.getScripting();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}