本文整理了Java中javafx.scene.control.Button
类的一些代码示例,展示了Button
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Button
类的具体详情如下:
包路径:javafx.scene.control.Button
类名称:Button
暂无
代码示例来源:origin: pmd/pmd
Stage stage = new Stage();
try {
stage.setScene(new Scene(fxmlLoader.load()));
} catch (IOException e) {
e.printStackTrace();
stage.setTitle("Auxilliary classpath setup");
stage.initOwner(parentStage);
stage.initModality(Modality.WINDOW_MODAL);
setClassPathButton.setOnAction(e -> {
stage.close();
onApply.accept(fileListView.getItems());
});
cancelButton.setOnAction(e -> stage.close());
stage.show();
代码示例来源:origin: jfoenixadmin/JFoenix
@Override
public void start(Stage stage) {
FlowPane main = new FlowPane();
main.setVgap(20);
main.setHgap(20);
main.getChildren().add(new Button("Java Button"));
JFXButton jfoenixButton = new JFXButton("JFoenix Button");
main.getChildren().add(jfoenixButton);
JFXButton button = new JFXButton("RAISED BUTTON");
button.getStyleClass().add("button-raised");
main.getChildren().add(button);
JFXButton button1 = new JFXButton("DISABLED");
button1.setDisable(true);
main.getChildren().add(button1);
StackPane pane = new StackPane();
pane.getChildren().add(main);
StackPane.setMargin(main, new Insets(100));
pane.setStyle("-fx-background-color:WHITE");
final Scene scene = new Scene(pane, 800, 200);
scene.getStylesheets().add(ButtonDemo.class.getResource("/css/jfoenix-components.css").toExternalForm());
stage.setTitle("JFX Button Demo");
stage.setScene(scene);
stage.show();
}
代码示例来源:origin: torakiki/pdfsam
private Button buildButton(String text, boolean response) {
Button button = new Button(text);
button.getStyleClass().addAll(Style.BUTTON.css());
button.setOnAction(e -> {
this.response = response;
hide();
});
return button;
}
代码示例来源:origin: speedment/speedment
@Override
public Button createNode() {
final Button btn = new Button(text, icon.view());
btn.setTextAlignment(TextAlignment.CENTER);
btn.setAlignment(Pos.CENTER);
btn.setMnemonicParsing(false);
btn.setLayoutX(10);
btn.setLayoutY(10);
btn.setPadding(new Insets(8, 12, 8, 12));
btn.setOnAction(handler);
btn.setTooltip(new Tooltip(tooltip));
return btn;
}
}
代码示例来源:origin: speedment/speedment
private Button addButton(final ListView<String> listView) {
final Button button = new Button("Add Item", FontAwesome.PLUS.view());
button.setOnAction(e -> {
final int newIndex = listView.getItems().size();
final Set<String> set = new HashSet<>(strings);
final AtomicInteger i = new AtomicInteger(0);
while (!set.add(DEFAULT_FIELD + i.incrementAndGet())) {}
listView.getItems().add(DEFAULT_FIELD + i.get());
listView.scrollTo(newIndex);
listView.getSelectionModel().select(newIndex);
// There is a strange behavior in JavaFX if you try to start editing
// a field on the same animation frame as another field lost focus.
// Therefore, we wait one animation cycle before setting the field
// into the editing state
runLater(() -> listView.edit(newIndex));
});
return button;
}
代码示例来源:origin: pmd/pmd
@Override
public void initialize(URL location, ResourceBundle resources) {
BooleanBinding noSelection = fileListView.getSelectionModel().selectedItemProperty().isNull();
removeFileButton.disableProperty().bind(noSelection);
moveItemUpButton.disableProperty().bind(noSelection.or(fileListView.getSelectionModel().selectedIndexProperty().isEqualTo(0)));
// we can't just map the val because we need an ObservableNumberValue
IntegerBinding lastIndexBinding = Bindings.createIntegerBinding(() -> fileListView.getItems().size() - 1,
Val.wrap(fileListView.itemsProperty()).flatMap(LiveList::sizeOf));
moveItemDownButton.disableProperty().bind(noSelection.or(fileListView.getSelectionModel().selectedIndexProperty().isEqualTo(lastIndexBinding)));
fileListView.setCellFactory(DesignerUtil.simpleListCellFactory(File::getName, File::getAbsolutePath));
selectFilesButton.setOnAction(e -> onSelectFileClicked());
removeFileButton.setOnAction(e -> onRemoveFileClicked());
moveItemUpButton.setOnAction(e -> moveUp());
moveItemDownButton.setOnAction(e -> moveDown());
}
代码示例来源:origin: org.netbeans.html/net.java.html.boot.fx
@Override
public void handle(WebEvent<String> t) {
final Stage dialogStage = new Stage();
dialogStage.initModality(Modality.WINDOW_MODAL);
dialogStage.initOwner(owner);
ResourceBundle r = ResourceBundle.getBundle("org/netbeans/html/boot/fx/Bundle"); // NOI18N
dialogStage.setTitle(r.getString("AlertTitle")); // NOI18N
final Button button = new Button(r.getString("AlertCloseButton")); // NOI18N
final Text text = new Text(t.getData());
VBox box = new VBox();
box.setAlignment(Pos.CENTER);
box.setSpacing(10);
box.setPadding(new Insets(10));
box.getChildren().addAll(text, button);
dialogStage.setScene(new Scene(box));
button.setCancelButton(true);
button.setOnAction(new CloseDialogHandler(dialogStage, null));
dialogStage.centerOnScreen();
dialogStage.showAndWait();
}
});
代码示例来源:origin: com.cedarsoft.commons/javafx
Button randomButton = new Button("Random!");
randomButton.setOnAction(evt -> integerProperty.set((int) (8000 * Math.random())));
vBox.getChildren().add(randomButton);
vBox.getChildren().add(hBox4);
primaryStage.setScene(new Scene(vBox));
primaryStage.show();
代码示例来源:origin: pmd/pmd
item.setOnAction(e -> {
try {
Stage popup = new Stage();
FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("generate-xpath-from-stack-trace.fxml"));
Parent root = loader.load();
button.disableProperty().bind(validation.invalidProperty());
button.setOnAction(f -> {
DesignerUtil.stackTraceToXPath(area.getText()).ifPresent(xpathExpressionArea::replaceText);
popup.close();
});
popup.setScene(new Scene(root));
popup.initStyle(StageStyle.UTILITY);
popup.initModality(Modality.WINDOW_MODAL);
代码示例来源:origin: net.sf.gluebooster.java.booster/gb-basic
@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("Hello World!");
Button btn = new Button();
btn.setText("Say 'Hello World'");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.out.println("Hello World!");
}
});
StackPane root = new StackPane();
root.getChildren().add(btn);
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
}
}
代码示例来源:origin: com.gluonhq/charm-down-desktop
scanStage = new Stage();
scanButton = new Button("scan");
stackPane.getChildren().add(vbox);
scanStage.setScene(new Scene(stackPane, 384, 256));
scanStage.close();
};
scanText.setOnAction(action);
scanButton.setOnAction(action);
scanStage.show();
代码示例来源:origin: stackoverflow.com
);
final Button button = new Button("I love you", imageView);
button.setStyle("-fx-base: coral;");
button.setContentDisplay(ContentDisplay.TOP);
button.setOnAction(new EventHandler<ActionEvent>() {
@Override public void handle(ActionEvent event) {
response.setText("I love you too!");
layout.getChildren().addAll(button, response);
layout.setStyle("-fx-background-color: cornsilk; -fx-padding: 10; -fx-font-size: 20;");
stage.setScene(new Scene(layout));
stage.show();
代码示例来源:origin: stackoverflow.com
@Override
public void start(Stage primaryStage) {
// Get the pane for the scene
primaryStage.setScene(new Scene(getPane(), 180, 600));
// Setup the stage
primaryStage.setTitle("Elevator Buttons");
primaryStage.setResizable(false);
primaryStage.show();
}
protected Pane getPane() {
Pane pane = new VBox(10);
pane.setPadding(new Insets(40));
GridPane grid = new GridPane();
for (int i = 0; i < row; i++) {
for (int k = 0; k < col; k++) {
// Set the button number as text for the button
Button button = new Button(Integer.toString((row * col - 2 * i - 1) + k));
button.setPrefWidth(100);
button.setStyle("-fx-font: 22 arial; -fx-base: LightGray");
// Add the button to the pane and set the handler
grid.add(button, k, i);
button.setOnAction(buttonHandler);
}
}
return grid;
}
代码示例来源:origin: stackoverflow.com
callButton.setOnAction(e -> System.out.println("clicked1")); // not working
callButton.addEventHandler(MouseEvent.MOUSE_ENTERED, e -> System.out.println("entered"));
callButton.addEventHandler(MouseEvent.MOUSE_CLICKED, e -> System.out.println("clicked")); // not working
chatButton.setOnAction(e -> System.out.println("clicked2")); // not working
callIconBox.getChildren().addAll(callButton, chatButton);
stage.setScene(new Scene(callIconBox));
stage.show();
代码示例来源:origin: torakiki/pdfsam
public ClosePane(EventHandler<ActionEvent> handler) {
setAlignment(Pos.CENTER_RIGHT);
getStyleClass().addAll(Style.CONTAINER.css());
Button closeButton = new Button(DefaultI18nContext.getInstance().i18n("Close"));
closeButton.getStyleClass().addAll(Style.BUTTON.css());
closeButton.setTextAlignment(TextAlignment.CENTER);
closeButton.setOnAction(ofNullable(handler).orElse(defaultHandler));
getChildren().add(closeButton);
}
}
代码示例来源:origin: jfoenixadmin/JFoenix
closeButton.getStyleClass().add("tab-close-button");
closeButton.setOnAction(action->{
TabPaneBehavior behavior = getBehavior();
if (behavior.canCloseTab(tab)) {
代码示例来源:origin: torakiki/pdfsam
OpenWithDialog initFor(InputPdfArgumentsLoadRequest event) {
this.messageTitle
.setText(DefaultI18nContext.getInstance().i18n("Select the task to perform on the following files"));
filesList
.setItems(FXCollections.observableArrayList(event.pdfs.stream().map(Path::toString).collect(toList())));
modules.forEach(m -> {
if (m.descriptor().hasInputType(event.requiredInputTyle())) {
Button current = new Button(m.descriptor().getName());
current.getStyleClass().addAll(Style.FOOTER_BUTTON.css());
Optional.ofNullable(m.graphic()).ifPresent(g -> {
g.setScaleX(0.7);
g.setScaleY(0.7);
current.setGraphic(g);
});
current.setOnAction((e) -> {
eventStudio().broadcast(new ClearModuleEvent(), m.id());
eventStudio().broadcast(activeteModule(m.id()));
hide();
PdfLoadRequestEvent loadEvent = new PdfLoadRequestEvent(m.id());
event.pdfs.stream().map(Path::toFile).map(PdfDocumentDescriptor::newDescriptorNoPassword)
.forEach(loadEvent::add);
eventStudio().broadcast(loadEvent, m.id());
});
buttons.getChildren().add(current);
}
});
return this;
}
代码示例来源:origin: com.powsybl/powsybl-gse-afs-ext-base
public ModificationScriptEditor(StorableScript storableScript, Scene scene, GseContext context) {
this.storableScript = storableScript;
this.context = context;
codeEditor = new GroovyCodeEditor(scene);
Text saveGlyph = Glyph.createAwesomeFont('\uf0c7').size("1.3em");
saveButton = new Button("", saveGlyph);
saveButton.getStyleClass().add("gse-toolbar-button");
saveButton.disableProperty().bind(saved);
saveButton.setOnAction(event -> save());
codeEditorWithProgressIndicator = new StackPane(codeEditor, new Group(progressIndicator));
codeEditor.codeProperty().addListener((observable, oldValue, newValue) -> saved.set(false));
splitPane = new SplitPane(codeEditorWithProgressIndicator);
toolBar = new ToolBar(saveButton);
splitPane.setOrientation(Orientation.VERTICAL);
splitPane.setDividerPosition(0, 0.8);
setTop(toolBar);
setCenter(splitPane);
// listen to modifications
storableScript.addListener(this);
}
代码示例来源:origin: torakiki/pdfsam
Label memory = new Label(DefaultI18nContext.getInstance().i18n("Max memory {0}",
FileUtils.byteCountToDisplaySize(Runtime.getRuntime().maxMemory())));
Button copyButton = new Button(DefaultI18nContext.getInstance().i18n("Copy to clipboard"));
FontAwesomeIconFactory.get().setIcon(copyButton, FontAwesomeIcon.COPY);
copyButton.getStyleClass().addAll(Style.BUTTON.css());
copyButton.setId("copyEnvDetails");
copyButton.setOnAction(a -> {
ClipboardContent content = new ClipboardContent();
writeContent(Arrays.asList(pdfsam.name(), pdfsam.property(VERSION), runtime.getText(), memory.getText()))
代码示例来源:origin: io.github.factoryfx/javafxDataEditing
@Override
@SuppressWarnings("unchecked")
public Node createValueVisualisation() {
ComboBox<E> comboBox = new ComboBox<>();
comboBox.setEditable(false);
comboBox.getItems().addAll(possibleEnumConstants);
comboBox.valueProperty().bindBidirectional(observableAttributeValue);
comboBox.setConverter(stringConverter);
Button deleteButton = new Button();
uniformDesign.addDangerIcon(deleteButton, FontAwesome.Glyph.TIMES);
deleteButton.setOnAction(event -> observableAttributeValue.set(null));
deleteButton.disableProperty().bind(observableAttributeValue.isNull());//.or(Bindings.createBooleanBinding(()-> isReadOnlyVisualisation)));
HBox hbox = new HBox(3);
hbox.getChildren().addAll(comboBox,deleteButton);
hbox.disableProperty().bind(readOnly);
return hbox;
}
}
内容来源于网络,如有侵权,请联系作者删除!