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


Java StyleClassedTextArea类代码示例

本文整理汇总了Java中org.fxmisc.richtext.StyleClassedTextArea的典型用法代码示例。如果您正苦于以下问题:Java StyleClassedTextArea类的具体用法?Java StyleClassedTextArea怎么用?Java StyleClassedTextArea使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: initKeyMapping

import org.fxmisc.richtext.StyleClassedTextArea; //导入依赖的package包/类
public void initKeyMapping(StyleClassedTextArea sourceText) {
    Platform.runLater(() -> {
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.S, SHORTCUT_DOWN), e -> handleSaveButtonAction())));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.G, SHORTCUT_DOWN), e -> handleBoldButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.I, SHORTCUT_DOWN), e -> handleItalicButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.B, SHORTCUT_DOWN), e -> handleBarredButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.K, SHORTCUT_DOWN), e -> handleTouchButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.PLUS, SHORTCUT_DOWN), e -> handleExpButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.EQUALS, SHORTCUT_DOWN), e -> handleIndButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.E, SHORTCUT_DOWN), e -> handleCenterButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.D, SHIFT_DOWN, SHORTCUT_DOWN), e -> handleRightButtonAction(null))));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.SPACE, SHORTCUT_DOWN), e -> handleUnbreakableAction())));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.L, SHORTCUT_DOWN), e -> handleGoToLineAction())));
        Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.F, SHORTCUT_DOWN), e -> handleFindReplaceDialog())));
        if (FunctionTreeFactory.isMacOs()) {
            Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.Q, SHORTCUT_DOWN), e -> currentSourceText.selectAll())));
        }
        if (MainApp.getConfig().isEditorSmart()) {
            //Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.TAB), e -> handleSmartTab())));
            //Nodes.addInputMap(sourceText, sequence(consume(keyPressed(KeyCode.ENTER), e -> handleSmartEnter())));
        }
    });
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:24,代码来源:MdTextController.java

示例2: start

import org.fxmisc.richtext.StyleClassedTextArea; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
    StyleClassedTextArea area = new StyleClassedTextArea();
    area.setWrapText(true);
    for(int i = 0; i < 10; ++i) {
        area.appendText("Lorem ipsum dolor sit amet, consectetur adipiscing elit.\n");
    }

    HBox panel = new HBox();
    for(int size: new int[]{8, 10, 12, 14, 16, 18, 20, 24, 28, 32, 36, 40, 48, 56, 64, 72}) {
        Button b = new Button(Integer.toString(size));
        b.setOnAction(ae -> area.setStyle("-fx-font-size:" + size));
        panel.getChildren().add(b);
    }

    VBox vbox = new VBox();
    VirtualizedScrollPane<StyleClassedTextArea> vsPane = new VirtualizedScrollPane<>(area);
    VBox.setVgrow(vsPane, Priority.ALWAYS);
    vbox.getChildren().addAll(panel, vsPane);

    Scene scene = new Scene(vbox, 600, 400);
    primaryStage.setScene(scene);
    area.requestFocus();
    primaryStage.setTitle("Font Size Switching Test");
    primaryStage.show();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:27,代码来源:FontSizeSwitcher.java

示例3: start

import org.fxmisc.richtext.StyleClassedTextArea; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
    Button red = createColorButton(Color.RED, "red");
    Button green = createColorButton(Color.GREEN, "green");
    Button blue = createColorButton(Color.BLUE, "blue");
    Button bold = createBoldButton("bold");
    HBox panel = new HBox(red, green, blue, bold);

    VirtualizedScrollPane<StyleClassedTextArea> vsPane = new VirtualizedScrollPane<>(area);
    VBox.setVgrow(vsPane, Priority.ALWAYS);
    area.setWrapText(true);
    VBox vbox = new VBox(panel, vsPane);

    Scene scene = new Scene(vbox, 600, 400);
    scene.getStylesheets().add(ManualHighlighting.class.getResource("manual-highlighting.css").toExternalForm());
    primaryStage.setScene(scene);
    primaryStage.setTitle("Manual Highlighting Demo");
    primaryStage.show();

    area.requestFocus();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:22,代码来源:ManualHighlighting.java

示例4: test_fxml_construction_of_area

import org.fxmisc.richtext.StyleClassedTextArea; //导入依赖的package包/类
@Test
public void test_fxml_construction_of_area() throws IOException, LoadException
{
    // FxmlTest.fxml is located in resources folder: src/integrationTest/resources/org/fxmisc/richtext/api/
    FXMLLoader fxml = new FXMLLoader( getClass().getResource( "FxmlTest.fxml" ) );
    StyleClassedTextArea area = (StyleClassedTextArea) fxml.load();
    // fxml.load() will throw a LoadException if any properties failed to be set,
    // so if 'area' is not null then all properties are guaranteed to have been set.
    org.junit.Assert.assertNotNull( area );
    
    FxmlTest ctrl = fxml.getController();
    // Check that the controller was loaded and that it has the relevant
    // test methods which are referenced in the loaded fxml file.
    org.junit.Assert.assertNotNull( ctrl );
    ctrl.testWithMouseEvent( null );
    ctrl.testWithOutMouseEvent();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:18,代码来源:FxmlTester.java

示例5: handleFindReplaceAction

import org.fxmisc.richtext.StyleClassedTextArea; //导入依赖的package包/类
@FXML private void handleFindReplaceAction(ActionEvent event){
    SplitPane sPane = (SplitPane) mainApp.getIndex().getEditorList().getTabs().stream()
            .filter(t ->t.isSelected())
            .findFirst()
            .get()
            .getContent();
    BorderPane bPane = (BorderPane) sPane.getItems().get(0);
    StyleClassedTextArea source = (StyleClassedTextArea) bPane.getCenter();
    FunctionTreeFactory.openFindReplaceDialog(source);
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:11,代码来源:MenuController.java

示例6: openFindReplaceDialog

import org.fxmisc.richtext.StyleClassedTextArea; //导入依赖的package包/类
public static void openFindReplaceDialog(StyleClassedTextArea sourceText) {
    FXMLLoader loader = new CustomFXMLLoader(MainApp.class.getResource("fxml/FindReplaceDialog.fxml"));

    Stage dialogStage = new CustomStage(loader, Configuration.getBundle().getString("ui.dialog.find.title"));
    dialogStage.setAlwaysOnTop(true);
    dialogStage.initModality(Modality.NONE);
    dialogStage.setTitle(Configuration.getBundle().getString("ui.dialog.find.title"));
    dialogStage.setResizable(false);

    FindReplaceDialog findReplaceDialog = loader.getController();
    findReplaceDialog.setSourceText(sourceText);

    dialogStage.show();
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:15,代码来源:FunctionTreeFactory.java

示例7: setSourceText

import org.fxmisc.richtext.StyleClassedTextArea; //导入依赖的package包/类
public void setSourceText(StyleClassedTextArea sourceText, ZdsHttp zdsUtils, MenuController menuManager, Content content){
    this.sourceText = sourceText;
    this.zdsUtils = zdsUtils;
    this.menuManager = menuManager;
    this.content = content;
    if(content == null ) {
        selectButton.setDisable(true);
    }
    title.setText(sourceText.getSelectedText());
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:11,代码来源:ImageInputDialog.java

示例8: start

import org.fxmisc.richtext.StyleClassedTextArea; //导入依赖的package包/类
@Override
public void start(Stage stage) {
    StyleClassedTextArea area = new StyleClassedTextArea();
    area.setWrapText(true);
    area.appendText("Pause the mouse over the text for 1 second.");

    Popup popup = new Popup();
    Label popupMsg = new Label();
    popupMsg.setStyle(
            "-fx-background-color: black;" +
            "-fx-text-fill: white;" +
            "-fx-padding: 5;");
    popup.getContent().add(popupMsg);

    area.setMouseOverTextDelay(Duration.ofSeconds(1));
    area.addEventHandler(MouseOverTextEvent.MOUSE_OVER_TEXT_BEGIN, e -> {
        int chIdx = e.getCharacterIndex();
        Point2D pos = e.getScreenPosition();
        popupMsg.setText("Character '" + area.getText(chIdx, chIdx+1) + "' at " + pos);
        popup.show(area, pos.getX(), pos.getY() + 10);
    });
    area.addEventHandler(MouseOverTextEvent.MOUSE_OVER_TEXT_END, e -> {
        popup.hide();
    });

    Scene scene = new Scene(area, 600, 400);
    stage.setScene(scene);
    stage.setTitle("Tooltip Demo");
    stage.show();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:31,代码来源:TooltipDemo.java

示例9: start

import org.fxmisc.richtext.StyleClassedTextArea; //导入依赖的package包/类
@Override
public void start(Stage primaryStage) {
    StyleClassedTextArea textArea = new StyleClassedTextArea();
    textArea.setWrapText(true);

    textArea.richChanges()
            .filter(ch -> !ch.getInserted().equals(ch.getRemoved())) // XXX
            .subscribe(change -> {
                textArea.setStyleSpans(0, computeHighlighting(textArea.getText()));
            });

    // load the dictionary
    try (InputStream input = getClass().getResourceAsStream("spellchecking.dict");
         BufferedReader br = new BufferedReader(new InputStreamReader(input))) {
        String line;
        while ((line = br.readLine()) != null) {
            dictionary.add(line);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }

    // load the sample document
    InputStream input2 = getClass().getResourceAsStream("spellchecking.txt");
    try(java.util.Scanner s = new java.util.Scanner(input2)) { 
        String document = s.useDelimiter("\\A").hasNext() ? s.next() : "";
        textArea.replaceText(0, 0, document);
    }

    Scene scene = new Scene(new StackPane(new VirtualizedScrollPane<>(textArea)), 600, 400);
    scene.getStylesheets().add(getClass().getResource("spellchecking.css").toExternalForm());
    primaryStage.setScene(scene);
    primaryStage.setTitle("Spell Checking Demo");
    primaryStage.show();
}
 
开发者ID:FXMisc,项目名称:RichTextFX,代码行数:36,代码来源:SpellChecking.java

示例10: setSourceText

import org.fxmisc.richtext.StyleClassedTextArea; //导入依赖的package包/类
public void setSourceText(StyleClassedTextArea sourceText){
    this.sourceText = sourceText;
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:4,代码来源:FindReplaceDialog.java

示例11: MdConvertController

import org.fxmisc.richtext.StyleClassedTextArea; //导入依赖的package包/类
public MdConvertController() {
    sourceText = new StyleClassedTextArea();
    sourceText.setStyle("markdown-editor");
    sourceText.setWrapText(true);
    vsPane = new VirtualizedScrollPane<>(sourceText);
}
 
开发者ID:firm1,项目名称:zest-writer,代码行数:7,代码来源:MdConvertController.java


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