wbk727
wbk727

Reputation: 8408

Change font style of highlighted text java

Below is the code I have to set all text within my text pane to bold but how can I get only the text that I have highlighted to be bold and achieve the following?

private void jButtonBoldActionPerformed(java.awt.event.ActionEvent evt) {                                              
    // TODO add your handling code here:
    jTextPaneBody.setFont(jTextPaneBody.getFont().deriveFont(Font.BOLD));
}

Upvotes: 1

Views: 635

Answers (1)

ControlAltDel
ControlAltDel

Reputation: 35011

Can't be done with a (J)TextField. If you need this functionality, you can use a JTextPane with a StyledEditorKit and a StyledDocument

Upvotes: 1

Related Questions