当前位置: 首页>>代码示例>>Java>>正文


Java CodeArea.setEditable方法代码示例

本文整理汇总了Java中org.fxmisc.richtext.CodeArea.setEditable方法的典型用法代码示例。如果您正苦于以下问题:Java CodeArea.setEditable方法的具体用法?Java CodeArea.setEditable怎么用?Java CodeArea.setEditable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.fxmisc.richtext.CodeArea的用法示例。


在下文中一共展示了CodeArea.setEditable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: GroovyEditorComponent

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
/**
 * Instantiates a new Groovy editor component.
 *
 * @param editable the editable
 */
public GroovyEditorComponent(final boolean editable) {

    codeArea = new CodeArea();
    codeArea.richChanges()
            .filter(ch -> !ch.getInserted().equals(ch.getRemoved()))
            .subscribe(change -> codeArea.setStyleSpans(0, getStyleSpans(codeArea.getText())));
    codeArea.prefHeightProperty().bind(heightProperty());
    codeArea.prefWidthProperty().bind(widthProperty());
    codeArea.setEditable(editable);
    codeArea.setOnKeyReleased(UIUtils::consumeIfIsNotHotKey);
    codeArea.setOnKeyPressed(UIUtils::consumeIfIsNotHotKey);


    FXUtils.addToPane(codeArea, this);
    FXUtils.addClassesTo(this, CSSClasses.TEXT_EDITOR_TEXT_AREA, CSSClasses.GROOVY_EDITOR_COMPONENT);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:22,代码来源:GroovyEditorComponent.java

示例2: FileViewController

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public FileViewController() {
    super();
    codeArea = new CodeArea();
    codeArea.setParagraphGraphicFactory(DiffLineNumberFactory.get(codeArea, Collections.EMPTY_LIST));
    codeArea.setEditable(false);

    Button button = new Button("Save as ...");

    scene = new Scene(
            new BorderPane(
                    new VirtualizedScrollPane(codeArea),
                    new ToolBar(button),
                    null,null,null
            ),
            1024, 768);
    scene.getStylesheets().add(this.getClass().getResource(Const.KEYWORDS_CSS).toExternalForm());


    button.setOnAction(
            event -> {
                FileChooser fileChooser = new FileChooser();

                //Set extension filter
                FileChooser.ExtensionFilter extFilter = new FileChooser.ExtensionFilter("Any files (*.*)", "*.*");
                fileChooser.getExtensionFilters().add(extFilter);

                //Show save file dialog
                File file = fileChooser.showSaveDialog(scene.getWindow());

                if (file != null) {

                    try {
                        Files.copy(Paths.get(fileName), file.toPath());
                    } catch (IOException e) {
                        e.printStackTrace();
                    }

                }
            }
    );

}
 
开发者ID:iazarny,项目名称:gitember,代码行数:43,代码来源:FileViewController.java

示例3: DiffViewController

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
public DiffViewController() {

        super();

        oldLinesToHighlight = new ArrayList<>();
        oldCodeArea = new CodeArea();
        oldCodeArea.setEditable(false);
        oldCodeArea.setParagraphGraphicFactory(DiffLineNumberFactory.get(oldCodeArea, oldLinesToHighlight));

        oldLabel = new ShaTextField();

        oldVSPane = new VirtualizedScrollPane<>(oldCodeArea, ScrollPane.ScrollBarPolicy.AS_NEEDED, ScrollPane.ScrollBarPolicy.NEVER);
        StackPane oldStackPane = new StackPane(oldVSPane);

        scrollPane = new Pane();
        scrollPane.setPrefWidth(75);

        newLinesToHighlight = new ArrayList<>();
        newCodeArea = new CodeArea();
        newCodeArea.setEditable(false);
        newCodeArea.setParagraphGraphicFactory(DiffLineNumberFactory.get(newCodeArea, newLinesToHighlight));
        newLabel = new ShaTextField();
        newVSPane = new VirtualizedScrollPane<>(newCodeArea);
        StackPane newStackPane = new StackPane(newVSPane);

        newStackPane.setPrefHeight(2000);


        gridPanel = new GridPane();

        ColumnConstraints oldColumn = new ColumnConstraints();
        oldColumn.setPercentWidth(45);
        gridPanel.getColumnConstraints().add(oldColumn);

        ColumnConstraints scrollColumn = new ColumnConstraints();
        scrollColumn.setPercentWidth(10);
        scrollColumn.setHalignment(HPos.CENTER);
        gridPanel.getColumnConstraints().add(scrollColumn);

        ColumnConstraints newlColumn = new ColumnConstraints();
        newlColumn.setPercentWidth(45);
        gridPanel.getColumnConstraints().add(newlColumn);

        buttonNext = new Button();
        buttonNext.setTooltip(new Tooltip("Next"));
        buttonNext.setGraphic(new FontIcon(FontAwesome.FORWARD));

        buttonPrev = new Button();
        buttonPrev.setTooltip(new Tooltip("Prev"));
        buttonPrev.setGraphic(new FontIcon(FontAwesome.BACKWARD));

        gridPanel.add(new ToolBar(new HBox(new Label("Revision:  "), oldLabel)), 0, 0);

        gridPanel.add(new ToolBar(new HBox(new Label("Revision:  "), newLabel)), 2, 0);

        gridPanel.add(scrollPane, 1, 1);
        gridPanel.add(oldStackPane, 0, 1);
        gridPanel.add(newStackPane, 2, 1);

        Region leftr = new Region();
        Region leftl = new Region();
        HBox.setHgrow(leftr,  Priority.ALWAYS);
        HBox.setHgrow(leftl,  Priority.ALWAYS);
        gridPanel.add(new HBox(leftl, buttonPrev, buttonNext, leftr), 1, 0);

        Field field = FieldUtils.getField(oldCodeArea.getClass(), "virtualFlow", true);
        try {
            oldVirtualFlow = (VirtualFlow) field.get(oldCodeArea);
            newVirtualFlow = (VirtualFlow) field.get(newCodeArea);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }


    }
 
开发者ID:iazarny,项目名称:gitember,代码行数:76,代码来源:DiffViewController.java

示例4: createCodeArea

import org.fxmisc.richtext.CodeArea; //导入方法依赖的package包/类
private static CodeArea createCodeArea(String text) {
    CodeArea code = new CodeArea(text);
    code.setParagraphGraphicFactory(LineNumberFactory.get(code));
    code.setEditable(false);
    return code;
}
 
开发者ID:Minecrell,项目名称:dandelion,代码行数:7,代码来源:MainController.java


注:本文中的org.fxmisc.richtext.CodeArea.setEditable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。