How to print different colors of Strings into JEditorpane?

How to print different colors of Strings into JEditorpane?
Can any body give me answer ...

JEditorPane contain HTML. So write your HTML using the color attribute.
Start by read the the API description of JEditorPane. you will find a link to the Swing tutorial on "Using Text Components" which has working examples of using a JEditorPane. It also has an example of using a JTextPane where you can dynamically change the attributes of individual pieces of text.

Similar Messages

  • How to print different pages of sap script  from diff. trays of printer

    Hi All,
    I have the requirement in SAP script. How to print different pages from different trays in the printer.
    For example  page 1 logo and address has to print from tray-1,
                        page 2 main data print from tray-2,
                        page 3 footer data print from tray-3.
    will appreciate if u come up with solutions asap.
    Thanks in advance.

    Hi,
    May be the links given below might help you,
    SAPScript:Selecting Different Tray in SAPscript
    Print to different output tray in SAPscript/Print Workbench
    Regards,
    Hema.
    Reward points if it is useful.

  • How to read and write a string into a txt.file

    Hi, I am now using BEA Workshop for Weblogic Platform version10. I am using J2EE is my programming language. The problem I encounter is as the above title; how to read and write a string into a txt.file with a specific root directory? Do you have any sample codes to reference?
    I hope someone can answer my question as soon as possible
    Thank you very much.

    Accessing the file system directly from a web app is a bad idea for several reasons. See http://weblogs.java.net/blog/simongbrown/archive/2003/10/file_access_in.html for a great discussion of the topic.
    On Weblogic there seems to be two ways to access files. First, use a File T3 connector from the console. Second, use java.net.URL with the file: protocol. The T3File object has been deprecated and suggests:
    Deprecated in WebLogic Server 6.1. Use java.net.URL.openConnection() instead.
    Edited by: m0smith on Mar 12, 2008 5:18 PM

  • Does anyone know how to print in color on a pages on Pages on a MacBook Pro?

    I have a project that I need to print out, and I recently just got a MacBook Pro, so I'm not 100% acquainted to Pages. SO PLEASE HELP!!!!

    Any application can print in color, which is the default, if a color-capable printer is configured and accessible by the Mac. It is no different than printing in B/W.
    Just make sure the printer is set up correctly so the Mac knows what it can do and how to drive it. If you want more help in the set up department, you'll have to provide more info as to what printer(s) you have.

  • How to set different color for items in selectManyCheckbox

    hi,
    I would like to change item text background color for each item on selectManyCheckbox (different for each item).
    It is only 5 items so that could be static reference or select.
    I know only how to change background for all items
    af|selectManyCheckbox::item-text {
        background:orange;
    How to select concrete item text and change color for only them?
    I found similar problem:
    css - Set background color of every individual checkbox of p:selectManyCheckbox - Stack Overflow
    but this dont work for me because I dont have in adf tr structure
    I need somethink like this:
    af|selectManyCheckbox::item-text XXXX - select here one of the item by number on list or id  {
        background:orange;

    hi,
    thanks Alejandro and Federico for answers.
    I use JDev 11.1.1.6. I dont write it in previously post because I think that is a more css then adf problem.
    I have 5 selectItem based on simple List<String> {"text1", "text2", "text3", "text4". "text5"}:
    <af:selectManyCheckbox label="List" id="smc2"
                                               layout="horizontal"
                                               value="#{bean.listInBean}"
                                               autoSubmit="true">
                          <af:selectItem label="text1" value="text1" id="si47"/>
                          <af:selectItem label="text2" value="text2" id="si43"/>
                          <af:selectItem label="text3" value="text3" id="si46"/>
                          <af:selectItem label="text4" value="text4" id="si45"/>
                          <af:selectItem label="text5" value="text5" id="si44"/>
                        </af:selectManyCheckbox>
    and I would like to color first selectItem text to orange, second to red.. etc, The list is a static list. Not would be changed.
    After Alejandro answer I build simple for each element (anyCollection contains item with two fields: textValue and label {(text1,text1), (text2,text2)...}
      <af:forEach items="#{bean.anyCollection}"
                                      var="item">
                            <af:selectItem id="si48" value="#{item.textValue}"  styleClass="yourClassName#{var.index}"
                                           label="#{item.label}"/>
                          </af:forEach>
    And now if I have my var called "item" I can write 5 css style classe yourClassName#{var.index} with different color, but there is a problem:
    Attribute styleClass is not defined for af:selectItem
    If it will be so simple I will just add 5 style classes for each selectItem
    <af:selectItem label="text1" value="text1" id="si47" styleClass="yourClassName0"/>
    <af:selectItem label="text2" value="text2" id="si43" styleClass="yourClassName1"/>
    Should I use other component then adf facer rich?

  • Same logo printing different colors for different file formats?

    I created a logo for a client who will be using it for some printed materials.  I provided the logo in 3 different file formats: EPS, JPEG and Tiff.
    In INDesign and MS Word, the logo is printing a different color for the EPS vs the Jpeg/Tiff file types.  Is there something I'm missing?
    I've even tried changing the color to something completely different and we are getting the same result.  There is STiLL a considerable difference between the Eps file and the other two files.

    No the logo was created for print and I originally had used a pantone color but converted to CMYK.  The actual value is C69 M7 Y0 K0.  When my client inserts the eps file into her InDesign layout, it prints a bright aqua color and if she uses either the jpeg or tiff, it is a much different blue.  We've tried other colors because I was thinking it might just be the fact that it's a blue color... but the same thing happens to other colors. I am wondering if there is some sort of color management setting that is causing the eps to be different?

  • How to set different color text in JTabe cell

    Hi
    I have been searching many forums to find how can this be done, but no success.
    I have Custom JTable with MyTableRenderer which is nothing else but alternate the color of rows(cells), CustomTableModel extends DefaultTableModel adding functionality for updateCellContent with different messages.
    I have a column in which cells i want to set these messages in different color.They are not set by user's editing, and by updating the content using the table model.
    Here is the code for that
    public void updateCellContent(HashMap<String, String> messages, int col) {
            for (int row = 0; row < this.dataVector.size() - 1; row++) {
                //This value is hardcoded for now.
                boolean isError = true;
                String filename = getFilename(row);
                String message = messages.get(filename);
                if (message != null) {
                    if (isError) {
                        setErrorMessage(message, row);
                    } else {
                        setMessage(message, row);
        private void setErrorMessage(String message, int row) {
            this.setFileStatus(message, row);
        private void setMessage(String message, int row) {
            String value = (String) this.getValueAt(row, COL_FILE_STATUS);
            ((Vector) this.dataVector.get(row)).setElementAt(value + " " + message, COL_FILE_STATUS);
            fireTableCellUpdated(row, COL_FILE_STATUS);
    public void setFileStatus(String message, int row) {
            setValueAt(message, row, COL_FILE_STATUS);
        }Thanks
    Dimitar

    I have Custom JTable with MyTableRenderer which is nothing else but alternate the color of rows(cells)If I understand you correctly a better way to do this is to override the prepareRenderer(...) method of JTable. You can search the forum for my "Table Prepare Renderer" (without the spaces) example which shows how this can be done.
    I have a column in which cells i want to set these messages in different color.Then you need to use a custom renderer for that column.
    If you need further help then you need to create a [Short, Self Contained, Compilable and Executable, Example Program (SSCCE)|http://homepage1.nifty.com/algafield/sscce.html], that demonstrates the incorrect behaviour.

  • How to highlight different color in bar chart above the mark

    Hi friends,
    I have a bar chart in which im displaying it in blue color in obiee 11g. In graph properties i have set a scale marker to the point 4000, so that a line is appearing horizontally at the point 4000 in the bar chart. My chart is exceeding above 4000, as it reaches upto 5000.
    I need to set a color to the graph such that from *0-4000, i need to have one color* and above from 4000-5000 i need to highlight it with a different color.
    How to possible it to highlight with different color above that *4000 mark in my bar chart*.
    Thanks
    All izz Well
    GTA

    From your initial post I thought you meant you wanted to change the colour of the bit above the line for every bar that went over the line.
    The solution above works because stacked bar will use different colours for different measures - by splitting your original measure into one measure for the data up to the line and another measure for any data above the line you achieve this. Bars that don't cross the line will only show one colour, bars that do cross the line will show two.
    eg
    original measure/new measure 1/new measure 2
    2000/2000/0
    3000/3000/0
    5000/4000/1000
    5500/4000/1500
    The other scenario is that you want the whole bar to be coloured if it crosses the line. If that's the case then there is a conditional formatting section under graph properties->style->style and conditional formatting.
    Regards,
    Robert

  • How to print red color in plain paper?

    When printed on glossy papers, red color (in photo or text) looks great.
    When I print on non-photo, plain papers, red color came out brownish.
    I tried on premium ink jet papers, it does not print red but in brown color.
    How can I print red color in plain paper?

    When dealing with printing ink, R=100m+100y+0c+0k. What drives the color toward rust, maroon, and brown is the addition of c to the mix. That may be the result of the diffuse reflection of the uncoated paper surface, its absorb rate, the ink chemistry and – the light source. Since the easiest variable to test is the light source, look at that color using a source weak in blue emission, incandescent light, and watch the red shift. Remember also that the reflected color will never be as bright as paper it is printed on. Each ink film is a filter subtracting light from the paper reflection.  
    Shown above (with a mode change to RGB for the purpose of this display) is its version of 100 each of m+ y  and a patch with the unwanted c

  • How to insert a very long string into a column of datatype 'LONG'

    Can anyone please tell me how can I insert a very long string into a column of datatype 'LONG'?
    I get the error, ORA-01704: string literal too long when I try to insert the value into the table.
    Since it is an old database, I cannot change the datatype of the column. And I see that the this column already contains strings which are very long.
    I know this can be done using bind variables but dont know how to use it in a simple query.
    Also is there any other way to do it?

    Hello,
    To preserve formatting in this forum, please enclose your code output between \ tags. And when executing you code as a pl/sql or sql script
    include following lineset define off;
         Your code or output goes here
      \Regards
    OrionNet                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to print in color

    What setting do I need to change to print in color on a color printer - everything is printing B/W?

    or maybe this one --
    http://www.cpierce.org/2011/07/getting-dell-5100cn-to-work-with-os-x-lion/

  • How to print in color not black

    it appears my black ink is empty.  is there any way to print what i need in color?  they're online forms/instructions that i need to print.
    plz help!!
    ty
    This question was solved.
    View Solution.

    Hi,
    It is possible to print in black only, it is impossible however to print with color inks only as the black color is also the base for for color printing.
    Ensure the Black ink is empty indeed by checking the Estimated ink levels on the printer screen.
    If it is empty you will need to replace the depleted cartridge to resume printing.
    Shlomi
    Say thanks by clicking the Kudos thumb up in the post.
    If my post resolve your problem please mark it as an Accepted Solution

  • How to apply different colors to specific rows in JTable

    hi,
    Anybody could tell me the way of colorising the rows in jtable.. I want to apply different colors to diff rows..
    If i get a piece of code that could help me a lot..
    thanks in advance,
    Sapna

    you'll find the answer at http://www2.gol.com/users/tame/swing/examples/SwingExamples.html

  • How to set different colors for even odd rows in a data table

    hi,
    In my project i hav a data table. i am using jsf. i want the rows of the data table different colors for even, odd rows. can i do it just setting the row class property ? or there should be there some other way? please help.
    sailajoy

    Hope this helps
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-loose.dtd">
    <html>
    <head>
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <title></title>
    <style type='text/css'>
    .scrollContent {
    height:100px;
    overflow-x:hidden;
    overflow-y:auto;
    .scrollContent tr {
    height: auto;
    white-space: nowrap;
    .scrollContent tr td:last-child {
    padding-right: 20px;
    .fixedHeader tr {
    position: relative;
    height: auto;
    top: expression( this.parentNode.parentNode.parentNode.scrollTop + 'px' );
    div.TableContainer {
    border: 1px solid #7DA87D;
    .headerFormat {
    background-color: white;
    color: #C8D7B5;
    margin: 3px;
    padding: 1px;
    white-space: nowrap;
    font-family: Helvetica;
    font-size: 16px;
    text-decoration: none;
    font-weight: bold;
    .headerFormat tr td {
    border: 1px solid #C8D7B5;
    background-color: #666633;
    .bodyFormat tr td {
         color: #000000;
         margin: 3px;
         padding: 1px;
         border: 0px none;
         font-family: Helvetica;
         font-size: 12px;
    .alternateRow {
    background-color: #C8D7B5;
    </style>
    <style type="text/css">
    div.TableContainer {
    height: 121px;
    overflow-x:hidden;
    overflow-y:auto;
    </style>
    </head>
    <body>
    <table cellpadding="0" cellspacing="0" border="0"><tr><td><div id="TableContainer" class="TableContainer" style="height:230px;">
    <table class="scrollTable">
    <thead class="fixedHeader headerFormat">
    <tr class="title">
    <td title="Sort" align="center"><b>NAME</b> </td>
    <td title="Sort" align="center"><b>Amt</b> </td>
    <td title="Sort" align="center"><b>Lvl</b> </td>
    <td title="Sort" align="center"><b>Rank</b> </td>
    <td title="Sort" align="center"><b>Position</b> </td>
    <td title="Sort" align="center"><b>Date</b></td>
    </tr>
    </thead>
    <tbody class="scrollContent bodyFormat" style="height:200px;">
    <tr class="alternateRow">
    <td>Maha</td>
    <td>
    <input type="text" name="textfield" size="7" />
    </td>
    <td align="right"><input type="text" name="textfield2" size="7" /></td>
    <td align="right"><input type="text" name="textfield3" size="7" /></td>
    <td><input type="text" name="textfield4" size="7" /></td>
    <td align="right"><input type="text" name="textfield5" size="7" /></td>
    </tr>
    <tr>
    <td>Thrawl</td>
    <td align="right">$9,550</td>
    <td align="right">159</td>
    <td align="right">100%</td>
    <td>Co-Owner</td>
    <td align="right">11/07/2003</td>
    </tr>
    <tr class="alternateRow">
    <td>Marhanen</td>
    <td align="right">$223.04</td>
    <td align="right">83</td>
    <td align="right">99%</td>
    <td>Banker</td>
    <td align="right">06/27/2006</td>
    </tr>
    <tr>
    <td>Peter</td>
    <td align="right">$121</td>
    <td align="right">567</td>
    <td align="right">23423%</td>
    <td>FishHead</td>
    <td align="right">06/06/2006</td>
    </tr>
    <tr class="alternateRow">
    <td>Jones</td>
    <td align="right">$15</td>
    <td align="right">11</td>
    <td align="right">15%</td>
    <td>Bubba</td>
    <td align="right">10/27/2005</td>
    </tr>
    <tr>
    <td>Supa-De-Dupa</td>
    <td align="right">$145</td>
    <td align="right">91</td>
    <td align="right">32%</td>
    <td>momma</td>
    <td align="right">12/15/1996</td>
    </tr>
    <tr class="alternateRow">
    <td>ClickClock</td>
    <td align="right">$1,213</td>
    <td align="right">23</td>
    <td align="right">1%</td>
    <td>Dada</td>
    <td align="right">1/30/1998</td>
    </tr>
    <tr>
    <td>Mrs. Robinson</td>
    <td align="right">$99</td>
    <td align="right">99</td>
    <td align="right">99%</td>
    <td>Wife</td>
    <td align="right">07/04/1963</td>
    </tr>
    <tr class="alternateRow">
    <td>Maha</td>
    <td align="right">$19,923.19</td>
    <td align="right">100</td>
    <td align="right">100%</td>
    <td>Owner</td>
    <td align="right">01/02/2001</td>
    </tr>
    <tr>
    <td>Thrawl</td>
    <td align="right">$9,550</td>
    <td align="right">159</td>
    <td align="right">100%</td>
    <td>Co-Owner</td>
    <td align="right">11/07/2003</td>
    </tr>
    <tr class="alternateRow">
    <td>Marhanen</td>
    <td align="right">$223.04</td>
    <td align="right">83</td>
    <td align="right">59%</td>
    <td>Banker</td>
    <td align="right">06/27/2006</td>
    </tr>
    <tr>
    <td>Peter</td>
    <td align="right">$121</td>
    <td align="right">567</td>
    <td align="right">534.23%</td>
    <td>FishHead</td>
    <td align="right">06/06/2006</td>
    </tr>
    <tr class="alternateRow">
    <td>Jones</td>
    <td align="right">$15</td>
    <td align="right">11</td>
    <td align="right">15%</td>
    <td>Bubba</td>
    <td align="right">10/27/2005</td>
    </tr>
    <tr>
    <td>Supa-De-Dupa</td>
    <td align="right">$145</td>
    <td align="right">91</td>
    <td align="right">42%</td>
    <td>momma</td>
    <td align="right">12/15/1996</td>
    </tr>
    <tr class="alternateRow">
    <td>ClickClock</td>
    <td align="right">$1,213</td>
    <td align="right">23</td>
    <td align="right">2%</td>
    <td>Dada</td>
    <td align="right">1/30/1998</td>
    </tr>
    <tr>
    <td>Mrs. Robinson</td>
    <td align="right">$99</td>
    <td align="right">99</td>
    <td align="right">(-10.42%)</td>
    <td>Wife</td>
    <td align="right">07/04/1963</td>
    </tr>
    <tr class="alternateRow">
    <td>Maha</td>
    <td align="right">-$19,923.19</td>
    <td align="right">100</td>
    <td align="right">(-10.01%)</td>
    <td>Owner</td>
    <td align="right">01/02/2001</td>
    </tr>
    <tr >
    <td>Thrawl</td>
    <td align="right">$9,550</td>
    <td align="right">159</td>
    <td align="right">-10.20%</td>
    <td>Co-Owner</td>
    <td align="right">11/07/2003</td>
    </tr>
    <tr class="alternateRow" >
    <td><strong>TOTAL</strong>:</td>
    <td align="right"><strong>999999</strong></td>
    <td align="right"><strong>9999999</strong></td>
    <td align="right"><strong>99</strong></td>
    <td > </td>
    <td align="right"> </td>
    </tr>
    </tbody>
    </table>
    </div></td></tr></table>
    </body>
    </html>

  • How to print diffrent color and diffrent size of text in JTextArea ?

    Hello All,
    i want to make JFrame which have JTextArea and i append text in
    JTextArea in diffrent size and diffrent color and also with diffrent
    fonts.
    any body give me any example or help me ?
    i m thanksfull.
    Arif.

    You can't have multiple text attributes in a JTextArea.
    JTextArea manages a "text/plain" content type document that can't hold information about attributes ( color, font, size, etc.) for different portions of text.
    You need a component that can manage styled documents. The most basic component that can do this is JEditorPane. It can manage the following content types :
    "text/rtf" ==> via StyledDocument
    "text/html" ==> via HTMLDocument
    I've written for you an example of how a "Hello World" string could be colorized in a JEditorPane with "Hello" in red and "World" in blue.
    import javax.swing.JEditorPane;
    import javax.swing.text.StyleConstants;
    import javax.swing.text.StyledEditorKit;
    import javax.swing.text.StyledDocument;
    import javax.swing.text.MutableAttributeSet;
    import javax.swing.text.SimpleAttributeSet;
    import java.awt.Color;
    public class ColorizeTextTest{
         public static void main(String args[]){
              //build gui
              JFrame frame = new JFrame();
              JEditorPane editorPane = new JEditorPane();
              frame.getContentPane().add(editorPane);
              frame.pack();
              frame.setVisible(true);
              //create StyledEditorKit
              StyledEditorKit editorKit = new StyledEditorKit();
              //set this editorKit as the editor manager [JTextComponent] <-> [EditorKit] <-> [Document]
              editorPane.setEditorKit(editorKit);
              StyledDocument doc = (StyledDocument) editorPane.getDocument();
              //insert string "Hello World"
              //this text is going to be added to the StyledDocument with positions 0 to 10
              editorPane.setText("Hello World");
              //create and attribute set
              MutableAttributeSet atr = new SimpleAttributeSet();
              //set foreground color attribute to RED
              StyleConstants.setForeground(atr,Color.RED);
              //apply attribute to the word "Hello"
              int offset = 0; //we want to start applying this attribute at position 0
              int length = 5; //"Hello" string has a length of 5
              boolean replace = false; //should we override any other attribute not specified in "atr" : anwser "NO"
              doc.setCharacterAttributes(offset,length,atr,replace);
              //set foreground color attribute to BLUE
              StyleConstants.setForeground(atr,Color.BLUE);
              //apply attribute to the word "World"
              offset = 5; //we include the whitespace
              length = 6;
              doc.setCharacterAttributes(offset,length,atr,replace);
    }

Maybe you are looking for

  • How to add text to a pdf file using Access VBA??

    I'm down on my hands and knees, begging.  I have 300 files that I want to put a variable string at the top of the first page (centered, or at the right hand side).  I am using Acrobat X and Microsoft Access 2010 and I do have the SDK and have spend o

  • Batch export of multiple clips from one video in Premiere CS4

    Hello, I'm really in a bind and hope you guys can help me out. I have about 30 hours of video in about 30 mpg files..1 hour in each video. I need to splice out small clips from each video..anywhere from 10 to 20 clips in each and send them to Media E

  • Can i download all packages from yum update website?

    i want to download all yum update package from yum update pages http://public-yum.oracle.com/repo/EnterpriseLinux/EL5/1/base/i386/ .so i have all the package needed,because the OEL i installed dont have internet access ? btw i already using program w

  • Can't login to iCloud to restore from backup

    So I restored my iPod, and before that had backed it up to iCloud. When I got to the setup I chose "Restore from iCloud Backup" and logged in with my .mac account. After I put my birthday and agree to the terms it says setting up Apple ID or somethin

  • Justify indicator value to right

    Hi how can I set the value of a control or an indicator to the right generally in LV7. I don't want to change it all the time. thanks Yves