Different color for JTextPane rows

Hi!
Do you know if it's possible to write rows in different colors in a JTextPane or it writes in ForeGround color every row ...
Thanks!

You can change colors in a JTextPane by getting the underlying Document and make modifications to it. Here is an example of how to change the current print color:   Document doc = textPane.getDocument();
   MutableAttributeSet attr = new SimpleAttributeSet();
   StyleConstants.setForeground(attr, newColor);
   doc.setCharacterAttributes(attr);

Similar Messages

  • PWA 2010 timesheet: 2 different colors for the rows "Actual " and "Planned

    Hello,
    To make timesheet easier to read and fill, is it possible to have 2 different colors for the rows “Actual “ and “Planned”?
    Thanks,
    soudha

    Hello Soudha,
    By default the timesheet grid shows the cells in white color. But if you have little coding skills or a developer at your end, you can try this using "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\JsGrid.js" java
    script file.
    You may have to modify it but I recommend to take a backup of the file and test in your test environment first.
    Happy troubleshooting.....
    Vikram Daruru - MSFT

  • 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>

  • Combo chart - different colors for Bar/Line

    Hi,
    In a combo chart is it possible to have different colors for bar and lines......................In our report- combo charts the intersection of bar/line is NOT visible beacuse of same color.

    Yes, I create a formula row with a zero in the first column. The row should be hiden. This has to be at the top of the grid and include the row in your data ranges for the chart.

  • 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!

  • How can i do different colors for the category in business graphics

    Hi everybody,
    i have a business graphics and i need different colors for the category. my business graphics is a gantt.
    for example
    category1
    category2
    category2
    and so on.
    Is there a solution for this? How can i do it?
    Best regards,
    Markus

    Sorry.
    In my opinion, this requirement can not be resolved.
    Generally, we use Business Graphic with Category, we just follow:
    DATA:lr_graph TYPE REF TO cl_wd_business_graphics.
    lr_graph = cl_wd_business_graphics=>new_business_graphics(
        bind_series_source = 'NODE_DYN'
        chart_type = cl_wd_business_graphics=>e_chart_type-BARS
        height = 340
        width = 750
    *     BIND_TOOLTIP = 'GRAPH.TT'
        id = 'GRAPH' ).
    DATA: lr_bgr_cs TYPE REF TO cl_wd_category.
    lr_bgr_cs = cl_wd_category=>new_category(
    view = wd_this->mr_view
    bind_description = 'NODE_DYN.CATEGORY').
    lr_graph->set_category( lr_bgr_cs ).
    If we go to SE24, to check  the class "CL_WD_CATEGORY", we cannot find any method  or attribute about how to manipulate  the "Category Font Color"...
    Maybe,any other expert can give you fantastic solution, hope. Best wishes.

  • Drop Down List in a table - different options for each row

    How can i have a drop down list in a table with different options for each row?
    My requirement is this.. I want to display, say employee dtails in a table, and one column is employee hobbies, whcih can have multiple values and each employee may have a different list of hobbies. So how can we populate the drop down for each row, with different options?

    Hey. Uh, this probably isn't the answer you were looking for, but it sounds like you've got a problem with your database design there. Generally speaking, your tables shouldn't have multi-valued fields, in the relational model anyway (sql). Instead, you should look at adding a separate table like EMPLOYEE_HOBBIES. Then you have a foreign key using the employees primary key as the foreign key in the employee_hobbies table, see what I mean? I might have misunderstood your explanation though, I'm not sure.
    Alternatively, you could just have hobbies as a big freeform varchar field, and don't bother to make people separate their hobbies into different fields (you'd have to abandon the drop-down listbox idea in this case). If there's no really important reason to make the distinction, then it's probably easier just to not do it.

  • 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 can i apply different color for each cell in jlist component?

    hi guys i need your help and sorry if my english is very bad..guys how can i apply different colors for each cell in jlist component? for example for the first cell i want to apply color blue, for the second cell i want red, etc... i need your answer guys tnx..
    Edited by: ryrene on Mar 21, 2010 12:13 AM

    ryrene wrote:
    hi guys i need your help and sorry if my english is very bad.
    ..guys how can i apply different colors for each cell in jlist component? for example for the first cell i want to apply color blue, for the second cell i want red, etc... i need your answer guys tnx..I'll see your tnx, and raise you dve bmbrs & nplm.

  • 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

  • Different content for a row popin in every row

    HI,
    is it possible to have a different content for a row popin in every different row?
    For example: In Row 1 I have a ViewContainerUIElement containing View A, in Row 2 I have a ViewContainerUIElement containing View B...
    This is what I need, different views in every row...
    Is this somehow possible?
    Best regards,
    Peter

    OK than. Have you think about one view which will be in your table popin, but each element in this view will be created dynamically? Than you will get the look as there are different views, different design for each row, but it will be the same view.

  • A quick way to set different color for certain items in JList?

    is there a quick way of setting different color for certain items in JList?

    Either use HTML strings as the values in your JList (quickest, but may not be the most convenient, especially if your model isn't just text), or create your own ListCellRenderer (e.g. extend DefaultListCellRenderer).
    There is no such thing as "list.setItemForeground(int index, Color c)". You'll have to use one of the methods above.

  • Different colors for hierarchy nodes in WEBI 4.0 (Possible or not)

    Hi Everyone,
    We have been listening a lot about the capability of Webi 4.0 in terms of Hierarchies from BW BEx Query. It works just fine like in BEx Analyzer, but is it possible to create formatted reports like we do in Crystal reports to display different colors for the hierarchy nodes. The reason for asking about this functionality is though Crystal Enterprise also inherits Hierarchical view from BEx Query we still won't be able to drill down in real time to do some interactive analysis.
    Where as Webi 4.0 can allow us to do interactive analysis by allowing us to drill down on the hierarchies, but it would be great to show the Webi report with different colors for the hierarchy nodes along with the drill down functionality, to give users the best look and feel while working with these reports.
    I am trying to achieve this functionality but I am not successful yet and running out of ideas. I am also not sure if this is possible or not. Can anyone throw some light or share there thoughts on this.
    Any comments will be greatly appreciated.
    Thanks & Regards,
    SRV

    Create a variable with:
         =[Object].Depth
    where [Object] has to be the one containing the BEx hierarchy.
    This function will return the hierarchy level starting with 0 (zero).
    You can use the value of the variable the in the formatting rules:
    variable   equal   [hierarchy level]
    to format all hierarchy nodes on the given level.
    R. Uli

  • Is there a way to have multiple color Guides so I can have different colors for different layers

    Is there a way to have multiple color Guides in Illustrator and Photoshop CC so I can have different colors for different layers?

    I think it's not possible "natively" to have this functionalty but I found these topics for Photoshop :
    http://www.ps-scripts.com/bb/viewtopic.php?f=10&t=4618
    http://www.ps-scripts.com/bb/viewtopic.php?f=10&t=4617
    On this one, you will see a workflow which are well described.
    http://graphicdesign.stackexchange.com/questions/6030/how-to-set-different-color-to-guides ai-ps-id-fw
    I've not tested them but you should give it a try!

  • JTextArea-Using different colors  for the Strings added

    I'm looking for a way to write in a textArea using different colors for the Strings

    use SetForeground(Color newForegroundColor) on the JTextArea class
    good luck
    krishna

Maybe you are looking for