本文整理汇总了Java中javafx.scene.control.Label.setGraphic方法的典型用法代码示例。如果您正苦于以下问题:Java Label.setGraphic方法的具体用法?Java Label.setGraphic怎么用?Java Label.setGraphic使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.control.Label
的用法示例。
在下文中一共展示了Label.setGraphic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ActionTextPane
import javafx.scene.control.Label; //导入方法依赖的package包/类
public ActionTextPane() {
actionText = new Label("Test");
graphic = new ImageView(new Image("assets/icons/editor_action_info_icon.png"));
actionText.setGraphic(graphic);
actionText.setTextFill(Utils.getDefaultTextColor());
actionText.setAlignment(Pos.CENTER);
actionText.setPadding(new Insets(0, 0, 0, 5));
getChildren().add(actionText);
setAlignment(Pos.CENTER);
ft = new FadeTransition(Duration.millis(500), graphic);
ft.setFromValue(1.0);
ft.setToValue(0.0);
ft.setAutoReverse(true);
ft.setCycleCount(4);
}
示例2: initProgressBarUI
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void initProgressBarUI() {
Label runLabel = new Label("Runs: ");
runLabel.setMinWidth(Region.USE_PREF_SIZE);
nRuns = new Text((int) progress + "/" + maxTestCount);
Label errorLabel = new Label("Errors: ");
errorLabel.setMinWidth(Region.USE_PREF_SIZE);
errorLabel.setGraphic(FXUIUtils.getIcon("error"));
errorLabel.setPadding(new Insets(0, 0, 0, 80));
errorText = new Text(errors + "");
Label failureLabel = new Label("Failures: ");
failureLabel.setMinWidth(Region.USE_PREF_SIZE);
failureLabel.setGraphic(FXUIUtils.getIcon("failure"));
failureLabel.setPadding(new Insets(0, 0, 0, 80));
failureText = new Text(failures + "");
progressBarString.setAlignment(Pos.CENTER);
progressBarString.setPadding(new Insets(5, 0, 5, 0));
progressBarString.getChildren().addAll(runLabel, nRuns, errorLabel, errorText, failureLabel, failureText);
}
示例3: GoogleEntryAttendeeItem
import javafx.scene.control.Label; //导入方法依赖的package包/类
public GoogleEntryAttendeeItem(EventAttendee attendee) {
this.attendee = Objects.requireNonNull(attendee);
optionalIcon = new Label();
optionalIcon.setOnMouseClicked(evt -> setOptional(!isOptional()));
optionalIcon.getStyleClass().add("button-icon");
optionalIcon.setTooltip(new Tooltip());
statusIcon = new Label();
name = new Label();
name.setMaxWidth(Double.MAX_VALUE);
setOptional(Boolean.TRUE.equals(attendee.getOptional()));
optionalProperty().addListener(obs -> updateIcon());
updateIcon();
removeButton = new Label();
removeButton.setGraphic(new FontAwesome().create(FontAwesome.Glyph.TRASH_ALT));
removeButton.getStyleClass().add("button-icon");
removeButton.setOnMouseClicked(evt -> removeAttendee(attendee));
HBox.setHgrow(optionalIcon, Priority.NEVER);
HBox.setHgrow(name, Priority.ALWAYS);
HBox.setHgrow(removeButton, Priority.NEVER);
getStyleClass().add("attendee-item");
getChildren().addAll(optionalIcon, statusIcon, name, removeButton);
ContextMenu menu = new ContextMenu();
MenuItem optionalItem = new MenuItem("Mark as optional");
optionalItem.setOnAction(evt -> setOptional(true));
MenuItem requiredItem = new MenuItem("Mark as required");
requiredItem.setOnAction(evt -> setOptional(false));
MenuItem removeItem = new MenuItem("Remove attendee");
removeItem.setOnAction(evt -> removeAttendee(attendee));
menu.getItems().addAll(optionalItem, requiredItem, new SeparatorMenuItem(), removeItem);
addEventHandler(CONTEXT_MENU_REQUESTED, evt -> menu.show(this, evt.getScreenX(), evt.getScreenY()));
}
示例4: getCountries
import javafx.scene.control.Label; //导入方法依赖的package包/类
public ObservableList<Label> getCountries(){
String[] locales = Locale.getISOCountries();
ObservableList<Label> countries = FXCollections.observableArrayList();
for (String countryCode : locales) {
Locale obj = new Locale("EN", countryCode);
Label country = new Label(obj.getDisplayCountry());
if (!obj.getCountry().toLowerCase().equals("an")){
Image icon = new Image("application/resources/icons/flags/4x3/"+obj.getCountry().toLowerCase()+".png");
country.setGraphic(new ImageView(icon));
countries.add(country);
// try {
// System.out.println("Country Currency "+Currency.getInstance(obj).getCurrencyCode());
// }catch (NullPointerException ex){
//// System.out.println("Country "+obj.getDisplayCountry());
// if (obj.getDisplayCountry().equals("Antarctica")){
// System.out.println("Country Currency EDD");
// }
//
// }
}
// System.out.println("Country Code = " + obj.getCountry()
// + ", Country Name = " + obj.getDisplayCountry());
}
return countries;
}
示例5: createPopoverContent
import javafx.scene.control.Label; //导入方法依赖的package包/类
/**
* Creates a <{@link Label} containing text and icon
*
* @param hovered
* - Use darker icon if mouse is hovered
* @return <{@link Label}
*/
private Label createPopoverContent(String msg, ImageView icon, Color textColor, int fontSize) {
Label label = new Label(msg);
label.setGraphic(icon);
label.setTextFill(textColor);
label.setFont(Font.font("SansSerif", fontSize));
label.setAlignment(javafx.geometry.Pos.CENTER);
label.setGraphicTextGap(15);
label.setContentDisplay(ContentDisplay.TOP);
return label;
}
示例6: createIconLabel
import javafx.scene.control.Label; //导入方法依赖的package包/类
public static Label createIconLabel(GlyphIcons icon, String iconSize, String text, ContentDisplay contentDisplay, Paint colour, String style)
{
Text iconLabel = GlyphsDude.createIcon(icon, iconSize);
iconLabel.setFill(colour);
Label label = new Label(text);
label.setTextFill(colour);
label.setStyle(style);
label.setGraphic(iconLabel);
label.setContentDisplay(contentDisplay);
return label;
}
示例7: GoogleEntryReminderItem
import javafx.scene.control.Label; //导入方法依赖的package包/类
private GoogleEntryReminderItem(GoogleEntryReminder reminder) {
this.reminder = requireNonNull(reminder);
methodCombo = new ComboBox<>();
methodCombo.getItems().setAll(RemindMethod.values());
methodCombo.disableProperty().bind(entry.getCalendar().readOnlyProperty());
methodCombo.valueProperty().bindBidirectional(reminder.methodProperty());
methodCombo.setConverter(new StringConverter<RemindMethod>() {
@Override
public String toString(RemindMethod object) {
return object.getName();
}
@Override
public RemindMethod fromString(String string) {
for (RemindMethod method : RemindMethod.values()) {
if (method.getName().equals(string)) {
return method;
}
}
return null;
}
});
Integer minutes = reminder.getMinutes();
TimeUnit unit = TimeUnit.MINUTES;
if (minutes != null) {
if (minutes % 1440 == 0) {
unit = TimeUnit.DAYS;
minutes = minutes / 1400;
} else if (minutes % 60 == 0) {
unit = TimeUnit.HOURS;
minutes = minutes / 60;
}
}
valueTxt = new TextField();
valueTxt.disableProperty().bind(entry.getCalendar().readOnlyProperty());
valueTxt.setPrefColumnCount(5);
valueTxt.setText(minutes == null ? "" : minutes.toString());
valueTxt.textProperty().addListener(obs -> updateMinutes());
unitCombo = new ComboBox<>();
unitCombo.getItems().setAll(TimeUnit.MINUTES, TimeUnit.HOURS, TimeUnit.DAYS);
unitCombo.disableProperty().bind(entry.getCalendar().readOnlyProperty());
unitCombo.setValue(unit);
unitCombo.valueProperty().addListener(obs -> updateMinutes());
removeIcon = new Label();
removeIcon.getStyleClass().add("button-icon");
removeIcon.setGraphic(new FontAwesome().create(FontAwesome.Glyph.TRASH_ALT));
removeIcon.setOnMouseClicked(evt -> removeReminder(reminder));
removeIcon.disableProperty().bind(entry.getCalendar().readOnlyProperty());
HBox.setHgrow(removeIcon, Priority.NEVER);
setAlignment(Pos.CENTER_LEFT);
getChildren().addAll(methodCombo, valueTxt, unitCombo, removeIcon);
getStyleClass().add("notification-item");
}
示例8: getActionPane
import javafx.scene.control.Label; //导入方法依赖的package包/类
private VBox getActionPane(){
progress= new Text("Office\nEntry Progress");
progress.setTextAlignment(TextAlignment.CENTER);
progress.setFont(Font.font("Times New Roman", 35));
lname= new Label("-Your Name here-");
Image iconf= new Image(Office_Entry.class.getResourceAsStream("/pic/finger.png"));
ImageView ivconf= new ImageView(iconf);
lpic= new Label();
lpic.setGraphic(ivconf);
Image img1= new Image(PersonalReports.class.getResourceAsStream("/pic/cross.png"));
ImageView imagvw= new ImageView(img1);
imagvw.setFitHeight(70);
imagvw.setFitWidth(70);
lnotexist= new Label("",imagvw);
lnotexist.setText("\n\n\n\n\nN/A");
lnotexist.setFont(Font.font("Cooper Black", 15));
lnotexist.setVisible(false);
txtfinger= new TextField();
txtfinger.setEditable(false);
txtfinger.setMaxWidth(160);
txtfinger.setStyle("-fx-background-radius:10; -fx-background-color:#9CD777;");
txtsearch= new TextField();
initFilter();
Button btnView= new Button("View Records");
Button btnCloseView= new Button("Hide Records");
Button btnadd= new Button("save");
btnadd.setOnAction(e -> {
setAddAttendance();
});
btnView.setOnAction(e -> {
timelineDown.play();
});
btnCloseView.setOnAction(e -> {
timelineUp.play();
});
VBox laywrong= new VBox();
laywrong.getChildren().addAll(lnotexist);
laywrong.setPadding(new Insets(0,0,0,0));
laywrong.setAlignment(Pos.CENTER);
HBox laytest= new HBox(5);
laytest.getChildren().addAll(txtfinger /* btnadd*/);
laytest.setAlignment(Pos.CENTER);
VBox laybtnsearch= new VBox();
laybtnsearch.getChildren().addAll(txtsearch);
laybtnsearch.setAlignment(Pos.CENTER);
laybtnsearch.setPadding(new Insets(20,0,0,0));
HBox laybtn= new HBox(5);
laybtn.getChildren().addAll(btnView, btnCloseView);
laybtn.setAlignment(Pos.CENTER);
VBox lay1= new VBox(10);
lay1.getChildren().addAll(progress, lpic, lname, laytest);
lay1.setAlignment(Pos.CENTER);
VBox layside= new VBox(25);
layside.getChildren().addAll(lay1, laybtn, laybtnsearch, laywrong);
layside.setAlignment(Pos.TOP_CENTER);
layside.setMinWidth(230);
layside.setPadding(new Insets(20,0,10,0));
return layside;
}
示例9: createBeforeActions
import javafx.scene.control.Label; //导入方法依赖的package包/类
@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: initGUI
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void initGUI() {
//Search facility
Label searchLabel = new Label();
Image dirImage = new Image("icon/ZOOM_IN.png");
searchLabel.setGraphic(new ImageView(dirImage));
keywordInput = new TextField("Type in search keyword...");
keywordInput.setPrefWidth(230);
//Add actionlistener
keywordInput.textProperty().addListener((observalbe, oldvalue, newvalue)->{
updateTreeView(newvalue.toUpperCase());
});
//Add focus listener
keywordInput.focusedProperty().addListener((observalbe, oldvalue, newvalue)->{
if (newvalue) {
if (getNodeLayerCount(currentSelectedNode) >= 2) {
keywordInput.setText("");
}
}
});
HBox hBox = new HBox();
hBox.setSpacing(5);
hBox.getChildren().addAll(searchLabel, keywordInput);
setTop(hBox);
treeView = new TreeView();
treeView.setMinWidth(200);;
treeView.setEditable(false);
treeView.setOnMouseClicked(onTreeItemClicked()); //<-Handle mouse click event
setCenter(treeView);
}
示例11: update
import javafx.scene.control.Label; //导入方法依赖的package包/类
private void update() {
if (!entries.isEmpty()) {
List<Entry<?>> workingList = new ArrayList<>(entries);
/*
* Individual calendars are already sorted, but now we are
* displaying entries from several calendars, so let's resort.
*/
Collections.sort(workingList);
for (Entry<?> entry : workingList) {
Calendar calendar = entry.getCalendar();
BorderPane borderPane = new BorderPane();
borderPane.getStyleClass().add("entry");
Label titleLabel = new Label(entry.getTitle());
BorderPane.setAlignment(titleLabel, Pos.CENTER_LEFT);
titleLabel.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
titleLabel.getStyleClass().add("title"); //$NON-NLS-1$
borderPane.setCenter(titleLabel);
Circle colorDot = new Circle();
colorDot.setRadius(2.5);
colorDot.getStyleClass().add(
calendar.getStyle() + "-icon-small"); //$NON-NLS-1$
titleLabel.setGraphic(colorDot);
Label timeLabel = new Label();
if (entry.isFullDay()) {
timeLabel.setText(Messages.getString("EntriesPane.FULL_DAY")); //$NON-NLS-1$
} else {
timeLabel.setText(DateTimeFormatter.ofLocalizedTime(
FormatStyle.SHORT).format(entry.getStartTime()));
}
borderPane.setRight(timeLabel);
timeLabel.getStyleClass().add("time"); //$NON-NLS-1$
BorderPane.setAlignment(timeLabel, Pos.CENTER_RIGHT);
getChildren().add(borderPane);
}
}
}
示例12: MonthEntryViewSkin
import javafx.scene.control.Label; //导入方法依赖的package包/类
public MonthEntryViewSkin(MonthEntryView view) {
super(view);
Entry<?> entry = view.getEntry();
if (entry.isRecurrence()) {
entry = entry.getRecurrenceSourceEntry();
}
Calendar calendar = entry.getCalendar();
colorDot = new Circle();
colorDot.setRadius(2.5);
colorDot.setMouseTransparent(true);
titleLabel = new Label();
titleLabel.setGraphic(colorDot);
titleLabel.setMinSize(0, 0);
titleLabel.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
titleLabel.setMouseTransparent(true);
timeLabel = new Label();
timeLabel.setMouseTransparent(true);
timeLabel.setMaxHeight(Double.MAX_VALUE);
timeLabel.setMouseTransparent(true);
// update in these cases
entry.titleProperty().addListener(weakUpdateViewListener);
entry.fullDayProperty().addListener(weakUpdateViewListener);
entry.intervalProperty().addListener(weakUpdateViewListener);
entry.calendarProperty().addListener(weakUpdateViewListener);
view.positionProperty().addListener(weakUpdateViewListener);
if (calendar != null) {
calendar.styleProperty().addListener(weakUpdateViewListener);
}
getChildren().addAll(titleLabel, timeLabel);
updateView();
}
示例13: SearchResultListViewCell
import javafx.scene.control.Label; //导入方法依赖的package包/类
public SearchResultListViewCell() {
setPrefWidth(0);
getStyleClass().add("search-result-cell"); //$NON-NLS-1$
colorCircle = new Circle();
colorCircle.setRadius(3.5);
titleLabel = new Label();
titleLabel.setMinWidth(0);
titleLabel.setGraphic(colorCircle);
titleLabel.getStyleClass().add("title-label"); //$NON-NLS-1$
dateLabel = new Label();
dateLabel.setMinWidth(0);
dateLabel.getStyleClass().add("date-label"); //$NON-NLS-1$
timeLabel = new Label();
timeLabel.setMinWidth(0);
timeLabel.getStyleClass().add("time-label"); //$NON-NLS-1$
BorderPane dateTimePane = new BorderPane();
dateTimePane.getStyleClass().add("date-time-pane");
dateTimePane.setLeft(dateLabel);
dateTimePane.setRight(timeLabel);
borderPane = new BorderPane();
borderPane.getStyleClass().add("container");
borderPane.setTop(titleLabel);
borderPane.setBottom(dateTimePane);
setGraphic(borderPane);
setContentDisplay(ContentDisplay.GRAPHIC_ONLY);
setOnMouseClicked(evt -> {
if (evt.getClickCount() == 2) {
Entry<?> entry = getItem();
if (entry != null) {
fireEvent(new RequestEvent(this, this, entry));
}
}
});
}
示例14: getActionPane
import javafx.scene.control.Label; //导入方法依赖的package包/类
private VBox getActionPane(){
progress= new Text("Gate\nEntry Progress");
progress.setTextAlignment(TextAlignment.CENTER);
progress.setFont(Font.font("Times New Roman", 35));
lname= new Label("-Your Name here-");
Image iconf= new Image(AllAttendance.class.getResourceAsStream("/pic/finger.png"));
ImageView ivconf= new ImageView(iconf);
lpic= new Label();
lpic.setGraphic(ivconf);
Image img1= new Image(PersonalReports.class.getResourceAsStream("/pic/cross.png"));
ImageView imagvw= new ImageView(img1);
imagvw.setFitHeight(70);
imagvw.setFitWidth(70);
lnotexist= new Label("",imagvw);
lnotexist.setText("\n\n\n\n\nN/A");
lnotexist.setFont(Font.font("Cooper Black", 15));
lnotexist.setVisible(false);
txtfinger= new TextField();
txtfinger.setEditable(false);
txtfinger.setMaxWidth(160);
txtfinger.setStyle("-fx-background-radius:10; -fx-background-color:#9CD777;");
txtsearch= new TextField();
initFilter();
Button btnadd= new Button("save");
btnadd.setOnAction(e -> {
setAddAttendance();
});
Button btnView= new Button("View Records");
Button btnCloseView= new Button("Hide Records");
btnView.setOnAction(e -> {
timelineDown.play();
});
btnCloseView.setOnAction(e -> {
timelineUp.play();
});
VBox laywrong= new VBox();
laywrong.getChildren().addAll(lnotexist);
laywrong.setPadding(new Insets(0,0,0,0));
laywrong.setAlignment(Pos.CENTER);
HBox laytest= new HBox(5);
laytest.getChildren().addAll(txtfinger /* btnadd*/);
laytest.setAlignment(Pos.CENTER);
//btnadd was beside txtfinger
VBox laybtnsearch= new VBox();
laybtnsearch.getChildren().addAll(txtsearch);
laybtnsearch.setAlignment(Pos.CENTER);
laybtnsearch.setPadding(new Insets(20,0,0,0));
HBox laybtn= new HBox(5);
laybtn.getChildren().addAll(btnView, btnCloseView);
laybtn.setAlignment(Pos.CENTER);
VBox lay1= new VBox(10);
lay1.getChildren().addAll(progress, lpic, lname, laytest);
lay1.setAlignment(Pos.CENTER);
VBox layside= new VBox(25);
layside.getChildren().addAll(lay1, laybtn, laybtnsearch, laywrong);
layside.setAlignment(Pos.TOP_CENTER);
layside.setMinWidth(230);
layside.setPadding(new Insets(20,0,10,0));
return layside;
}
示例15: createContent
import javafx.scene.control.Label; //导入方法依赖的package包/类
@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);
}