Results 1 to 6 of 6
  1. #1
    charles is offline Member
    Join Date
    Oct 2016
    Posts
    3
    Rep Power
    0

    Default jEditorPane question

    Well, I'm new to the forum and java in general so I'm a bit lost.

    My problem is that I'm using a jEditorPane in netbeans and I want to change the font only of the selected text. Is it possible? if it is, how can I do it ?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: jEditorPane question

    Can you post a small example of the code you are working on. Something that compiles and executes and shows the problem.
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    charles is offline Member
    Join Date
    Oct 2016
    Posts
    3
    Rep Power
    0

    Default Re: jEditorPane question

    private void jCBFuentesActionPerformed(java.awt.event.ActionEve nt evt) {
    jEPDoc.setFont(new Font(jCB1.getSelectedItem().toString(), Font.PLAIN, Integer.parseInt(jCB2.getSelectedItem().toString() )));
    }
    That's what changes the font currently on the editor pane, but I don't know how to do that only to selected text.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: jEditorPane question

    I suspect the selected text needs to be wrapped in html that sets its font.
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    charles is offline Member
    Join Date
    Oct 2016
    Posts
    3
    Rep Power
    0

    Default Re: jEditorPane question

    Sorry but I'm new to java, so I don't know what that means, could you explain a bit please?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    20,003
    Rep Power
    33

    Default Re: jEditorPane question

    Here's a sample of a String with some text wrapped in html:
    Java Code:
                String text = "<html><div style='color:red'>This should be in red</div></html>";
    I'm new to java
    This project will take some research to find a solution. You need to look at the Java tutorial for explanations and sample code. See the tutorial. http://docs.oracle.com/javase/tutori...ditorpane.html
    Last edited by Norm; 10-19-2016 at 01:48 AM.
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. set jEditorPane css problem
    By jasonwucinski in forum New To Java
    Replies: 1
    Last Post: 04-15-2011, 08:35 PM
  2. [SOLVED] JEditorPane bug?
    By shwein in forum Networking
    Replies: 10
    Last Post: 04-01-2009, 12:36 PM
  3. JEditorPane Example
    By Java Tip in forum javax.swing
    Replies: 0
    Last Post: 06-27-2008, 07:47 PM
  4. insertHTML in a JEditorPane
    By olbion in forum New To Java
    Replies: 1
    Last Post: 05-05-2008, 12:30 PM
  5. JEditorPane
    By drmmr11 in forum Java Applets
    Replies: 0
    Last Post: 08-02-2007, 06:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •