下面列出了javafx.scene.control.TextField#setEditable ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public static Tuple3<Label, TextField, Button> addTopLabelTextFieldButton(GridPane gridPane,
int rowIndex,
String title,
String buttonTitle,
double top) {
TextField textField = new BisqTextField();
textField.setEditable(false);
textField.setMouseTransparent(true);
textField.setFocusTraversable(false);
Button button = new AutoTooltipButton(buttonTitle);
button.setDefaultButton(true);
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(textField, button);
HBox.setHgrow(textField, Priority.ALWAYS);
final Tuple2<Label, VBox> labelVBoxTuple2 = addTopLabelWithVBox(gridPane, rowIndex, title, hBox, top);
return new Tuple3<>(labelVBoxTuple2.first, textField, button);
}
public static Tuple4<Label, TextField, Label, TextField> addCompactTopLabelTextFieldTopLabelTextField(GridPane gridPane,
int rowIndex,
String title1,
String title2) {
TextField textField1 = new BisqTextField();
textField1.setEditable(false);
textField1.setMouseTransparent(true);
textField1.setFocusTraversable(false);
final Tuple2<Label, VBox> topLabelWithVBox1 = getTopLabelWithVBox(title1, textField1);
TextField textField2 = new BisqTextField();
textField2.setEditable(false);
textField2.setMouseTransparent(true);
textField2.setFocusTraversable(false);
final Tuple2<Label, VBox> topLabelWithVBox2 = getTopLabelWithVBox(title2, textField2);
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.getChildren().addAll(topLabelWithVBox1.second, topLabelWithVBox2.second);
GridPane.setRowIndex(hBox, rowIndex);
gridPane.getChildren().add(hBox);
return new Tuple4<>(topLabelWithVBox1.first, textField1, topLabelWithVBox2.first, textField2);
}
@Override
public Node constructContent() {
boxview = new HBox();
boxview.setSpacing(6.0);
statusview = new TextField();
statusview.setEditable(false);
statusview.setFocusTraversable(false);
statusview.getStyleClass().add("unitinputview");
HBox.setHgrow(statusview, Priority.SOMETIMES);
boxview.getChildren().add(statusview);
initialize();
return boxview;
}
/**
* Update the current selected class.
*
* @param c
* The newly selected class.
*/
private void updateSelection(CDec c) {
selectedDec = c;
info.getChildren().clear();
info.add(new Label("Class name"), 0, 0);
TextField name = new TextField();
if (c.hasMappings()) {
name.setText(c.map().getCurrentName());
} else {
name.setText(c.getFullName());
name.setEditable(false);
}
if (c.isLocked())
name.setDisable(true);
info.add(name, 1, 0);
name.addEventHandler(KeyEvent.KEY_PRESSED, (KeyEvent e) -> {
if (KeyCode.ENTER == e.getCode()) {
pass = -2;
c.map().setCurrentName(name.getText());
refreshCode();
resetSelection();
updateStyleAndRegions();
}
});
}
public NeutralMassComponent() {
add(new Label("m/z:"), 0, 0);
ionMassField = new TextField();
ionMassField.textProperty().addListener((observable, oldValue, newValue) -> {
updateNeutralMass();
});
ionMassField.setPrefColumnCount(8);
add(ionMassField, 1, 0);
add(new Label("Charge:"), 2, 0);
chargeField = new TextField();
chargeField.textProperty().addListener((observable, oldValue, newValue) -> {
updateNeutralMass();
});
chargeField.setPrefColumnCount(2);
add(chargeField, 3, 0);
add(new Label("Ionization type:"), 0, 1, 2, 1);
ionTypeCombo =
new ComboBox<IonizationType>(FXCollections.observableArrayList(IonizationType.values()));
ionTypeCombo.setOnAction(e -> {
updateNeutralMass();
});
add(ionTypeCombo, 2, 1, 2, 1);
add(new Label("Calculated mass:"), 0, 2, 2, 1);
neutralMassField = new TextField();
neutralMassField.setPrefColumnCount(8);
neutralMassField.setStyle("-fx-background-color: rgb(192, 224, 240);");
neutralMassField.setEditable(false);
add(neutralMassField, 2, 2, 2, 1);
}
private HBox getLine (Label label, TextField text, HBox hbox)
{
HBox line = new HBox (10);
line.getChildren ().addAll (label, text, hbox);
label.setPrefWidth (LABEL_WIDTH);
text.setPrefWidth (100);
text.setFont (defaultFont);
text.setEditable (true);
text.setFocusTraversable (true);
return line;
}
private void addBankAccountTypeDisplay() // {{{
{
TradeCurrency singleTradeCurrency = japanBankAccount.getSingleTradeCurrency();
String currency = singleTradeCurrency != null ? singleTradeCurrency.getNameAndCode() : "null";
String accountTypeText = currency + " " + japanBankAccount.getBankAccountType();
TextField accountTypeTextField = addCompactTopLabelTextField(gridPane, ++gridRow, JapanBankData.getString("account.type"), accountTypeText).second;
accountTypeTextField.setEditable(false);
}
private VBox createNameField() {
VBox nameFieldBox = new VBox();
TextField nameField = new TextField();
nameField.textProperty().addListener((observable, oldValue, newValue) -> {
fireContentChanged();
checkList.setName(nameField.getText());
});
nameField.setEditable(mode.isSelectable());
nameFieldBox.getChildren().addAll(new Label("Name"), nameField);
HBox.setHgrow(nameField, Priority.ALWAYS);
VBox.setMargin(nameFieldBox, new Insets(5, 10, 0, 5));
nameField.setText(checkList.getName());
HBox.setHgrow(nameFieldBox, Priority.ALWAYS);
return nameFieldBox;
}
private Node createContent()
{
final GridPane layout = new GridPane();
layout.setHgap(5);
layout.setVgap(5);
int row = 0;
final TextField filename = new TextField(file.getAbsolutePath());
filename.setEditable(false);
GridPane.setHgrow(filename, Priority.ALWAYS);
layout.add(new Label(Messages.PropDlgPath), 0, row);
layout.add(filename, 1, row);
final TextField date = new TextField(TimestampFormats.MILLI_FORMAT.format(Instant.ofEpochMilli(file.lastModified())));
date.setEditable(false);
date.setMinWidth(200);
GridPane.setHgrow(date, Priority.ALWAYS);
layout.add(new Label(Messages.PropDlgDate), 0, ++row);
layout.add(date, 1, row);
if (!file.isDirectory())
{
final TextField size = new TextField(file.length() + " " + Messages.PropDlgBytes);
size.setEditable(false);
GridPane.setHgrow(size, Priority.ALWAYS);
layout.add(new Label(Messages.PropDlgSize), 0, ++row);
layout.add(size, 1, row);
}
layout.add(new Label(Messages.PropDlgPermissions), 0, ++row);
layout.add(writable, 1, row);
layout.add(executable, 1, ++row);
writable.setSelected(file.canWrite());
executable.setSelected(file.canExecute());
return layout;
}
private HBox getLine (RadioButton button, TextField text)
{
HBox line = new HBox (10);
line.getChildren ().addAll (button, text);
button.setPrefWidth (LABEL_WIDTH);
text.setPrefWidth (300);
text.setFont (defaultFont);
text.setEditable (false);
text.setFocusTraversable (false);
button.setUserData (text);
return line;
}
private HBox getLine (Label label, TextField text, HBox hbox)
{
HBox line = new HBox (10);
line.getChildren ().addAll (label, text, hbox);
label.setPrefWidth (LABEL_WIDTH);
text.setPrefWidth (100);
text.setFont (defaultFont);
text.setEditable (true);
text.setFocusTraversable (true);
return line;
}
/**
*
*/
public TextFieldCell() {
textField = new TextField();
textField.addEventFilter(KeyEvent.KEY_TYPED, hex_Validation(50));
textField.getStyleClass().add("hexTextFieldEditor");
textField.setEditable(false);
textField.setOnMouseClicked((MouseEvent mouseEvent) -> {
if (mouseEvent.getButton().equals(MouseButton.PRIMARY) && mouseEvent.getClickCount() == 2) {
handleMouseClickedEvent();
}
});
this.setGraphic(textField);
}
private void addPayInfoEntry(GridPane infoGridPane, int row, String labelText, String value) {
Label label = new AutoTooltipLabel(labelText);
TextField textField = new TextField(value);
textField.setMinWidth(500);
textField.setEditable(false);
textField.setFocusTraversable(false);
textField.setId("payment-info");
GridPane.setConstraints(label, 0, row, 1, 1, HPos.RIGHT, VPos.CENTER);
GridPane.setConstraints(textField, 1, row);
infoGridPane.getChildren().addAll(label, textField);
}
private void addPayInfoEntry(GridPane infoGridPane, int row, String labelText, String value) {
Label label = new AutoTooltipLabel(labelText);
TextField textField = new TextField(value);
textField.setMinWidth(500);
textField.setEditable(false);
textField.setFocusTraversable(false);
textField.setId("payment-info");
GridPane.setConstraints(label, 0, row, 1, 1, HPos.RIGHT, VPos.CENTER);
GridPane.setConstraints(textField, 1, row);
infoGridPane.getChildren().addAll(label, textField);
}
private Node createAttributeValueNode(final Object[] values, final AttributeData attribute, final AttributeTitledPane parent, final boolean multiValue) {
boolean noneSelected = values == null;
boolean isNull = !noneSelected && (values[0] == null);
parent.setAttribute(attribute);
AbstractAttributeInteraction<?> interaction = AbstractAttributeInteraction.getInteraction(attribute.getDataType());
final String displayText;
final List<Node> displayNodes;
if (multiValue) {
displayText = "<Multiple Values>";
displayNodes = Collections.emptyList();
} else if (isNull) {
displayText = NO_VALUE_TEXT;
displayNodes = Collections.emptyList();
} else if (noneSelected) {
displayText = "<Nothing Selected>";
displayNodes = Collections.emptyList();
} else {
displayText = interaction.getDisplayText(values[0]);
displayNodes = interaction.getDisplayNodes(values[0], -1, CELL_ITEM_HEIGHT);
}
parent.setAttributeValue(displayText);
final TextField attributeValueText = new TextField(displayText);
attributeValueText.setEditable(false);
if (noneSelected || isNull || multiValue) {
attributeValueText.getStyleClass().add("undisplayedValue");
}
if (displayNodes.isEmpty()) {
return attributeValueText;
}
GridPane gridPane = new GridPane();
gridPane.setAlignment(Pos.CENTER_RIGHT);
gridPane.setPadding(Insets.EMPTY);
gridPane.setHgap(CELL_ITEM_SPACING);
ColumnConstraints displayNodeConstraint = new ColumnConstraints(CELL_ITEM_HEIGHT);
displayNodeConstraint.setHalignment(HPos.LEFT);
ColumnConstraints displayTextConstraint = new ColumnConstraints();
displayTextConstraint.setHalignment(HPos.RIGHT);
displayTextConstraint.setHgrow(Priority.ALWAYS);
displayTextConstraint.setFillWidth(true);
for (int i = 0; i < displayNodes.size(); i++) {
final Node displayNode = displayNodes.get(i);
gridPane.add(displayNode, i, 0);
gridPane.getColumnConstraints().add(displayNodeConstraint);
}
gridPane.add(attributeValueText, displayNodes.size(), 0);
gridPane.getColumnConstraints().add(displayTextConstraint);
return gridPane;
}
public static void showDialog(final LockFile.UnableToCreateLock exception)
{
final Alert alert = new Alert(AlertType.ERROR);
alert.setTitle("Paintera");
alert.setHeaderText("Unable to create lock file.");
final Label instructions = new Label(
"If no other Paintera instance is accessing the same project please delete lock file and try to " +
"restart Paintera.");
instructions.setWrapText(true);
final GridPane content = new GridPane();
final Label fileLabel = new Label("Lock File");
final Label messageLabel = new Label("Message");
final TextField fileField = new TextField(exception.getLockFile().getAbsolutePath());
final TextField messageField = new TextField(exception.getMessage());
fileField.setTooltip(new Tooltip(fileField.getText()));
messageField.setTooltip(new Tooltip(messageField.getText()));
fileField.setEditable(false);
messageField.setEditable(false);
GridPane.setHgrow(fileField, Priority.ALWAYS);
GridPane.setHgrow(messageField, Priority.ALWAYS);
content.add(fileLabel, 0, 0);
content.add(messageLabel, 0, 1);
content.add(fileField, 1, 0);
content.add(messageField, 1, 1);
final VBox contentBox = new VBox(instructions, content);
alert.getDialogPane().setContent(contentBox);
final StringWriter stringWriter = new StringWriter();
exception.printStackTrace(new PrintWriter(stringWriter));
final String exceptionText = stringWriter.toString();
final TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
LOG.trace("Exception text (length={}): {}", exceptionText.length(), exceptionText);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
// final GridPane expandableContent = new GridPane();
// expandableContent.setMaxWidth( Double.MAX_VALUE );
//
// expandableContent.add( child, columnIndex, rowIndex );
alert.getDialogPane().setExpandableContent(textArea);
// alert.setResizable( true );
alert.showAndWait();
}
private void addBankBranchDisplay() // {{{
{
String branchText = japanBankAccount.getBankBranchCode() + " " + japanBankAccount.getBankBranchName();
TextField branchTextField = addCompactTopLabelTextField(gridPane, ++gridRow, JapanBankData.getString("branch"), branchText).second;
branchTextField.setEditable(false);
}
private void addBankDisplay() // {{{
{
String bankText = japanBankAccount.getBankCode() + " " + japanBankAccount.getBankName();
TextField bankTextField = addCompactTopLabelTextField(gridPane, ++gridRow, JapanBankData.getString("bank"), bankText).second;
bankTextField.setEditable(false);
}
@Override
public Node constructContent() {
StackPane stackpaneroot = new StackPane();
boxview = new HBox();
boxview.setSpacing(6.0);
statusview = new TextField();
statusview.setEditable(false);
statusview.setFocusTraversable(false);
statusview.getStyleClass().add("unitinputview");
HBox.setHgrow(statusview, Priority.SOMETIMES);
editaction = new Button();
editaction.setFocusTraversable(false);
editaction.setMnemonicParsing(false);
editaction.getStyleClass().add("unitbutton");
editaction.setOnAction(this::onEditEvent);
boxview.getChildren().addAll(statusview, editaction);
boxedit = new HBox();
boxedit.setSpacing(6.0);
boxedit.setVisible(false);
statusedit = new TextField();
statusedit.getStyleClass().add("unitinput");
HBox.setHgrow(statusedit, Priority.SOMETIMES);
((TextField) statusedit).setOnAction(this::onEnterEvent);
okaction = new Button();
okaction.setFocusTraversable(false);
okaction.setMnemonicParsing(false);
okaction.getStyleClass().add("unitbutton");
okaction.setOnAction(this::onOkEvent);
cancelaction = new Button();
cancelaction.setFocusTraversable(false);
cancelaction.setMnemonicParsing(false);
cancelaction.getStyleClass().add("unitbutton");
cancelaction.setOnAction(this::onCancelEvent);
boxedit.getChildren().addAll(statusedit, okaction, cancelaction);
stackpaneroot.getChildren().addAll(boxview, boxedit);
initialize();
return stackpaneroot;
}
private void addBankAccountDisplay() // {{{
{
String accountText = japanBankAccount.getBankAccountNumber() + " " + japanBankAccount.getBankAccountName();
TextField accountTextField = addCompactTopLabelTextField(gridPane, ++gridRow, JapanBankData.getString("account"), accountText).second;
accountTextField.setEditable(false);
}