javafx.scene.control.Label#setGraphic ( )源码实例Demo

下面列出了javafx.scene.control.Label#setGraphic ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: pmd-designer   文件: ToolbarTitledPane.java
private Label buildErrorLabel() {
    Label errorLabel = new Label();

    errorLabel.getStyleClass().addAll("error-label");

    FontIcon errorIcon = new FontIcon("fas-exclamation-triangle");
    errorLabel.setGraphic(errorIcon);
    errorLabel.tooltipProperty().bind(
        errorMessage.map(message -> StringUtils.isBlank(message) ? null : new Tooltip(message))
    );
    errorLabel.textProperty().bind(errorType);
    errorLabel.visibleProperty().bind(errorMessage.map(StringUtils::isNotBlank));
    // makes the label zero-width when it's not visible
    errorLabel.managedProperty().bind(errorLabel.visibleProperty());

    return errorLabel;
}
 
源代码2 项目: iliasDownloaderTool   文件: CoursesTreeView.java
private void redraw() {
	if (node == null) {
		setGraphic(null);
		return;
	}

	final BorderPane pane = new BorderPane();
	final Label box = new Label();
	box.setAlignment(Pos.TOP_LEFT);

	if (node instanceof IliasFolder) {
		IliasFolder folder = (IliasFolder) node;
		box.setGraphic(folder.getGraphic());
	} else if (node instanceof IliasFile) {
		IliasFile file = (IliasFile) node;
		box.setGraphic(file.getGraphic());
	} else if (node instanceof IliasForum) {
		box.setGraphic(new ImageView("img/forum.png"));
	}

	box.setText(node.toString());
	pane.setLeft(box);
	createAndAddActions(pane);
	setGraphic(pane);
	createToolTip();
}
 
源代码3 项目: pdfsam   文件: DashboardTile.java
public DashboardTile(String title, String description, Node graphic) {
    getStyleClass().addAll("dashboard-modules-tile");
    Label titleLabel = new Label(title);
    titleLabel.getStyleClass().add("dashboard-modules-tile-title");
    if (nonNull(graphic)) {
        titleLabel.setGraphic(graphic);
    }
    Label textLabel = new Label(description);
    textLabel.getStyleClass().add("dashboard-modules-tile-text");
    textLabel.setMinHeight(USE_PREF_SIZE);
    VBox topTile = new VBox(5);
    topTile.getChildren().addAll(titleLabel, textLabel);

    button.getStyleClass().add("dashboard-modules-invisible-button");
    button.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);

    armed.bind(button.armedProperty());
    getChildren().addAll(new StackPane(topTile, button));
    setMaxHeight(USE_PREF_SIZE);
    setMinHeight(USE_PREF_SIZE);
}
 
源代码4 项目: gluon-samples   文件: BasicView.java
public BasicView() {
    
    Label label = new Label("Gluon - AWS Mobile Hub");

    Label signIn = new Label("Accesing signed view...");
    signIn.setGraphic(new Icon(MaterialDesignIcon.VPN_LOCK));
    
    VBox controls = new VBox(15.0, label, signIn);
    controls.setAlignment(Pos.CENTER);
    
    setCenter(controls);
    
    setOnShowing(e -> {
        if (! AWSService.getInstance().isSignedIn()) {
            getApplication().switchView(AwsMobileHub.SIGNED_OUT_VIEW);
        }
    });
}
 
源代码5 项目: Path-of-Leveling   文件: GemsPanel_Controller.java
public static ObservableList<Label> getMainGems(SocketGroup selected){
    ObservableList<Label> listG = FXCollections.observableArrayList();
    for(Gem g : selected.getGems()){
        if(!g.getGemName().equals("<empty group>")){
            Label l = new Label();
            Image img = g.getIcon();
            if(img!=null){
                l.setGraphic(new ImageView(img));
            }
            l.setText(g.getGemName().toString());
            listG.add(l);
        }
    }
    return listG;
}
 
public void generateLabel(){
    sgLabel = new Label();
    if(sg == null){
        sg = new SocketGroup(); //creating dummie
    }
    if(sg.getActiveGem()!=null){
      Image img = sg.getActiveGem().getSmallIcon(); 
      sgLabel.setGraphic(new ImageView(img));
      sgLabel.setText(sg.getActiveGem().getGemName());
    }else{
        sgLabel.setText("<empty group>");
    }      
}
 
源代码7 项目: pdfsam   文件: NotificationsController.java
private Label buildLabel(String message, NotificationType type) {
    Label textLabel = new Label(message);
    textLabel.getStyleClass().add("notification-text");
    if (type != null) {
        textLabel.getStyleClass().add(type.getStyleClass());
        textLabel.setGraphic(type.getGraphic());
    }
    return textLabel;
}
 
源代码8 项目: HubTurbo   文件: PickerAssignee.java
private Label getAssigneeLabelWithAvatar() {
    Label assignee = new Label(getLoginName());
    assignee.setGraphic(getAvatarImageView());
    FontLoader fontLoader = Toolkit.getToolkit().getFontLoader();
    double width = fontLoader.computeStringWidth(assignee.getText(), assignee.getFont());
    assignee.setPrefWidth(width + 35 + AVATAR_SIZE);
    assignee.setPrefHeight(LABEL_HEIGHT);
    assignee.getStyleClass().add("labels");
    assignee.setStyle("-fx-background-color: lightgreen;");
    return assignee;
}
 
源代码9 项目: jmonkeybuilder   文件: BaseAssetEditorDialog.java
@Override
@FxThread
protected void createBeforeActions(@NotNull final HBox container) {
    super.createBeforeActions(container);

    warningLabel = new Label();
    warningLabel.setGraphic(new ImageView(Icons.WARNING_24));
    warningLabel.setVisible(false);

    FXUtils.addClassTo(warningLabel, CssClasses.DIALOG_LABEL_WARNING);
    FXUtils.addToPane(warningLabel, container);
}
 
源代码10 项目: jace   文件: Utility.java
public static Optional<Label> loadIconLabel(String filename) {
    if (isHeadless) {
        return Optional.empty();
    }
    Image img = loadIcon(filename).get();
    Label label = new Label() {
        @Override
        public boolean equals(Object obj) {
            if (obj instanceof Label) {
                Label l2 = (Label) obj;
                return super.equals(l2) || l2.getText().equals(getText());
            } else {
                return super.equals(obj);
            }
        }

        @Override
        public int hashCode() {
            return getText().hashCode();
        }
    };
    label.setGraphic(new ImageView(img));
    label.setAlignment(Pos.CENTER);
    label.setContentDisplay(ContentDisplay.TOP);
    label.setTextFill(Color.WHITE);
    DropShadow shadow = new DropShadow(5.0, Color.BLACK);
    label.setEffect(shadow);
    return Optional.of(label);
}
 
源代码11 项目: gluon-samples   文件: CommitDescriptionTableCell.java
private Label makeRefLabel(GitRef ref) {
    Label refLabel = new Label(ref.getShortName());
    refLabel.setGraphic(UITools.getRefIcon(ref));
    if (ref instanceof GitTag) {
        refLabel.getStyleClass().add("tag-ref");
    } else if (ref instanceof GitBranch) {
        refLabel.getStyleClass().add("branch-ref");
    } else {
        refLabel.getStyleClass().add("unknown-ref");
    }
    return refLabel;
}
 
源代码12 项目: bisq   文件: FormBuilder.java
public static Text getIconForLabel(GlyphIcons icon, String iconSize, Label label, String style) {
    if (icon.fontFamily().equals(MATERIAL_DESIGN_ICONS)) {
        final Text textIcon = MaterialDesignIconFactory.get().createIcon(icon, iconSize);
        textIcon.setOpacity(0.7);
        if (style != null) {
            textIcon.getStyleClass().add(style);
        }
        label.setContentDisplay(ContentDisplay.LEFT);
        label.setGraphic(textIcon);
        return textIcon;
    } else {
        throw new IllegalArgumentException("Not supported icon type");
    }
}
 
源代码13 项目: milkman   文件: FxmlBuilder.java
public static Label label(Node graphic) {
	Label lbl = new Label();
	lbl.setGraphic(graphic);
	return lbl;
}
 
源代码14 项目: AsciidocFX   文件: LabelBuilt.java
public static LabelBuilt icon(Ikon ikon, double minSize) {
    Label iconLabel = new Label();
    iconLabel.setGraphic(new FontIcon(ikon));
    iconLabel.setMinWidth(minSize);
    return new LabelBuilt(iconLabel);
}
 
源代码15 项目: Path-of-Leveling   文件: Gem.java
public Label getLabel(){
    cachedLabel = new Label();
    cachedLabel.setText(name);
    cachedLabel.setGraphic(new ImageView(gemIcon));
    return cachedLabel;
}
 
源代码16 项目: jmonkeybuilder   文件: AboutDialog.java
@Override
@FxThread
protected void createContent(@NotNull final VBox root) {
    super.createContent(root);

    final JfxApplication application = JfxApplication.getInstance();
    final HostServices hostServices = application.getHostServices();

    final GridPane gridPane = new GridPane();

    final Label applicationLabel = new Label(Config.TITLE);
    applicationLabel.setGraphic(new ImageView(Icons.APPLICATION_64));

    final Label versionLabel = new Label(Messages.ABOUT_DIALOG_VERSION + ":");
    versionLabel.prefWidthProperty().bind(gridPane.widthProperty().multiply(0.5));

    final Label versionField = new Label(Config.STRING_VERSION);

    final Label projectHomeLabel = new Label(Messages.ABOUT_DIALOG_PROJECT_HOME + ":");

    final Hyperlink projectHomeField = new Hyperlink("bitbucket.org");
    projectHomeField.setOnAction(event -> hostServices.showDocument(PROJECT_HOME));
    projectHomeField.setFocusTraversable(false);

    final Label forumThreadLabel = new Label(Messages.ABOUT_DIALOG_FORUM_THREAD + ":");

    final Hyperlink forumThreadField = new Hyperlink("hub.jmonkeyengine.org");
    forumThreadField.setOnAction(event -> hostServices.showDocument(FORUM_THREAD));
    forumThreadField.setFocusTraversable(false);

    final Label usedLibrariesLabel = new Label(Messages.ABOUT_DIALOG_USED_LIBRARIES + ":");
    usedLibrariesLabel.prefWidthProperty().bind(gridPane.widthProperty());

    final Label usedIcons = new Label(Messages.ABOUT_DIALOG_USED_ICONS + ":");
    usedIcons.prefWidthProperty().bind(gridPane.widthProperty());

    final TextArea librariesArea = new TextArea(LIBRARIES);
    librariesArea.setEditable(false);
    librariesArea.setFocusTraversable(false);

    final TextArea iconsArea = new TextArea(ICONS);
    iconsArea.setEditable(false);
    iconsArea.setFocusTraversable(false);

    gridPane.add(applicationLabel, 0, 0, 2, 1);
    gridPane.add(versionLabel, 0, 1, 1, 1);
    gridPane.add(versionField, 1, 1, 1, 1);
    gridPane.add(projectHomeLabel, 0, 2, 1, 1);
    gridPane.add(projectHomeField, 1, 2, 1, 1);
    gridPane.add(forumThreadLabel, 0, 3, 1, 1);
    gridPane.add(forumThreadField, 1, 3, 1, 1);
    gridPane.add(usedLibrariesLabel, 0, 4, 2, 1);
    gridPane.add(librariesArea, 0, 5, 2, 1);
    gridPane.add(usedIcons, 0, 6, 2, 1);
    gridPane.add(iconsArea, 0, 7, 2, 1);

    FXUtils.addToPane(gridPane, root);

    FXUtils.addClassTo(root, CssClasses.ABOUT_DIALOG);
    FXUtils.addClassTo(gridPane, CssClasses.DEF_GRID_PANE);
    FXUtils.addClassTo(usedLibrariesLabel, usedIcons, CssClasses.ABOUT_DIALOG_LONG_LABEL);
    FXUtils.addClassesTo(versionLabel, projectHomeLabel, forumThreadLabel, usedLibrariesLabel, usedIcons,
            versionField, projectHomeField, forumThreadField, CssClasses.SPECIAL_FONT_16);
    FXUtils.addClassTo(applicationLabel, CssClasses.ABOUT_DIALOG_TITLE_LABEL);
}
 
源代码17 项目: helloiot   文件: MainNode.java
public void construct(List<UnitPage> appunitpages) {
    
    appunitpage.subscribeStatus(messagePageHandler);
    appbeeper.subscribeStatus(beeper.getMessageHandler());
    appbuzzer.subscribeStatus(buzzer.getMessageHandler());
    systime.subscribeStatus(timeindicator.getMessageHandler());

    // Add configured unitpages.
    for (UnitPage up : appunitpages) {
        this.addUnitPage(up);
    }

    //Init unit nodes
    for (Unit u : app.getUnits()) {
        Node n = u.getNode();
        if (n != null) {
            UnitPage unitpage = buildUnitPage(UnitPage.getPage(n));
            unitpage.addUnitNode(n);
        }
    }

    // Build listpages based on unitpages
    List<UnitPage> sortedunitpages = new ArrayList<>();
    sortedunitpages.addAll(unitpages.values());
    Collections.sort(sortedunitpages);
    firstmenupage = null;
    for (UnitPage value : sortedunitpages) {
        value.buildNode();
        if (!value.isSystem() && !value.isEmpty() && (value.getName() == null || !value.getName().startsWith("."))) {
            Label l = new Label();
            l.setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
            l.setAlignment(Pos.CENTER);
            l.setGraphic(value.getGraphic());
            l.setPrefSize(45.0, 40.0);                
            Button buttonmenu = new Button(value.getText(), l);
            buttonmenu.getStyleClass().add("menubutton");
            buttonmenu.setAlignment(Pos.BASELINE_LEFT);
            buttonmenu.setMaxWidth(Double.MAX_VALUE);
            buttonmenu.setFocusTraversable(false);
            buttonmenu.setMnemonicParsing(false);
            buttonmenu.setOnAction(e -> {
                appunitpage.sendStatus(value.getName());              
            });
            menupages.getChildren().add(buttonmenu); // Last button is disconnect button
            if (firstmenupage == null) {
                firstmenupage = value.getName();
            }
        }
    }
    
    // Add backbutton
    if (backbutton != null && backbutton.isVisible()) {
        menupages.getChildren().add(new Separator(Orientation.HORIZONTAL));
        menupages.getChildren().add(backbutton);
    }
    
    gotoPage("start");

    // Remove menubutton if 0 or 1 visible page.
    menubutton.setVisible(!menupages.getChildren().isEmpty());
}
 
源代码18 项目: FxDock   文件: FX.java
/** creates a label.  accepts: CssStyle, CssID, FxCtl, Insets, OverrunStyle, Pos, TextAlignment, Color, Node, Background */
public static Label label(Object ... attrs)
{
	Label n = new Label();
	
	for(Object a: attrs)
	{
		if(a == null)
		{
			// ignore
		}
		else if(a instanceof CssStyle)
		{
			n.getStyleClass().add(((CssStyle)a).getName());
		}
		else if(a instanceof CssID)
		{
			n.setId(((CssID)a).getID());
		}
		else if(a instanceof FxCtl)
		{
			switch((FxCtl)a)
			{
			case BOLD:
				n.getStyleClass().add(CssTools.BOLD.getName());
				break;
			case FOCUSABLE:
				n.setFocusTraversable(true);
				break;
			case FORCE_MAX_WIDTH:
				n.setMaxWidth(Double.MAX_VALUE);
				break;
			case FORCE_MIN_HEIGHT:
				n.setMinHeight(Control.USE_PREF_SIZE);
				break;
			case FORCE_MIN_WIDTH:
				n.setMinWidth(Control.USE_PREF_SIZE);
				break;
			case NON_FOCUSABLE:
				n.setFocusTraversable(false);
				break;
			case WRAP_TEXT:
				n.setWrapText(true);
				break;
			default:
				throw new Error("?" + a);
			}
		}
		else if(a instanceof Insets)
		{
			n.setPadding((Insets)a);
		}
		else if(a instanceof OverrunStyle)
		{
			n.setTextOverrun((OverrunStyle)a);
		}
		else if(a instanceof Pos)
		{
			n.setAlignment((Pos)a);
		}
		else if(a instanceof String)
		{
			n.setText((String)a);
		}
		else if(a instanceof TextAlignment)
		{
			n.setTextAlignment((TextAlignment)a);
		}
		else if(a instanceof Color)
		{
			n.setTextFill((Color)a);
		}
		else if(a instanceof StringProperty)
		{
			n.textProperty().bind((StringProperty)a);
		}
		else if(a instanceof Node)
		{
			n.setGraphic((Node)a);
		}
		else if(a instanceof Background)
		{
			n.setBackground((Background)a);
		}
		else
		{
			throw new Error("?" + a);
		}			
	}
	
	return n;
}
 
源代码19 项目: CPUSim   文件: LineNumAndBreakpointFactory.java
@Override
public Node apply(int idx) {
    Label label = new Label();
    Paragraph paragraph = area.getParagraphs().get(idx);
    boolean breakPoint = getAllBreakPointLineNumbers().contains(idx);
    Circle icon = new Circle(4, breakPoint ? Color.RED : Color.web("#eee")); //
    // same color as background and so invisible
    label.setGraphic(icon);
    label.getStyleClass().add("lineno");
    label.getStylesheets().add(stylesheet);

    // add a listener to the Label so that clicks in it cause the breakpoint
    // circle to toggle on and off
    label.setOnMouseClicked(event -> {
        Circle circle = (Circle) label.getGraphic();
        if (breakPoints.removeIf(x -> x == paragraph)) {
            // if the paragraph was already a breakpoint, remove it and its circle
            circle.setFill(Color.web("#eee"));
        }
        else {
            breakPoints.add(paragraph);
            circle.setFill(Color.RED);
        }
    });

    // When the format changes, for example when line numbers are shown or hidden,
    // redraw the label's text
    format.addListener((observable, oldValue, newValue) -> {
        label.setText(formatTheLineNumber(idx + 1, area.getParagraphs().size()));
    });

    // When code stops due to a break point, change the background to orange
    // instead of light grey
    currentBreakPointLineNumber.addListener((observable, oldValue, newValue) -> {
        if ((int) newValue == idx) { // break at given line
            label.setBackground(new Background(new BackgroundFill(Color.ORANGE,
                    CornerRadii.EMPTY, Insets.EMPTY)));
        }
        else if ((int) oldValue == idx) { // resumed after breaking at given line
            label.setBackground(new Background(new BackgroundFill(Color.web("#eee")
                    , CornerRadii.EMPTY, Insets.EMPTY)));
        }
    });

    // when a paragraph is removed from the text area, be sure the
    // paragraph is removed from the set of breakpoints
    area.getParagraphs().addListener((ListChangeListener<Paragraph<?>>) c -> {
        if (indexOfUsingIdentity(breakPoints, paragraph) == -1) {
            breakPoints.removeIf(x -> x == paragraph);
        }
        //we can't just say breakPoints.remove(paragraph) because we need
        //to compare paragraphs withh ==, not Paragraph.equals()
    });

    // reformat the line numbers when the number of lines changes.
    // When removed from the scene, stay subscribed to never(), which is
    // a fake subscription that consumes no resources, instead of staying
    // subscribed to area's paragraphs.
    EventStreams.valuesOf(label.sceneProperty()).flatMap(scene -> scene != null ?
            nParagraphs.map(n -> formatTheLineNumber(idx + 1, n)) : EventStreams
            .<String>never()).feedTo(label.textProperty());
    return label;
}
 
源代码20 项目: ShootOFF   文件: CanvasManager.java
public Label addDiagnosticMessage(final String message, final long chimeDelay, final Color backgroundColor) {
	final Label diagnosticLabel = new Label(message);
	diagnosticLabel.setStyle("-fx-background-color: " + colorToWebCode(backgroundColor));

	final ImageView muteView = new ImageView();
	muteView.setFitHeight(20);
	muteView.setFitWidth(muteView.getFitHeight());
	if (config.isChimeMuted(message)) {
		muteView.setImage(muteImage);
	} else {
		muteView.setImage(soundImage);
	}

	diagnosticLabel.setContentDisplay(ContentDisplay.RIGHT);
	diagnosticLabel.setGraphic(muteView);
	diagnosticLabel.setOnMouseClicked((event) -> {
		if (config.isChimeMuted(message)) {
			muteView.setImage(soundImage);
			config.unmuteMessageChime(message);
		} else {
			muteView.setImage(muteImage);
			config.muteMessageChime(message);
		}

		try {
			config.writeConfigurationFile();
		} catch (final Exception e) {
			logger.error("Failed persisting message's (" + message + ") chime mute settings.", e);
		}
	});

	Platform.runLater(() -> diagnosticsVBox.getChildren().add(diagnosticLabel));

	if (chimeDelay > 0 && !config.isChimeMuted(message) && !diagnosticExecutorService.isShutdown()) {
		@SuppressWarnings("unchecked")
		final ScheduledFuture<Void> chimeFuture = (ScheduledFuture<Void>) diagnosticExecutorService.schedule(
				() -> TrainingExerciseBase.playSound("sounds/chime.wav"), chimeDelay, TimeUnit.MILLISECONDS);
		diagnosticFutures.put(diagnosticLabel, chimeFuture);
	}

	return diagnosticLabel;
}