Scrolling Row Text Color in JScrollPane

Hi,
I've implemented a JTable that overrides the prepareRenderer method so that if certain criteria are met, the text of the associated row are set to a certain color.
          // Create JTable and override prepareRenderer method
          centertable = new JTable(sorter)          
               public Component prepareRenderer(TableCellRenderer renderer, int row, int column)
                    //System.out.println("Row: " + row + " Column: " + column + " Value: " + colorpanel[row][column]);
                    Component c = super.prepareRenderer(renderer, row, column);
                    if(selectedcolorpanel[row][column] == 1)
                         c.setBackground(Color.ORANGE);
                    else
                         c.setBackground(Color.BLACK);
                    // Do Text Coloring for uptick / downtick?
                    // Uptick
                    if(selectedcolorpanel[row][column] == 2)
                         c.setForeground(Color.GREEN);
                    // Downtick
                    if(selectedcolorpanel[row][column] == 3)
                         c.setForeground(Color.RED);
                    // Same
                    if(selectedcolorpanel[row][column] == 4)
                         c.setForeground(Color.WHITE);
                    // Keyboard  and mouse highlights implementation
                    if(isCellSelected(row, column))
                         c.setBackground(Color.ORANGE);
                         selectedcolorpanel[row][column] = 1;
                    return c;
          };I embed the table in a scrollpane and set an integer to the limit of rows that I want to display in the table. If I get a row above the row limit of the table, I first remove a row from the table model, then add the new row. However, the color is not preserved, as the table scrolls UP, but the colorpanel does not. Does anyone have any suggestions, or easy way to preserve coloring in a JTable on scroll?
Thanks,
hhung

Hi,
Swing questions should be asked in the Swing forum. Please post your question there, and link back to this thread.
Kaj

Similar Messages

  • Change row text color if box checked

    Hi. I've setup my form in a table and if a checkbox is
    ticked, the background color changes along the whole row. Trouble
    is, the text doesn't stand out after this color change so I also
    need the text color to change from black to white when checked and
    revert to black if unchecked. Anyone know how I would do this?
    Here's the code I'm using to change the background color. Can I
    modify it or do I need new code? I'm still learning :)
    <script type="text/javascript">
    function change(obj) {
    var tr=obj.parentNode.parentNode;
    if(obj.checked) {
    tr.className+=' pink';
    else {
    tr.className=tr.className.replace(' pink', '');
    clickCh();
    .nochange, tr {background-color:white;}
    tr.pink {
    background-color:#7247D1;
    .light {background-color:#D2CAEB;}
    .dark {background-color:#B1AAD7;}
    <tr class="light">
    <td width="68" bgcolor="#000000" class="leftAlign"
    scope="row"> </td>
    <td width="20" bgcolor="7247d1" class="leftAlign"
    scope="row"> </td>
    <td width="21" class="leftAlign"
    scope="row"> </td>
    <td class="leftAlign"
    scope="row">  <strong>
    ProductA</strong> (details)</td>
    <td width="30" class="leftAlign" scope="row"><div
    align="center">20g</div></td>
    <td><input name="input4" onClick="change(this)"
    value="0.80" type="checkbox"></td>
    <td >&pound;0.15</td>
    <td>data1</td>
    <td>data2</td>
    <td>data3</td>
    <td>data4</td>
    <td bgcolor="7247d1"> </td>
    <td bgcolor="#000000"> </td>
    </tr>

    look at focus and keylisteners.

  • FCPX: Scrolling Credits Text Color

    Can anyone tell me how to change the color of text in the scrolling credits option from white to another color? I don't see an option to do this. I see an option to change ALL the text in the credits to one color, but not line by line. I only want to color the main title categories in the credits.

  • ALV Weddynpro : Text color for a row(for a particular record)

    Hello Friends,
    Situation : Webdynpro App utilizing re-usable ALV component to Edit(changed/modify) Employee records.
                     I have used to the class cl_salv_wd_uie_a_input to make certain columns read_only and colored(cell background only).
    My requirement :
    Suppose there are 4  rows and based on  if a certain condition is staisfied(lets say 2 rows), then i have to  changed the color ONLY THE TEXT(to RED). There is certain meaning for the rows for such records which users can easily interpret.
    I have tried to used CL_SALV_WD_UIE_TEXT_VIEW(which i have successfully color coded the texts),  but i lose the editing capabilities.
    The webdynpro App uses a EDITABLE-ALV meaning that, user can  insert/modify/delete records and save them in the DB.
    Is there anyway to have both this features using above said situations and consequences?
    OR
    Pls share any workaround if anyone has tried this before?
    Regards
    Vinay.
    Example.
      PERNR
      COL1
      COL2
      102984
      UYYER
      IIIELX
      102983
      DFKLJJ
      DOFUOU
      102985
      DOFJDOFU
      DFOIUOIU
      102988
      DFOADSFUOU
      OSDUFOU

    Hi,
    We can assign semantic colors only to text view fields. So in this case since you are forcibly changing the  view to text view, for text coloring, we are losing the edit fields capabilities. Instead setting the type of field( text view / input view ) based on the your condition could be best, so that editing capabilities is also not missed and text coloring is also not missed.
    Or you can set all fields to input fields and set the read only/edit property based on the condition and set the cell design of the fields accordingly, so that the users can distinguish easily.
    Regards,
    Harsha

  • How to change the text color to red in a combo box?

    I'm writing a java program which have a combo box which shows all the name of the member from the database. However, I would like to change the text color of those member who have now currently on-line.
    Please help, it's URGENT. Thanks in advance.
    Clark

    hi,
    as i mentioned, you would require to use a custom renderer for this, for this
    //Class subclass the JFrame and has a JList in it
    import javax.swing.*;
    import java.awt.*;
    import java.util.Vector;
    public class ListRendererTest extends JFrame
         private JList lstMenu;
         private DefaultListModel defaultListModel;
         private JScrollPane scrollPane;
         private Vector listVector;
         public ListRendererTest()
              init();
              addComponents();
              showFrame();
         public void init()
              lstMenu = new JList();
              defaultListModel= new DefaultListModel();
              lstMenu.setModel(defaultListModel);
              scrollPane      = new JScrollPane(lstMenu);
              listVector = new Vector();
              MyListData m1 = new MyListData();
              m1.setName("Rakesh");
              m1.setOnline(false);
              listVector.addElement(m1);
              m1 = new MyListData();   //represents each User instance
              m1.setName("Makesh");
              m1.setOnline(true);
              listVector.addElement(m1);
              for (int i=0;i < listVector.size(); i++)
                   defaultListModel.addElement(((MyListData)listVector.elementAt(i)));
              lstMenu.setCellRenderer(new MyListRenderer());  //set custom renderer
         public void addComponents()
              getContentPane().add(scrollPane,BorderLayout.CENTER);
         public void showFrame()
              setTitle("List renderer test");
              setSize(300,300);
              setLocation(200,200);
              setVisible(true);
         public static void main(String args[])
              new ListRendererTest();
    }The above class is the Container which houses the JList in it, it uses two other classes, MyListData which is used to represent each user instance ( username, and information about whether he is online) and MyListRenderer (custom renderer).
    // Represents each user instance //
    public class MyListData
         private String name;
         private boolean online;
         public void setName(String name)
              this.name = name;
         public String getName()
              return name;
         public void setOnline(boolean online)
              this.online = online;
         public boolean isOnline()
              return online;
    //custom list renderer
    import javax.swing.*;
    import java.awt.*;
    public class MyListRenderer extends DefaultListCellRenderer
         private MyListData myListData;
         public Component getListCellRendererComponent(JList list, Object value, int index,  boolean isSelected, boolean cellHasFocus)
               myListData = (MyListData)value;
               setText(myListData.getName());
               setBackground(myListData.isOnline() ? Color.red: Color.white);  //check if online, if so show in different color
               setForeground(isSelected ? Color.blue : Color.black);
               return this;
    }hope that helps.
    cheerz
    ynkrish

  • Easy one I hope: How do I change text color?

    For the life of me I can't seem to find anything with a color pallette (except for background fill). I need to change text color but don't know where to find it.  Everything's always black. When I highlight the text, and goto "Font", I see something that looks like the "Select Text Color" (like the one above but as soon as you mouse over it, it turns to a crossed-out "ABC", and can't get the pallette.
    Thanks for your help.

    Hi,
    Question: Are these fields that you had changed the type of in the Object Pallet/Field Tab/Type ? If so, try deleting the object and put a new one in its place from the Object Library.
    If no, what sort of parent do these items have? Table Row? or SubForm?
    Good luck!
    Stephen

  • Work with JTable cell (check input, set text color)

    I have a JTable with data
    The task is:
    User inputs some data into cell
    I want to check his input string for equatily with other values in column
    For example, I have these values in column:
    1.example
    2.exercise
    3.execute
    User inputs word "execution" in the same column
    until user inputs "executi" his input string should be red.
    What event I have to listen to if I want to get user input string?
    Also a question:
    Is there any opportunity to work with cell row (copy it to another JTable) ?
    Message was edited by:
    Holod

    i think you should use cell editor as textfield (although that is default for jtable) and then implements document listener and set text color in insert update method.
    try this out :-)

  • Alternating text color of excel cell items after each space?

    Hello. I have a script that emails a table of info which works fine and that looks like this:
    name, samaccountname, date, memberof
    In the email table I was able to have it do a line break on each space so that the memberof groups are on on separate lines for easier reading.
    Well I've been wanting to send the data to store in a csv sheet as well. I can get it going in there but for the member of column it puts in memberof1  memberof2  memberof3 etc etc on one line. The CNs OUs etc are all removed and its just the group
    names separated by spaces. Works but a little hard to read.
    I was thinking maybe there was a way to open the excel file for writing and on that one column have it alternate text colors using the space as the delimiter? Everything would be easier to read that way. Is this possible ?
    Thanks

    Thanks. I did look at that and have this so far. Im  just trying to echo it out right now, but Im guessing that somehow in the foreach ($item in $groups) I need to create an array or something? Then Id want to apply one color to each item in the array.
    Ive tried several different combinations and was trying $item.spli(" ") but it always comes back looking the same.
    So right now $item echos like this
    Group1  Group2  Group3  Group4  Group5
    Id just want to alternate each space delimited item one of two colors. Then take those appened colors of each item and write it back to the cell that I read it from in the column so that its easier to read. Is this even possible?
    $objExcel = new-object -comobject excel.application 
    $objExcel.Visible = $True
    $ExcelFilesLocation = "c:\"
    $UserWorkBook = $objExcel.Workbooks.Open($ExcelFilesLocation + "groups.csv")
    $UserWorksheet = $UserWorkBook.Worksheets.Item(1)
    $intRow = 2
    Do {
     # Reading the first column of the current row
     $groups = $UserWorksheet.Cells.Item($intRow, 4).Value()
     foreach ($item in $groups)
     $regex = [regex] "\s"
     $split = $regex.split($item)
     Write-Host $split
     # Move to next row
     $intRow++
     While ($UserWorksheet.Cells.Item($intRow,1).Value() -ne $null)

  • Text Colors in Boris 3D

    I cannot control colors in Boris Title 3D. Open Boris Title 3D. Click Options and get the window to enter text. Enter text. Highlight the text. Click Style Palette and get the Style Palette window. Click Color. On dropdown, select zColors.clr. Just above the count item, are three icons: Add Style, Rename Style, and Edit Selected Style. The last two are grayed out. Scroll down the colors on the right (two finger scroll doesn't work) and click on AquaBlue. The two grayed out icons are now active but nothing else happens. Double click AquaBlue. Same result. X out of colors and click Apply. In the viewer, click video. Background is black and text is white. What to do? Thank you

    First reset the Style palette. Go to the third tab on the left, the color tab. Make sure text fill is set to color. Use the eyedropper to suck the color from the style palette.

  • Changing text color of item renderer in datagrid

    Hi,
    I have the following datagrid:
    <mx:DataGridColumn field="name" ......... />
    <mx:DataGridColumn itemRenderer="myRenderer" ...... />
    In myRenderer, I extend from the TextInput class; with the
    text color:WHITE
    My question is:
    When I do a mouse rollover/selection on any row of the
    datagrid, how can I change the text color of my renderer?
    If I add the rollover/selection event listener for my
    renderer, it will only change the color when my mouse is over its
    column.
    I want it to change colour whenever the row is selected/
    rollover.
    Thank you very much.
    Regards,
    hy

    Hi,
    The rollOverColor and selectionColor style on the Datagrid
    will only work for the normal columns.
    Since my column extends from the TextInput, the rollOverColor
    and selectionColor style does not seem to have any effect on the
    itemrenderer.
    hy

  • JTable - row focus color

    I wrote a program which will change the color of each row.
    odd row background color will be white
    even row background color will be gray.
    My doubt is?
    if i move the mouse on the any row, that row should have a different background color (dark of row background)

    I tried with DefaultTableCellRenderer, but it is not
    workingIs this what you want?
    import java.awt.Color;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableCellRenderer;
    import javax.swing.table.TableCellRenderer;
    public class RowColor extends JFrame {
        public RowColor() {
            Object[][] data =
                {"Row 1", "Row 1"},
                {"Row 2", "Row 2"},
                {"Row 3", "Row 3"},
                {"Row 4", "Row 4"}
            Object[] columnNames = {"Column 1","Column 2"};
            JTable table = new JTable(data, columnNames) {
                public TableCellRenderer getCellRenderer(int row, int column){
                    DefaultTableCellRenderer c = (DefaultTableCellRenderer)super.getCellRenderer(row, column);
                    if (row % 2 == 0)
                        c.setBackground(Color.GREEN);
                    else
                        c.setBackground(Color.YELLOW);
                    return c;
            JScrollPane scrollPane = new JScrollPane( table );
            getContentPane().add( scrollPane );
        public static void main(String[] args) {
            RowColor frame = new RowColor();
            frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
    }

  • Credits scroll with different colors and txt size

    I am trying to do a credits scroll with different text color and size How do I best do this. I understand how to do it with text/scroll but that doesn't allow me to do different text colors and size. How do I do it with Boris Crawl?
    Message was edited by: Tony Brave

    Hi -
    Mark an In and Out where you want the roll to roll.
    Load Boris Crawl in to the viewer and edit to the timeline.
    Double click on the clip in the timeline.
    On the control tab for Boris Crawl you can set it to roll your text:
    !http://www.spotsbeforeyoureyes.com/Boris%20Crawl%20Set%20Roll.jpg!
    Then click on the box above that where it says click for options and create your roll:
    !http://www.spotsbeforeyoureyes.com/Boris%20Type%20Example.jpg!
    Once you have typed and formatted your text, click apply and you should be able to see the roll.
    The speed of your roll is basically determined by the length of the clip on the timeline, the Controls tab for the clip gives you lots of subtle and not so subtle adjustments - like a soft wipe at the top and bottom of the crawl, etc.
    Hope this helps.

  • Multi Row Text Item (Not Text Area)

    Is it possible to create a multi-row text item for entering data i.e. a text area WITHOUT a scrollbar?. I know exactly how many rows I need e.g. an address field
    The scroll bar looks terrible on printouts when printing off data entry forms.
    Also any way of having ruled lines appear in the multi row text field?
    regards
    Paul

    Hello,
    No, just use three text items. or a textarea with the style ="overflow:hidden;" should supress the scrollbar
    Carl
    Message was edited by:
    Carl Backstrom

  • Row background color in dataTable control based on criteria

    It is relatively straightforward to give a pattern of color to rows in a dataTable control, for instance to alternate colors from white to gray.
    However, I have not yet figured how the row background color could be decided based on data fields associated with each row. For instance, I would like to set the row background color based on the value of a boolean attribute associated with the row, e.g. white if value is false and gray if it is true.
    Is there an easy way to do this?
    Martin

    of the text, but not the whole cell. I need to find a
    way to change the span at the row level (on the <tr>
    tag). ANy ways to do this?
    MartinThis is a question of how to let the renderer adjust its behaviour depending on the current state of the model. My renderer changes the background for the selected row by changing the style class:
            writer.startElement("tr", table);
              if (table.getRowSelector())
                   if (table.isAtSelectedRow())
                        writer.writeAttribute("class", "selectedRow", null);
    etc.(of course, to be able to do this you must write your own renderer)
    erik

  • AppleScript Text Coloring Help

    Okay, so in AppleScript Studio I made an application that is really just a text editor. Now I would like to make a script that would run whenever the contents of a text view changed, and what I want the script to do is every time it sees a certain word in the text view, change the color of only that word and leave the rest of the text alone, but it also changes the color of the word if that word is used more than once.
    i tried
    if text view "text" of scroll view "text" of window "window" contains "the" then
    set selection of text view "text" of scroll view "text" of window "window" to "the"
    set color of selection to "red"
    end if
    It gives me several errors, I don't really know if they are relevant to the solution of my problem, but if they are I can post them.
    Please help, I have tried to do this in so many different ways and nothing has worked.
    Message was edited by: Unreality

    bump

Maybe you are looking for

  • Need help with regular expression

    I'm trying to use the java.util.regex package to extract URLs from html files. The URLs that I am interested in extracting from the HTML look like the following: <font color="#008000">http://forum.java.sun.com - So, the URL is always preceeded by: <f

  • What is the noise my iMac does while using boot camp?

    Hello. I installed Windows 7 (Ultimate) on my iMac (27, late 2013, 32GB RAM) using Boot Camp and when I start using it, every couple of seconds I hear a noise that only happens with Windows. It's a very soft noise and it keeps repeating. I already se

  • Copy PO with Invoice Plan

    Hi guys, is there any function or way to copy a PO with Invoicing Plan? If I try to create a new PO by copying from an existing one, everything is copied unless the Invoice Plan. Who can help me? Thanks. Fabio

  • SCVMM 2012 R2 UR4 Running Dynamic Optimizer Fails

    After updating to UR4, running the dynamic optimizer on two of my four clusters fails. The problem appears to be related to networking and is a "Object reference not set to an instance of an object" error.  Looking at the event and trace logs, I have

  • Sound out of sinc on custom theme

    I am trying to replace an off the peg theme with a custom one that I have made in iMovie, but I can't get rid of the starting theme completely. That's one problem, but the main issue I have is that after I have imported the imovie as a background the