How to change the color for HTML words in JEditorPane?

Hi Sir,
In the JTextPane , we could change the word's color by using:
Style style = doc.addStyle("test",null);
StyleConstants.setForeground(style, Color.red);
doc.setCharacterAttributes(10,20,syle,true);
we can change the text into red color,which range is from 10 to 30.
But how to change the color for HTML words in JEditorPane?

Hi,
you can use an AttributeSet to apply the foreground color. Let's say, doc is a HTMLDocument, then SimpleAttributeSet set = new SimpleAttributeSet();
doc.getStyleSheet().addCSSAttribute(set, CSS.Attribute.COLOR, "#0D0D0D"); would apply a color to a given AttributeSet. The AttributeSet with your color then can be applied to a selected range of text in a JEditorPane by   /**
   * set the attributes for a given editor. If a range of
   * text is selected, the attributes are applied to the selection.
   * If nothing is selected, the input attributes of the given
   * editor are set thus applying the given attributes to future
   * inputs.
   * @param editor  the editor pane to apply the attributes to
   * @param a  the set of attributes to apply
  public void applyAttributes(JEditorPane editor, AttributeSet a) {
    ((HTMLDocument) editor.getDocument()).getStyleSheet().addCSSAttribute(set, CSS.Attribute.COLOR, "#0D0D0D");
    editor.requestFocus();
    int start = editor.getSelectionStart();
    int end = editor.getSelectionEnd();
    if(end != start) {
      doc.setCharacterAttributes(start, end - start, a, false);
    else {
      MutableAttributeSet inputAttributes =
        ((SHTMLEditorKit) editor.getEditorKit()).getInputAttributes();
      inputAttributes.addAttributes(a);
  } Ulrich

Similar Messages

  • How to change the color for the af:messages by skins ?

    Hello All
    How i can change the text color for the af:messages by skins,i want change the color for the messages paragraph not for message header
    Because i know how to change the message header color text by
    .AFErrorTextForeground:alias
    color: Red;
    Error:
    1. You Must Select etc...
    2. Hello All
    i want to change the color nor for the header (Error) ,i want change it for the messages 1 and 2 and its text.
    Regards
    Mohammad Weshah
    )

    Hi Frank
    Unfortunately it dose not work.
    Any another options for this issue .
    Regards
    Mohd.Weshah

  • How to change the colors for individual bubbles in a bubble chart?

    I have a report where in a bubble chart needs to be shown with different colors for bubbles available in the chart. I cant find any option to select individual bubbles and format the color options.
    Any guidance or suggestions solving this would be much appreciated.
    Thanks,
    Vinay

    Thanks JB for your reply, I see in format chart data there is are two sections:
    1. Positional
    2. Conditional
    In Positional - I have the type and color changes for the bubbles but if I change any color in that all the bubbles are simultaneously getting the same color code.
    Not sure if there is any other setting. Please share me your thoughts on this.
    Thanks again

  • How to change the colors for Exceptions

    Can someone tell me how I can change the default colors that assigned to the Exceptions?
    Thanks.
    Ryan

    Hi Ryan,
    You can do it workbook-wise.
    First select a cell containing the colour you want to change.
    Then select icon 'Format' from BEx toolbar, select 'Pattern' and then colour required.
    Regards
    Joe

  • How  to change the Color for hyperlinks Xcode

    I ned help for that, i am a new and om woking to build apps

    Hi,
    you can use an AttributeSet to apply the foreground color. Let's say, doc is a HTMLDocument, then SimpleAttributeSet set = new SimpleAttributeSet();
    doc.getStyleSheet().addCSSAttribute(set, CSS.Attribute.COLOR, "#0D0D0D"); would apply a color to a given AttributeSet. The AttributeSet with your color then can be applied to a selected range of text in a JEditorPane by   /**
       * set the attributes for a given editor. If a range of
       * text is selected, the attributes are applied to the selection.
       * If nothing is selected, the input attributes of the given
       * editor are set thus applying the given attributes to future
       * inputs.
       * @param editor  the editor pane to apply the attributes to
       * @param a  the set of attributes to apply
      public void applyAttributes(JEditorPane editor, AttributeSet a) {
        ((HTMLDocument) editor.getDocument()).getStyleSheet().addCSSAttribute(set, CSS.Attribute.COLOR, "#0D0D0D");
        editor.requestFocus();
        int start = editor.getSelectionStart();
        int end = editor.getSelectionEnd();
        if(end != start) {
          doc.setCharacterAttributes(start, end - start, a, false);
        else {
          MutableAttributeSet inputAttributes =
            ((SHTMLEditorKit) editor.getEditorKit()).getInputAttributes();
          inputAttributes.addAttributes(a);
      } Ulrich

  • How to change the color background in Pages for iPad?

    how to change the color background in Pages for iPad?

    You can find many themes at https://github.com/hdoria/xcode-themes  There's a download zip button on the right side of the page.
    Unzip and and copy the .dvtcolortheme files into /Users/YourUsername/Library/Developer/XCode/UserData/FontAndColorThemes Create the directory if it doesn't exist.
    If you can't find the Library directory you can get to it by using Finder's "Go to Folder..." option under "Go" or press shift + cmd + G then type the path.

  • How to change the color of specific row in ALV tree

    Hi,
    I m using method set_table_for_first_display of a class CL_GUI_ALV_TREE.
    The req is to change the color of specific row. Now can anybody tell me how to change the color of ALV tree. As in ALV tree and in this method 'set_table_for_first_display', there is no parameter IS_Layout.
    Pls suggest...

    hi
    hope this code will help you.
    Reward if help.
    REPORT zsharad_test1.
    TABLES: ekko.
    TYPE-POOLS: slis. "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
    ebeln TYPE ekpo-ebeln,
    ebelp TYPE ekpo-ebelp,
    statu TYPE ekpo-statu,
    aedat TYPE ekpo-aedat,
    matnr TYPE ekpo-matnr,
    menge TYPE ekpo-menge,
    meins TYPE ekpo-meins,
    netpr TYPE ekpo-netpr,
    peinh TYPE ekpo-peinh,
    line_color(4) TYPE c, "Used to store row color attributes
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
    wa_ekko TYPE t_ekko.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE,
    gd_tab_group TYPE slis_t_sp_group_alv,
    gd_layout TYPE slis_layout_alv,
    gd_repid LIKE sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
    PERFORM data_retrieval.
    PERFORM build_fieldcatalog.
    PERFORM build_layout.
    PERFORM display_alv_report.
    *& Form BUILD_FIELDCATALOG
    Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
    There are a number of ways to create a fieldcat.
    For the purpose of this example i will build the fieldcatalog manualy
    by populating the internal table fields individually and then
    appending the rows. This method can be the most time consuming but can
    also allow you more control of the final product.
    Beware though, you need to ensure that all fields required are
    populated. When using some of functionality available via ALV, such as
    total. You may need to provide more information than if you were
    simply displaying the result
    I.e. Field type may be required in-order for
    the 'TOTAL' function to work.
    fieldcatalog-fieldname = 'EBELN'.
    fieldcatalog-seltext_m = 'Purchase Order'.
    fieldcatalog-col_pos = 0.
    fieldcatalog-outputlen = 10.
    fieldcatalog-emphasize = 'X'.
    fieldcatalog-key = 'X'.
    fieldcatalog-do_sum = 'X'.
    fieldcatalog-no_zero = 'X'.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'EBELP'.
    fieldcatalog-seltext_m = 'PO Item'.
    fieldcatalog-col_pos = 1.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'STATU'.
    fieldcatalog-seltext_m = 'Status'.
    fieldcatalog-col_pos = 2.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'AEDAT'.
    fieldcatalog-seltext_m = 'Item change date'.
    fieldcatalog-col_pos = 3.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'MATNR'.
    fieldcatalog-seltext_m = 'Material Number'.
    fieldcatalog-col_pos = 4.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'MENGE'.
    fieldcatalog-seltext_m = 'PO quantity'.
    fieldcatalog-col_pos = 5.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'MEINS'.
    fieldcatalog-seltext_m = 'Order Unit'.
    fieldcatalog-col_pos = 6.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'NETPR'.
    fieldcatalog-seltext_m = 'Net Price'.
    fieldcatalog-col_pos = 7.
    fieldcatalog-outputlen = 15.
    fieldcatalog-datatype = 'CURR'.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    fieldcatalog-fieldname = 'PEINH'.
    fieldcatalog-seltext_m = 'Price Unit'.
    fieldcatalog-col_pos = 8.
    APPEND fieldcatalog TO fieldcatalog.
    CLEAR fieldcatalog.
    ENDFORM. " BUILD_FIELDCATALOG
    *& Form BUILD_LAYOUT
    Build layout for ALV grid report
    FORM build_layout.
    gd_layout-no_input = 'X'.
    gd_layout-colwidth_optimize = 'X'.
    gd_layout-totals_text = 'Totals'(201).
    Set layout field for row attributes(i.e. color)
    gd_layout-info_fieldname = 'LINE_COLOR'.
    gd_layout-totals_only = 'X'.
    gd_layout-f2code = 'DISP'. "Sets fcode for when double
    "click(press f2)
    gd_layout-zebra = 'X'.
    gd_layout-group_change_edit = 'X'.
    gd_layout-header_text = 'helllllo'.
    ENDFORM. " BUILD_LAYOUT
    *& Form DISPLAY_ALV_REPORT
    Display report using ALV grid
    FORM display_alv_report.
    gd_repid = sy-repid.
    CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
    EXPORTING
    i_callback_program = gd_repid
    i_callback_top_of_page = 'TOP-OF-PAGE' "see FORM
    i_callback_user_command = 'USER_COMMAND'
    i_grid_title = outtext
    is_layout = gd_layout
    it_fieldcat = fieldcatalog[]
    it_special_groups = gd_tabgroup
    IT_EVENTS = GT_XEVENTS
    i_save = 'X'
    is_variant = z_template
    TABLES
    t_outtab = it_ekko
    EXCEPTIONS
    program_error = 1
    OTHERS = 2.
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
    ENDFORM. " DISPLAY_ALV_REPORT
    *& Form DATA_RETRIEVAL
    Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
    DATA: ld_color(1) TYPE c.
    SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
    UP TO 10 ROWS
    FROM ekpo
    INTO TABLE it_ekko.
    *Populate field with color attributes
    LOOP AT it_ekko INTO wa_ekko.
    Populate color variable with colour properties
    Char 1 = C (This is a color property)
    Char 2 = 3 (Color codes: 1 - 7)
    Char 3 = Intensified on/off ( 1 or 0 )
    Char 4 = Inverse display on/off ( 1 or 0 )
    i.e. wa_ekko-line_color = 'C410'
    ld_color = ld_color + 1.
    Only 7 colours so need to reset color value
    IF ld_color = 8.
    ld_color = 1.
    ENDIF.
    CONCATENATE 'C' ld_color '10' INTO wa_ekko-line_color.
    wa_ekko-line_color = 'C410'.
    MODIFY it_ekko FROM wa_ekko.
    ENDLOOP.
    ENDFORM. " DATA_RETRIEVAL

  • How to change the color of SAP screen?

    Hi Frens,
    I know it has nothing to do with SD Community, but still I am asking. Can anyone tell me "How to change the color of SAP screen?" It is needed especially when you are working on System Landscape including PRD, Qua & Dev. There are chances that you end up making a test case in PRD instead of Dev or Qua. To avoid that, different color of SAP screen may be very useful and safe.
    Regards
    Vikas Chhabra
    SD/CIN Consultant

    We had a clone of SAP for testing
    Only GUIXT solution was available for users to distinguish between real Prod & Clone as SID was same
    Created 2 scripts n C:\guixt\scripts
    saplsmtr_navigation.e0100.txt
    Esession.txt
    BOTH having identical code
    if V[_ashost=10.3.3.18]
      TitlePrefix "CLONE18"
      TitleSuffix "(CLONE8)"
    endif
    if V[_ashost=10.3.3.25]
      TitlePrefix "PROD25"
      TitleSuffix "(PROD25)"
    endif
    After much research - this was only solution.
    GUIXT will be around; like SAPSCRIPT & SMARTFORMS
    despite the enticement of Adobe Forms!
    After some time you may set GUIXT profile start window HIDDEN
    This you do by clicking profile button of GUIXT menu
    If you want to see GUIXT Window again
    CMD.exe Dos prompt
    cd C:\Program Files\SAP\FrontEnd\SAPgui
    guixt visible
    Regards
    Jayanta Narayan Choudhuri
    Kolkata
    URL: http://ojnc.byethost11.com

  • How to change the color of SOLIDS ?

    Hi there,
    In the Effects panel, I select the color solids, we only have green and a few colors. I chose the green one as the background.
    Then I wanna choose my own color by changing the color of the green but my eyes are blind, I cannot find where the selection are ?
    Can anyone be kind enuf to let me know where the switch is ? How to change the color of the solids to be used as background ?
    Thanks
    Chers

    Luis Sequeira1 wrote:
    Drag your generator to the timeline. Select int. Look at the Inspector, in the top right corner (if the inspector is not open, you can use Cmd-4 to open it). At the top of the inspector, you have three buttons: "Generator", "Video", and "Info". Click on "Generator" and you get a drop down menu allowing you to choose one of six colors.
    If none of these six serves you well, you can then click on "Video", and use the Color tools to set it to anything you want.
    Thanks Luis for your detailed explanation ... it worked !

  • How to change the color of the text field of form

    Hi ,
    Is there any way to change the color of the text field of the form........
    Thnx in advance .......
    Cheers,
    Eman

    Hi Bob. I'm new to these forums and I'm not sure of protocol and exactly how this is supposed to work, so If I'm doing this wrong then please excuse me and let me know.
    I liked you solution on 'How to change the color of an Item on a form' using <blink>.
    I'm new to this application and coding as well so its kind of foreign to me.
    Working on a Report Page,
    I would like to have item, :P1_JOB_NO blink when the difference between sysdate and :P1_DATE_DUE < 7 days.
    I can identify the job_no which should blink by using the sql statement:
    SQL> select job_no from oax_projects07 where
    2 (sysdate - date_due < 7) and
    3 emp_name = 'GARY PILKENTON';
    JOB_NO
    20060627 050
    But I dont know the proper syntax to make it blink,
    or when to plug the syntax into.
    ie, is it a process, a validation, etc.
    Do you have any advice for me?

  • BI BEANS - Graph - How to change the color .. please help

    Hi Everyone,
    Can anyone please tell me how to change the color of the Graph bars or slices. I mean the color which represents the data.
    For example in a pie chart I want to set specific color for specific slice. Please help.
    Regards
    SRT

    It seems to be the SET_SERIE_COLOR() method added to the FormsGraph revised version, but this latest version is momentarily not available for download.
    I think there is an existant open thread on this. Maybe you could find it using the Forum Search box.
    Francois

  • May I know how to change the color of texts inside the indicator box?

    Can anyone tell me how to change the color of texts inside the indicator box? I have tried to use property node but not really know how it functions.
    In fact, I am writing a program for which the number inside indicator on front panel will show red color if the measured value can't reach the requirement. I am using LabView 6.1 Professional
    Thank You for your attention!!!!!!

    Simply use a property node with "NumText.TextColor" and wire the correct color depending on your test result.
    The attached simple example (LV 6.1) lets you change it from the front panel. In your case, you would use your test output instead of a FP switch, of course. Message Edited by altenbach on 05-25-2005 09:05 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    TextColor.vi ‏18 KB

  • How to change the color of Menu links in obiee

    Does anyone knows how to change the colors of Menu links in obiee. With menu I mean the menu links default right top (Search, homepage, Catalogus, Dashboards, new, Open). This should be set in skin and style files, not? I searched a lot. I could not find It. It is now Oracle blue, we want to change this.
    obiee 11.1.1.5.
    Thanks

    You have to customize portal banner and portal content CSS files as needed in OBIEE server.
    below links will guide u but will will not tell you exactly but your req can be done by customizing portal content and portal banner CSS files. try to identify the exact code using firebug in mozilla.
    http://www.rittmanmead.com/2009/04/customizing-obiee-dashboard-banners/
    Customization of login page, banner,logo in obiee11g
    Thanks
    Jay.

  • How to change a color for a row in ALV grid display

    Hi,
       how to change a color for a row in ALV grid display based on a condition.Any sample code plz

    Hello Ramya,
    Did you check in [SCN|How to color a row of  alv grid]
    Thanks!

  • I cannot find how to change the language for labels in a quiz

    I cannot find how to change the language for labels in a quiz

    You have to be aware that this will only change labels if you edit before adding quiz slides: Preferences, Quiz, Default Labels. You will have to edit the labels, choosing another language will not change them automatically.

Maybe you are looking for

  • HELPP!

    okay the lcd screen keeps blinking on and off what should i do? what happened to it? i just unplugged it from the usb but yea i forgot to eject first.. and now its just dead HELPP

  • Cascade update of primary key in child tables

    Hi, We have a typical scenario in which the primary key has to propage to the child table into 3 levels. We are getting the no parent key exception if we create new data into the three tables using 3 level master detail relationship and execute commi

  • One TV keeps getting message this channel not available

    OK so one TV an older one, in my home keeps getting the message this channel not available.  I went through ll the trouble shooting steps.  My other two TVs are fine but they are new one's.  This is my grandpas' old one.

  • Pixma Pro-100 re-install

    I'm having bizarre color rendering issues with my printer. Printing from Photoshop CS 5 and using Canon photo paper, correct ICC profiles, latest driver, and following Canon's own procedures for Photoshop CS 5. I understand Canon Pro printers are on

  • Changing Multiple Smart Playlists View Options

    Hello I have lots of smart playlists in different folders in my iTunes Library. Is there any way to change the view options for multiple smart playlists in iTunes 10? Many Thanks Shaun