Example usage for javax.swing JTextPane putClientProperty

List of usage examples for javax.swing JTextPane putClientProperty

Introduction

In this page you can find the example usage for javax.swing JTextPane putClientProperty.

Prototype

public final void putClientProperty(Object key, Object value) 

Source Link

Document

Adds an arbitrary key/value "client property" to this component.

Usage

From source file:Main.java

public Main() {
    super(BoxLayout.Y_AXIS);
    try {//  w ww . j  av a2s.  c  om
        for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                UIManager.setLookAndFeel(info.getClassName());
                System.out.println("set");
                break;
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    Object o = UIManager.get("TextArea[Enabled+NotInScrollPane].borderPainter");

    UIDefaults paneDefaults = new UIDefaults();
    paneDefaults.put("TextPane.borderPainter", o);

    JTextPane pane = new JTextPane();
    pane.setMargin(new Insets(10, 10, 10, 10));

    pane.putClientProperty("Nimbus.Overrides", paneDefaults);
    pane.putClientProperty("Nimbus.Overrides.InheritDefaults", false);
    pane.setText("this \nis \na \ntest\n");
    add(pane);

}

From source file:org.languagetool.gui.ResultAreaHelper.java

static void install(ResourceBundle messages, LanguageToolSupport ltSupport, JTextPane pane) {
    Object prev = pane.getClientProperty(KEY);
    if (prev != null && prev instanceof ResultAreaHelper) {
        enable(pane);/*from  w w  w .  j a  v  a  2  s.com*/
        return;
    }
    ResultAreaHelper helper = new ResultAreaHelper(messages, ltSupport, pane);
    pane.putClientProperty(KEY, helper);
}

From source file:org.languagetool.gui.ResultAreaHelper.java

static void uninstall(JTextPane pane) {
    Object helper = pane.getClientProperty(KEY);
    if (helper != null && helper instanceof ResultAreaHelper) {
        ((ResultAreaHelper) helper).disable();
        pane.putClientProperty(KEY, null);
    }/* w ww.jav a2s .  c  o  m*/
}

From source file:org.owasp.jbrofuzz.fuzz.ui.FuzzingPanel.java

private JTextPane createEditablePane() {

    JTextPane textPane = new JTextPane();

    // Get the preferences for wrapping lines of text
    final boolean wrapText = JBroFuzz.PREFS.getBoolean(JBroFuzzPrefs.FUZZING[2].getId(), false);

    if (wrapText) {
        textPane = new JTextPane();
    } else {/*  w  ww  .  j  ava 2s  .  c o  m*/
        textPane = new NonWrappingTextPane();
    }

    textPane.putClientProperty("charset", "UTF-8");
    textPane.setEditable(true);
    textPane.setVisible(true);
    textPane.setFont(new Font("Verdana", Font.PLAIN, 12));
    textPane.setMargin(new Insets(1, 1, 1, 1));
    textPane.setBackground(Color.WHITE);
    textPane.setForeground(Color.BLACK);

    // Set the editor kit responsible for highlighting
    textPane.setEditorKit(new StyledEditorKit() {

        private static final long serialVersionUID = -6085642347022880064L;

        public Document createDefaultDocument() {
            return new TextHighlighter();
        }

    });

    // Right click: Cut, Copy, Paste, Select All
    RightClickPopups.rightClickRequestTextComponent(this, textPane);

    return textPane;
}