本文整理匯總了Java中javafx.scene.control.Label類的典型用法代碼示例。如果您正苦於以下問題:Java Label類的具體用法?Java Label怎麽用?Java Label使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Label類屬於javafx.scene.control包,在下文中一共展示了Label類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import javafx.scene.control.Label; //導入依賴的package包/類
public void start(Stage primaryStage, ScrollPane rootLayout) throws Exception {
primaryStage.setTitle("Change Hotkeys");
Scene myScene = new Scene(rootLayout);
ourStage = primaryStage;
myScene.addEventFilter(KeyEvent.KEY_PRESSED, new EventHandler<KeyEvent>() {
public void handle(KeyEvent event) {
if (changeHotkey) {
if (addHotkey(event, changeHotkeyFunction)) {
changeHotkey = false;
}
}
}
});
Label divider = new Label();
HBox labelHbox = new HBox(divider);
divider.setText("----These hotkeys are not changeable----");
labelHbox.setAlignment(Pos.CENTER);
for (String key : HOTKEYS) {
hotkeyVBox.getChildren().add(hotkeys.get(key).getHotkeyHBox());
}
hotkeyVBox.getChildren().add(labelHbox);
for (ImmutableHotkey hotkey : IMMUTABLE_HOTKEYS) {
hotkeyVBox.getChildren().add(hotkey.getHotkeyHBox());
}
primaryStage.setScene(myScene);
}
示例2: start
import javafx.scene.control.Label; //導入依賴的package包/類
@Override
public void start(Stage stage) {
Group root = new Group();
Scene scene = new Scene(root, 260, 80);
stage.setScene(scene);
stage.setTitle("Password Field Sample");
VBox vb = new VBox();
vb.setPadding(new Insets(10, 0, 0, 10));
vb.setSpacing(10);
HBox hb = new HBox();
hb.setSpacing(10);
hb.setAlignment(Pos.CENTER_LEFT);
Label label = new Label("Password");
final PasswordField pb = new PasswordField();
pb.setText("Your password");
pb.setOnAction((ActionEvent e) -> {
if (!pb.getText().equals("T2f$Ay!")) {
message.setText("Your password is incorrect!");
message.setTextFill(Color.rgb(210, 39, 30));
} else {
message.setText("Your password has been confirmed");
message.setTextFill(Color.rgb(21, 117, 84));
}
pb.clear();
});
hb.getChildren().addAll(label, pb);
vb.getChildren().addAll(hb, message);
scene.setRoot(vb);
stage.show();
}
示例3: start
import javafx.scene.control.Label; //導入依賴的package包/類
@Override
public void start(Stage stage) {
Group root = new Group();
Scene scene = new Scene(root, 300, 250);
stage.setScene(scene);
stage.setTitle("Progress Controls");
for (int i = 0; i < values.length; i++) {
final Label label = labels[i] = new Label();
label.setText("progress:" + values[i]);
final ProgressBar pb = pbs[i] = new ProgressBar();
pb.setProgress(values[i]);
final ProgressIndicator pin = pins[i] = new ProgressIndicator();
pin.setProgress(values[i]);
final HBox hb = hbs[i] = new HBox();
hb.setSpacing(5);
hb.setAlignment(Pos.CENTER);
hb.getChildren().addAll(label, pb, pin);
}
final VBox vb = new VBox();
vb.setSpacing(5);
vb.getChildren().addAll(hbs);
scene.setRoot(vb);
stage.show();
}
示例4: NotificationBarPane
import javafx.scene.control.Label; //導入依賴的package包/類
public NotificationBarPane(Node content) {
super(content);
progressBar = new ProgressBar();
label = new Label("infobar!");
bar = new HBox(label);
bar.setMinHeight(0.0);
bar.getStyleClass().add("info-bar");
bar.setFillHeight(true);
setBottom(bar);
// Figure out the height of the bar based on the CSS. Must wait until after we've been added to the parent node.
sceneProperty().addListener(o -> {
if (getParent() == null) return;
getParent().applyCss();
getParent().layout();
barHeight = bar.getHeight();
bar.setPrefHeight(0.0);
});
items = FXCollections.observableArrayList();
items.addListener((ListChangeListener<? super Item>) change -> {
config();
showOrHide();
});
}
示例5: aendereReihenfolge
import javafx.scene.control.Label; //導入依賴的package包/類
private void aendereReihenfolge(){
Stage stage = new Stage();
Label l = new Label("Reihenfolge festlegen:");
l.setStyle("-fx-text-fill: white");
l.setFont(Font.font(settingsFontSize));
l.setTranslateY(25);
l.setTranslateX(25);
TextField tf = new TextField(String.valueOf(orderId+1));
tf.setFont(Font.font(settingsFontSize-3));
tf.setTranslateX(25);
tf.setTranslateY(60);
Button b = new Button("Speichern");
b.setFont(Font.font(settingsFontSize));
b.setTranslateX(25);
b.setTranslateY(120);
b.setOnAction(e -> {
orderId = Integer.parseInt(tf.getText())-1;
stage.close();
Plugin_Gleisbelegung.sortiereGleiseListener();
});
Pane p = new Pane(l,tf,b);
p.setStyle("-fx-background-color: #303030");
p.setMinSize(500,200);
p.setMaxSize(500, 200);
Scene scene = new Scene(p, 300,200);
stage.setScene(scene);
stage.show();
stage.setAlwaysOnTop(true);
}
示例6: 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);
}
示例7: addServerUpdateListener
import javafx.scene.control.Label; //導入依賴的package包/類
private void addServerUpdateListener() {
serverTable.getSelectionModel().getSelectedCells().addListener((InvalidationListener) changed -> {
if (serverTable.getSelectionModel().getSelectedIndices().size() == 1) {
final SampServer selectedServer = serverTable.getSelectionModel().getSelectedItem();
if (Objects.nonNull(selectedServer)) {
updateServerInfo(selectedServer);
}
} else {
playerTable.getItems().clear();
playerTable.setPlaceholder(new Label());
serverAddress.setText("");
serverLagcomp.setText("");
serverPing.setText("");
serverPassword.setText("");
killServerLookupThreads();
}
});
}
示例8: FlowPaneSample
import javafx.scene.control.Label; //導入依賴的package包/類
public FlowPaneSample() {
super(400, 400);
FlowPane flowPane = new FlowPane(2, 4);
flowPane.setPrefWrapLength(200); //preferred wraplength
Label[] shortLabels = new Label[ITEMS];
Label[] longLabels = new Label[ITEMS];
ImageView[] imageViews = new ImageView[ITEMS];
for (int i = 0; i < ITEMS; i++) {
shortLabels[i] = new Label("Short label.");
longLabels[i] = new Label("I am a slightly longer label.");
imageViews[i] = new ImageView(ICON_48);
flowPane.getChildren().addAll(shortLabels[i], longLabels[i], imageViews[i]);
}
getChildren().add(flowPane);
}
示例9: init
import javafx.scene.control.Label; //導入依賴的package包/類
@Override
public void init(SensorThingsService service, Observation entity, GridPane gridProperties, Accordion accordionLinks, Label labelId, boolean editable) {
this.labelId = labelId;
this.entity = entity;
int i = 0;
textPhenomenonTime = addFieldTo(gridProperties, i, "PhenomenonTime", new TextField(), false, editable);
textResultTime = addFieldTo(gridProperties, ++i, "ResultTime", new TextField(), false, editable);
textResult = addFieldTo(gridProperties, ++i, "Result", new TextArea(), true, editable);
textResultQuality = addFieldTo(gridProperties, ++i, "ResultQuality", new TextField(), false, editable);
textValidTime = addFieldTo(gridProperties, ++i, "ValidTime", new TextField(), false, editable);
textParameters = addFieldTo(gridProperties, ++i, "Parameters", new TextArea(), true, editable);
if (accordionLinks != null) {
try {
accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getDatastream(), service.datastreams().query(), entity::setDatastream));
accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getMultiDatastream(), service.multiDatastreams().query(), entity::setMultiDatastream));
accordionLinks.getPanes().add(createEditableEntityPane(entity, entity.getFeatureOfInterest(), service.featuresOfInterest().query(), entity::setFeatureOfInterest));
} catch (IOException | ServiceFailureException ex) {
LOGGER.error("Failed to create panel.", ex);
}
}
}
示例10: createFXAAControl
import javafx.scene.control.Label; //導入依賴的package包/類
/**
* Create FXAA control.
*/
@FXThread
private void createFXAAControl(@NotNull final VBox root) {
final HBox container = new HBox();
container.setAlignment(Pos.CENTER_LEFT);
final Label label = new Label(Messages.SETTINGS_DIALOG_FXAA + ":");
fxaaFilterCheckBox = new CheckBox();
fxaaFilterCheckBox.selectedProperty().addListener((observable, oldValue, newValue) -> validate());
FXUtils.addToPane(label, container);
FXUtils.addToPane(fxaaFilterCheckBox, container);
FXUtils.addToPane(container, root);
FXUtils.addClassTo(label, CSSClasses.SETTINGS_DIALOG_LABEL);
FXUtils.addClassTo(fxaaFilterCheckBox, CSSClasses.SETTINGS_DIALOG_FIELD);
}
示例11: NotifyTab
import javafx.scene.control.Label; //導入依賴的package包/類
public NotifyTab()
{
super();
super.setText("Notification");
super.setClosable(false);
pane = new Pane();
box = new VBox();
header = new Label();
desc = new Label();
okButton = new Button("Ok");
okButton.setPrefWidth(50);
okButton.setOnMouseClicked(new OkButtonHandler());
box.getChildren().addAll(header, desc, okButton);
box.setPadding(new Insets(15, 15, 15, 15));
box.setSpacing(15);
pane.setPrefHeight(AppTabPane.CONTENT_HEIGHT);
pane.setPrefWidth(AppTabPane.CONTENT_WIDTH);
pane.getChildren().add(box);
super.setContent(pane);
}
示例12: addState
import javafx.scene.control.Label; //導入依賴的package包/類
private void addState(State<?,?> state, HBox line, Color color, int stateIndex, String stateDescription) {
final Rectangle rectangle = new Rectangle(WIDTH, WIDTH, color);
rectangle.setArcHeight(WIDTH);
rectangle.setArcWidth(WIDTH);
rectangle.setUserData(state);
Label text = new Label(computeStateLabel(stateIndex));
text.setTextOverrun(OverrunStyle.ELLIPSIS);
text.setAlignment(Pos.CENTER);
text.setMouseTransparent(true);
text.setTextFill(Color.WHITE);
text.setFont(STATE_FONT);
text.setMaxWidth(WIDTH);
final Tooltip tooltip = new Tooltip(stateDescription);
Tooltip.install(rectangle, tooltip);
StackPane layout = new StackPane();
StackPane.setMargin(rectangle, MARGIN_INSETS);
layout.getChildren().addAll(rectangle, text);
line.getChildren().add(layout);
}
示例13: onActionAddTerm
import javafx.scene.control.Label; //導入依賴的package包/類
public void onActionAddTerm(Term term) {
LoggerFacade.getDefault().debug(this.getClass(), "On action add [Term=" + term.getTitle() + "]"); // NOI18N
final boolean isTermAdded = this.isTermAdded(term);
if (!isTermAdded) {
final Label label = new Label(term.getTitle());
label.setUserData(term); // TODO tweak it - own component
fpTerms.getChildren().add(label);
if (fpTerms.getChildren().size() > 1) {
FXCollections.sort(fpTerms.getChildren(), TERM_COMPARATOR);
}
}
}
示例14: loadThreadMes
import javafx.scene.control.Label; //導入依賴的package包/類
public void loadThreadMes(Label lbl) {
Task tMes = new Task<Void>() {
DecimalFormat df = new DecimalFormat("#.00€");
@Override
protected Void call() throws Exception {
Platform.runLater(new Runnable() {
@Override
public void run() {
lbl.setText(df.format(mesatarja()) + "");
}
});
return null;
}
};
Thread mesT = new Thread(tMes);
mesT.setDaemon(true);
mesT.start();
}
示例15: search
import javafx.scene.control.Label; //導入依賴的package包/類
private void search()
{
if (currentSearch != null)
currentSearch.cancel(true);
currentSearch = CompletableFuture
.supplyAsync(() -> api.search("modpacks", txtSearch.getText(), 3), executor)
.thenAcceptAsync(result ->
{
packList.getChildren().clear();
if (!result.isEmpty())
result.stream().map(search ->
{
PackPreview preview = new PackPreview(search);
preview.setOnAction(event ->
{
txtSearch.getParent().requestFocus();
loadPack(search.slug);
});
return preview;
}).forEach(packList.getChildren()::add);
else
packList.getChildren().add(new Label("No results found."));
searchPopOver.show(txtSearch);
}, uiExecutor);
}