Example usage for javax.swing JEditorPane requestFocus

List of usage examples for javax.swing JEditorPane requestFocus

Introduction

In this page you can find the example usage for javax.swing JEditorPane requestFocus.

Prototype

public void requestFocus() 

Source Link

Document

Requests that this Component gets the input focus.

Usage

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatPanel.java

/**
 * Pastes the content of the clipboard to the write area.
 *//*from  www.j av a  2 s .c o  m*/
public void paste() {
    JEditorPane editorPane = this.writeMessagePanel.getEditorPane();

    editorPane.paste();

    editorPane.requestFocus();
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatPanel.java

/**
 * Shows the font chooser dialog/*from ww w . j a v a 2s .co m*/
 */
public void showFontChooserDialog() {
    JEditorPane editorPane = writeMessagePanel.getEditorPane();
    FontChooser fontChooser = new FontChooser();

    int result = fontChooser.showDialog(this);

    if (result != FontChooser.CANCEL_OPTION) {
        String fontFamily = fontChooser.getFontFamily();
        int fontSize = fontChooser.getFontSize();
        boolean isBold = fontChooser.isBoldStyleSelected();
        boolean isItalic = fontChooser.isItalicStyleSelected();
        boolean isUnderline = fontChooser.isUnderlineStyleSelected();
        Color fontColor = fontChooser.getFontColor();

        // Font family and size
        writeMessagePanel.setFontFamilyAndSize(fontFamily, fontSize);

        // Font style
        writeMessagePanel.setBoldStyleEnable(isBold);
        writeMessagePanel.setItalicStyleEnable(isItalic);
        writeMessagePanel.setUnderlineStyleEnable(isUnderline);

        // Font color
        writeMessagePanel.setFontColor(fontColor);

        writeMessagePanel.saveDefaultFontConfiguration(fontFamily, fontSize, isBold, isItalic, isUnderline,
                fontColor);
    }

    editorPane.requestFocus();
}