本文整理匯總了Java中javafx.scene.control.TextArea類的典型用法代碼示例。如果您正苦於以下問題:Java TextArea類的具體用法?Java TextArea怎麽用?Java TextArea使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
TextArea類屬於javafx.scene.control包,在下文中一共展示了TextArea類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createTextArea
import javafx.scene.control.TextArea; //導入依賴的package包/類
private Node createTextArea(boolean selectable, boolean editable) {
textArea = new TextArea();
textArea.setPrefRowCount(4);
textArea.setEditable(editable);
textArea.textProperty().addListener((observable, oldValue, newValue) -> {
text = textArea.getText();
});
textArea.setText(text);
ScrollPane scrollPane = new ScrollPane(textArea);
scrollPane.setFitToWidth(true);
scrollPane.setFitToHeight(true);
scrollPane.setHbarPolicy(ScrollBarPolicy.NEVER);
scrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS);
HBox.setHgrow(scrollPane, Priority.ALWAYS);
return scrollPane;
}
示例2: build
import javafx.scene.control.TextArea; //導入依賴的package包/類
@Override
public AlertDialog build() {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
TextArea textArea = new TextArea();
GridPane expContent = new GridPane();
Label label = new Label("Stacktrace:");
label.setTextFill(Utils.getDefaultTextColor());
initOwner(ownerStage);
setTitle(title);
setHeaderText(header);
setContentText(message);
exception.printStackTrace(pw);
String exceptionText = sw.toString();
textArea.setText(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
getDialogPane().setExpandableContent(expContent);
return this;
}
示例3: getText
import javafx.scene.control.TextArea; //導入依賴的package包/類
@Test public void getText() {
final TextArea textArea = (TextArea) getPrimaryStage().getScene().getRoot().lookup(".text-area");
LoggingRecorder lr = new LoggingRecorder();
List<Object> text = new ArrayList<>();
Platform.runLater(() -> {
RFXComponent rTextField = new RFXTextInputControl(textArea, null, null, lr);
textArea.setText("Hello World");
rTextField.focusLost(null);
text.add(rTextField.getAttribute("text"));
});
new Wait("Waiting for text area text.") {
@Override public boolean until() {
return text.size() > 0;
}
};
AssertJUnit.assertEquals("Hello World", text.get(0));
}
示例4: TextPaneMenu
import javafx.scene.control.TextArea; //導入依賴的package包/類
public TextPaneMenu(TextArea textArea) {
this.textArea = textArea;
MenuItem copy = new MenuItem("_Copy");
this.setStyle(FontUtils.setUIFont(this.getStyle()));
copy.setMnemonicParsing(true);
copy.setOnAction(e -> {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection s = new StringSelection(
textArea.getSelectedText()
);
clipboard.setContents(s, null);
});
copy.setGraphic(new ImageView(ImageUtils.copyImage));
getItems().addAll(copy);
}
示例5: AsciiPaneMenu
import javafx.scene.control.TextArea; //導入依賴的package包/類
public AsciiPaneMenu(TextArea textArea) {
this.textArea = textArea;
MenuItem copy = new MenuItem("_Copy");
this.setStyle(FontUtils.setUIFont(this.getStyle()));
copy.setMnemonicParsing(true);
copy.setOnAction(e -> {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringSelection s = new StringSelection(
textArea.getSelectedText().replace("\n", "")
);
clipboard.setContents(s, null);
});
copy.setGraphic(new ImageView(ImageUtils.copyImage));
getItems().addAll(copy);
}
示例6: makeErrorGUI
import javafx.scene.control.TextArea; //導入依賴的package包/類
/**
* Make a Error Dialog
* @return BorderPane
*/
public void makeErrorGUI() {
root = new Group();
Scene scene = new Scene(root, 360, 185, Color.WHITE);
ImagePattern pattern = new ImagePattern(new Image("icon/bk2.jpg"));
scene.setFill(pattern);
setTitle("Error");
setScene(scene);
Image appIcon = new Image("icon/ERROR.png");
getIcons().add(appIcon);
BorderPane bp = new BorderPane();
textArea = new TextArea(message);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(320);
textArea.setMaxHeight(130);
HBox hBox = new HBox();
hBox.setSpacing(5);
hBox.setPadding(new Insets(5,0,0,0));
hBox.setAlignment(Pos.BOTTOM_RIGHT);
hBox.getChildren().addAll(openLogButton,okButton);
bp.setCenter(textArea);
bp.setBottom(hBox);
root.getChildren().add(bp);
sizeToScene();
setX(owner.getX() + Math.abs(owner.getWidth() - scene.getWidth()) / 2.0);
setY(owner.getY() + Math.abs(owner.getHeight() - scene.getHeight()) / 2.0);
}
示例7: showThrowable
import javafx.scene.control.TextArea; //導入依賴的package包/類
/** Show error dialog. **/
static void showThrowable(Window parent, Throwable e) {
Main.log(e);
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("Exception");
alert.initOwner(parent);
alert.initModality(Modality.WINDOW_MODAL);
alert.setHeaderText(e.getClass().getName());
alert.setContentText(e.getMessage());
StringWriter stringWriter = new StringWriter();
PrintWriter printWriter = new PrintWriter(stringWriter);
e.printStackTrace(printWriter);
String exceptionText = stringWriter.toString();
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
alert.getDialogPane().setExpandableContent(textArea);
alert.showAndWait();
}
示例8: ConsoleTab
import javafx.scene.control.TextArea; //導入依賴的package包/類
public ConsoleTab(Button button, Pane pane, TextArea mooConsole, TextField commandInput, Button commandSend) {
super(button, pane);
this.mooConsole = mooConsole;
this.commandInput = commandInput;
this.commandSend = commandSend;
// for sending command
commandSend.setOnAction(event -> {
String text = commandInput.getText();
commandInput.clear();
PacketMessenger.message(new PacketConsoleInput(text));
});
// register this as event listener
EventExecutor.getInstance().register(this);
PacketAdapting.getInstance().register(this);
}
示例9: createExceptionTextArea
import javafx.scene.control.TextArea; //導入依賴的package包/類
protected static GridPane createExceptionTextArea(Throwable errorToDisplay) {
StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw);
errorToDisplay.printStackTrace(pw);
String exceptionText = sw.toString();
Label label = new Label("The exception stacktrace was:");
TextArea textArea = new TextArea(exceptionText);
textArea.setEditable(false);
textArea.setWrapText(true);
textArea.setMaxWidth(Double.MAX_VALUE);
textArea.setMaxHeight(Double.MAX_VALUE);
GridPane.setVgrow(textArea, Priority.ALWAYS);
GridPane.setHgrow(textArea, Priority.ALWAYS);
GridPane expContent = new GridPane();
expContent.setMaxWidth(Double.MAX_VALUE);
expContent.add(label, 0, 0);
expContent.add(textArea, 0, 1);
return expContent;
}
示例10: input2ArrayListofArrayOfLongs
import javafx.scene.control.TextArea; //導入依賴的package包/類
public static ArrayList<Long[]> input2ArrayListofArrayOfLongs(TextArea ta) throws NumberFormatException {
String[] lines = ta.getText().trim().split("\n");
ArrayList<Long[]> result = new ArrayList<>(lines.length);
for (int i = 0; i < lines.length; i++) {
String[] inputs = lines[i].trim().split("[, ]+");
result.add(new Long[inputs.length]);
try {
for (int j = 0; j < inputs.length; j++) {
result.get(i)[j] = strPow(inputs[j]);
}
} catch (NumberFormatException ex) {
throw new NumberFormatException("Invaild Number (" + inputs + ")");
}
}
return result;
}
示例11: init
import javafx.scene.control.TextArea; //導入依賴的package包/類
@Override
public void init(SensorThingsService service, FeatureOfInterest entity, GridPane gridProperties, Accordion accordionLinks, Label labelId, boolean editable) {
this.labelId = labelId;
this.entity = entity;
int i = 0;
textName = addFieldTo(gridProperties, i, "Name", new TextField(), false, editable);
textDescription = addFieldTo(gridProperties, ++i, "Description", new TextArea(), true, editable);
textEncodingType = addFieldTo(gridProperties, ++i, "EncodingType", new TextField(), false, editable);
textFeature = addFieldTo(gridProperties, ++i, "Feature", new TextArea(), false, editable);
if (accordionLinks != null) {
try {
TitledPane tp = new TitledPane("Observations", createCollectionPaneFor(entity.observations().query()));
accordionLinks.getPanes().add(tp);
} catch (NullPointerException e) {
// Happens when entity is new.
}
}
}
示例12: pickPropertyExtract
import javafx.scene.control.TextArea; //導入依賴的package包/類
private void pickPropertyExtract() {
Stage promptWindow = new Stage();
promptWindow.setTitle("Selection de l'extrait");
try {
main.getCurrentMoment().setCurrentProperty(property);
FXMLLoader loader = new FXMLLoader();
loader.setLocation(getClass().getResource("/view/SelectDescriptemePart.fxml"));
loader.setController(new SelectDescriptemePartController(main, promptWindow, new TextArea(),Enregistrement.PROPERTY));
loader.setResources(main._langBundle);
BorderPane layout = (BorderPane) loader.load();
Scene launchingScene = new Scene(layout);
promptWindow.setScene(launchingScene);
promptWindow.show();
} catch (IOException e) {
// TODO Exit Program
e.printStackTrace();
}
}
示例13: StepPanel
import javafx.scene.control.TextArea; //導入依賴的package包/類
public StepPanel(AppSession session, StepWrapper step) {
this.session = session;
runButton = new Button("►");
textArea = new TextArea();
textArea.setFont(App.getDefaultFont());
textArea.setMinHeight(0);
textArea.setWrapText(true);
textArea.focusedProperty().addListener((val, before, after) -> {
if (!after) { // if we lost focus
rebuildFeatureIfTextChanged();
}
});
this.step = step;
initTextArea();
runButton.setOnAction(e -> run());
getChildren().addAll(textArea, runButton);
setLeftAnchor(textArea, 0.0);
setRightAnchor(textArea, 30.0);
setBottomAnchor(textArea, 0.0);
setRightAnchor(runButton, 0.0);
setTopAnchor(runButton, 2.0);
setBottomAnchor(runButton, 0.0);
}
示例14: start
import javafx.scene.control.TextArea; //導入依賴的package包/類
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Test the Scripting");
BorderPane root = new BorderPane();
TextArea input = new TextArea();
input.setPrefWidth(300);
input.setPrefHeight(300);
ScriptingExample scriptingExample = new ScriptingExample();
Button executeButton = new Button("Execute");
Button retrieveButton = new Button("Retrieve");
executeButton.setOnAction(e -> scriptingExample.inputScript(input.getText()));
retrieveButton.setOnAction(e ->scriptingExample.getTowersFromGroovy());
root.setCenter(input);
root.setBottom(executeButton);
root.setRight(retrieveButton);
primaryStage.setScene(new Scene(root));
primaryStage.show();
}
示例15: btnDeleteAction
import javafx.scene.control.TextArea; //導入依賴的package包/類
@FXML
private void btnDeleteAction()
{
try
{
FXMLLoader loader = new FXMLLoader(MainDisplay.class.getResource("/fxml/DeleteResultDialog.fxml"));
Parent root = loader.load();
Scene scene = new Scene(root);
Stage stage = new Stage();
stage.initModality(Modality.APPLICATION_MODAL);
stage.initStyle(StageStyle.UNDECORATED);
stage.setScene(scene);
stage.show();
Node node = scene.lookup("#txtArea");
if(node instanceof TextArea)
{
TextArea textArea = (TextArea)node;
DeleteTask task = new DeleteTask(dataContainer);
textArea.textProperty().bind(task.valueProperty());
Thread th = new Thread(task);
th.setDaemon(true);
th.start();
}
else
throw new IOException("Unable to find \"TextArea\" node");
}
catch(IOException e)
{
e.printStackTrace();
}
}