本文整理汇总了Java中org.fxmisc.richtext.CodeArea.addEventHandler方法的典型用法代码示例。如果您正苦于以下问题:Java CodeArea.addEventHandler方法的具体用法?Java CodeArea.addEventHandler怎么用?Java CodeArea.addEventHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.fxmisc.richtext.CodeArea
的用法示例。
在下文中一共展示了CodeArea.addEventHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: JavaTextArea
import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public JavaTextArea(String content) {
codeArea = new CodeArea();
codeHelperDeligator = new JavaCodeAreaHelper(codeArea);
codeArea.setParagraphGraphicFactory(getLineFactory());
codeArea.richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
.successionEnds(Duration.ofMillis(500)).supplyTask(this::computeHighlightingAsync).awaitLatest(codeArea.richChanges())
.filterMap(t -> {
if (t.isSuccess()) {
return Optional.of(t.get());
} else {
t.getFailure().printStackTrace();
return Optional.empty();
}
}).subscribe(this::applyHighlighting);
// 마우스 클릭이벤트 정의
codeArea.addEventHandler(KeyEvent.KEY_PRESSED, this::codeAreaKeyClick);
codeArea.setOnMouseClicked(defaultSelectionHandler);
codeArea.selectionProperty().addListener((oba, oldval, newval) -> {
int start = newval.getStart();
int end = newval.getEnd();
int caretColumn = codeArea.getCaretColumn();
String format = String.format(POSISION_FORMAT, codeArea.getCurrentParagraph() + 1, start + 1, end + 1, caretColumn + 1,
codeArea.getAnchor(), codeArea.getCaretPosition());
lblLineInfo.setText(format);
});
lblLineInfo.setPrefHeight(USE_COMPUTED_SIZE);
lblLineInfo.setMinHeight(USE_COMPUTED_SIZE);
lblLineInfo.setMaxHeight(USE_COMPUTED_SIZE);
this.setCenter(codeArea);
this.setBottom(lblLineInfo);
// this.getChildren().add(codeArea);
// this.getStylesheets().add(JavaKeywordsAsync.class.getResource("java-keywords.css").toExternalForm());
this.getStylesheets().add(JavaTextArea.class.getResource("java-keywords.css").toExternalForm());
this.codeArea.appendText(content);
UndoManager undoManager = codeArea.getUndoManager();
undoManager.forgetHistory();
undoManager.mark();
this.codeArea.selectRange(0, 0);
}
示例2: ASTSqlCodeAreaHelper
import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public ASTSqlCodeAreaHelper(CodeArea codeArea, ConnectionSupplier connectionSupplier) {
this.codeArea = codeArea;
this.connectionSupplier = connectionSupplier;
view = createResourceView();
codeArea.setPopupWindow(new PopOver(view));
codeArea.setPopupAlignment(PopupAlignment.SELECTION_TOP_CENTER);
codeArea.addEventHandler(KeyEvent.KEY_PRESSED, ev -> {
if (ev.isControlDown() && ev.getCode() == KeyCode.SPACE) {
if (ev.isConsumed())
return;
String string = markText(codeArea);
view.getTxtFilter().setText(string);
replaceTarget.set(string);
codeArea.getPopupWindow().show(codeArea.getScene().getWindow());
codeArea.getPopupWindow().requestFocus();
view.getTxtFilter().requestFocus();
view.getTxtFilter().selectEnd();
ev.consume();
}
});
}
示例3: BehaviorTextArea
import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public BehaviorTextArea(String content) {
codeArea = new CodeArea();
codeHelperDeligator = new BehaviorCodeAreaHelper(codeArea);
codeArea.setParagraphGraphicFactory(getLineFactory());
codeArea.richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
.successionEnds(Duration.ofMillis(500)).supplyTask(this::computeHighlightingAsync).awaitLatest(codeArea.richChanges())
.filterMap(t -> {
if (t.isSuccess()) {
return Optional.of(t.get());
} else {
t.getFailure().printStackTrace();
return Optional.empty();
}
}).subscribe(this::applyHighlighting);
// 마우스 클릭이벤트 정의
codeArea.addEventHandler(KeyEvent.KEY_PRESSED, this::codeAreaKeyClick);
codeArea.setOnMouseClicked(defaultSelectionHandler);
codeArea.selectionProperty().addListener((oba, oldval, newval) -> {
int start = newval.getStart();
int end = newval.getEnd();
int caretColumn = codeArea.getCaretColumn();
String format = String.format(POSISION_FORMAT, codeArea.getCurrentParagraph() + 1, start + 1, end + 1, caretColumn + 1,
codeArea.getAnchor(), codeArea.getCaretPosition());
lblLineInfo.setText(format);
});
lblLineInfo.setPrefHeight(USE_COMPUTED_SIZE);
lblLineInfo.setMinHeight(USE_COMPUTED_SIZE);
lblLineInfo.setMaxHeight(USE_COMPUTED_SIZE);
this.setCenter(codeArea);
this.setBottom(lblLineInfo);
// this.getChildren().add(codeArea);
// this.getStylesheets().add(JavaKeywordsAsync.class.getResource("java-keywords.css").toExternalForm());
this.getStylesheets().add(BehaviorTextArea.class.getResource("behavior-keywords.css").toExternalForm());
this.codeArea.appendText(content);
UndoManager undoManager = codeArea.getUndoManager();
undoManager.forgetHistory();
undoManager.mark();
this.codeArea.selectRange(0, 0);
}
示例4: ThreadDumpTextArea
import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public ThreadDumpTextArea() {
//
// RuntimeClassUtil.addShutdownHook(() -> {
//
// if (!executor.isTerminated())
// executor.shutdownNow();
//
// });
codeArea = new CodeArea();
codeHelperDeligator = new CodeAreaHelper<>(codeArea);
//codeArea.setParagraphGraphicFactory(getLineFactory());
// codeArea.richChanges().subscribe(change -> {
// codeArea.setStyleSpans(0, computeHighlighting(codeArea.getText()));
// });
// codeArea.richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
// .subscribe(change -> {
// codeArea.setStyleSpans(0, computeHighlighting(codeArea.getText()));
// });
codeArea.richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
.successionEnds(Duration.ofMillis(500)).supplyTask(this::computeHighlightingAsync).awaitLatest(codeArea.richChanges())
.filterMap(t -> {
if (t.isSuccess()) {
return Optional.of(t.get());
} else {
t.getFailure().printStackTrace();
return Optional.empty();
}
}).subscribe(this::applyHighlighting);
// 마우스 클릭이벤트 정의
codeArea.addEventHandler(KeyEvent.KEY_PRESSED, this::codeAreaKeyClick);
// codeArea.setOnKeyPressed(this::codeAreaKeyClick);
//
codeArea.setOnMouseClicked(defaultSelectionHandler);
// codeArea.richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
// .successionEnds(Duration.millis(500)).supplyTask(this::computeHighlightingAsync).awaitLatest(codeArea.richChanges())
// .filterMap(t -> {
// if (t.isSuccess()) {
// return Optional.of(t.get());
// } else {
// t.getFailure().printStackTrace();
// return Optional.empty();
// }
// }).subscribe(this::applyHighlighting);
codeArea.selectionProperty().addListener((oba, oldval, newval) -> {
int start = newval.getStart();
int end = newval.getEnd();
int caretColumn = codeArea.getCaretColumn();
String format = String.format(POSISION_FORMAT, codeArea.getCurrentParagraph() + 1, start + 1, end + 1, caretColumn + 1,
codeArea.getAnchor(), codeArea.getCaretPosition());
lblLineInfo.setText(format);
});
lblLineInfo.setPrefHeight(USE_COMPUTED_SIZE);
lblLineInfo.setMinHeight(USE_COMPUTED_SIZE);
lblLineInfo.setMaxHeight(USE_COMPUTED_SIZE);
this.setCenter(codeArea);
this.setBottom(lblLineInfo);
// this.getChildren().add(codeArea);
// this.getStylesheets().add(JavaKeywordsAsync.class.getResource("java-keywords.css").toExternalForm());
this.getStylesheets().add(ThreadDumpTextArea.class.getResource("thread-dump-keywords.css").toExternalForm());
}
示例5: SqlKeywords
import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public SqlKeywords() {
codeArea = new CodeArea();
codeHelperDeligator = new SqlCodeAreaHelper(codeArea);
codeArea.appendText("");
codeArea.setParagraphGraphicFactory(LineNumberFactory.get(codeArea));
// codeArea.richChanges().subscribe(change -> {
// Platform.runLater(() -> {
// codeArea.setStyleSpans(0, computeHighlighting(codeArea.getText()));
//
// });
// });
codeArea.richChanges().filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
.successionEnds(Duration.ofMillis(500)).supplyTask(this::computeHighlightingAsync).awaitLatest(codeArea.richChanges())
.filterMap(t -> {
if (t.isSuccess()) {
return Optional.of(t.get());
} else {
t.getFailure().printStackTrace();
return Optional.empty();
}
}).subscribe(this::applyHighlighting);
/**CodeArea 'Tab' Size handler *************************************************************/
//17.01.14 Deprecated
//codeArea.addEventHandler(KeyEvent.KEY_PRESSED, new CodeAreaTabSizeHandler(codeArea));
// 마우스 클릭이벤트 정의
codeArea.addEventHandler(KeyEvent.KEY_PRESSED, this::codeAreaKeyClick);
codeArea.setOnKeyPressed(this::codeAreaKeyClick);
//
// codeArea.setOnMouseClicked(defaultSelectionHandler);
// 선택라인정보 보여주는 기능 추가.
codeArea.selectionProperty().addListener((oba, oldval, newval) -> {
int start = newval.getStart();
int end = newval.getEnd();
int caretColumn = codeArea.getCaretColumn();
String format = String.format("line : %d selectionStart : %d selectionEnd : %d column : %d ",
codeArea.getCurrentParagraph() + 1, start + 1, end + 1, caretColumn + 1);
lblLineInfo.setText(format);
});
lblLineInfo.setPrefHeight(USE_COMPUTED_SIZE);
this.setCenter(codeArea);
this.setBottom(lblLineInfo);
// this.getChildren().add();
this.getStylesheets().add(SqlKeywords.class.getResource("java-keywords.css").toExternalForm());
}