Different color for each item in the list

Hi all

I am currently working with a List component and I am looking to change the color of the font for each item individually. Flex allows you to do this? If so, can someone post a solution. Thank you in advance.






override the private function data (value: Object): void
{
Super.Data = value; EXTREMELY IMPORTANT THAT YOU DO THIS FIRST
If {(value)
Examine the value and determine the color
setStyle ("color", somecolor);
}
}
]]>




Tags: Flex

Similar Questions

  • the list widget with different colors for each item in the list?

    I'll add a widget list to my interactive color wheel:

    * http://r0k.us/graphics/SIHwheel.html

    It is an old applet, first published in 1998 and older than Swing.

    The list contains the names of color 1 567 which he knows the color values. I want the background color to each element to be one of the named color. The forefront color name text will be white or black, chosen for readability to her background. Basically, I'm hoping to accomplish what the name of this color page did with its list widget HTML-form:

    * http://chir.ag/projects/name-that-color/

    I studied the java.awt.list document:

    * http://download.oracle.com/javase/1.4.2/docs/api/java/awt/List.html

    SetBackground() and setForeground() methods are implemented, but they seem to apply only to the list as a whole. As far as I know, it seems there is no access to list items themselves as components. I hope that I am just missing what is obvious.

    -Rich

    What you want to do can be easily implemented on a JList swing, with the help of a custom converter. I would advise therefore to rewrite your applet in the swing, then use a JList. That way you can skip JUnit is studying just to force your applet awt to do something of awt was neither designed for and focus on swing of things GUI. Below is an example of how you can implement your JList:

    import java.awt.*;
    import java.math.BigInteger;
    import java.util.Arrays;
    import java.util.Comparator;
    
    import javax.swing.*;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    
    public class ColorList {
    
        public static void main(String[] args) {
         SwingUtilities.invokeLater(new Runnable() {
    
             @Override
             public void run() {
              new ColorList().createGUI();
             }
         });
        }
    
        private void createGUI() {
         String[][] array = getArray();
         // sort the array as you wish
         Arrays.sort(array, new Comparator() {
    
             @Override
             public int compare(String[] o1, String[] o2) {
              return o1[1].compareTo(o2[1]);
             }
    
         });
         // create the JList
         final JList list = new JList(array);
         // set some adequate renderer
         list.setCellRenderer(new DefaultListCellRenderer() {
             private static final long serialVersionUID = 1L;
    
             @Override
             public Component getListCellRendererComponent(JList list,
                  Object value, int index, boolean isSelected,
                  boolean cellHasFocus) {
              DefaultListCellRenderer renderer = (DefaultListCellRenderer) super
                   .getListCellRendererComponent(list, value, index,
                        isSelected, cellHasFocus);
              renderer.setText(((String[]) value)[1]);
              int color = new BigInteger(((String[]) value)[0], 16)
                   .intValue();
              renderer.setBackground(new Color(color));
              renderer.setForeground(new Color(0xFFFFFFFF ^ color));
              return renderer;
             }
         });
         final JLabel demoLabel = new JLabel(
              "Display this text in the selected color", JLabel.CENTER);
         list.addListSelectionListener(new ListSelectionListener() {
    
             @Override
             public void valueChanged(ListSelectionEvent e) {
              String[] selected = (String[]) list.getSelectedValue();
              demoLabel.setForeground(new Color(new BigInteger(selected[0],
                   16).intValue()));
             }
         });
    
         JFrame frame = new JFrame("ColorList");
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.add(new JScrollPane(list), BorderLayout.LINE_START);
         frame.add(demoLabel, BorderLayout.CENTER);
         frame.pack();
         frame.setLocationRelativeTo(null);
         frame.setVisible(true);
        }
    
        private String[][] getArray() {
         return new String[][] {
    
         { "000000", "Black" },
    
         { "000080", "Navy Blue" },
    
         { "0000C8", "Dark Blue" },
    
         { "0000FF", "Blue" },
    
         { "000741", "Stratos" },
    
         { "00FF00", "Green" },
    
         { "FF0000", "Red" },
    
         { "FFFFF0", "Ivory" },
    
         { "FFFFFF", "White" }
    
         };
    
        }
    
    }
    

    Piet

  • Ungroup a group and keep the scriptlabel for each item in the Group

    Hello

    does anyone know how to ungroup a group of rectangles with a certain tag (example groupA) give one every rectangle a clean label (the same text groupA)

    I can find the Group and ungroup it but I can't label the rectangles...

    var oPageItems = app.activeDocument.allPageItems;

    for (var j = oPageItems.length - 1;)  j > = 0; d-) {if (oPageItems [j] .label == ("groupA")) {oPageItems [j] .ungroup ()))}}

    ...???

    Help, please

    Hello

    front

    oPageItems [j] .ungroup ();

    go through the loop and set a label for each item within the Group:

    for (var k; k)< opageitems[j].length;="">

    oPageItems [j] [k] .label = "groupA";

    assuming that your oPageItems [j] is a group indeed.

    I hope that...

  • [REQUEST] Different images for each parent of the field of the tree?

    How can I provide different pictures for each parent/root of the field of the tree?

    I finally understand it.

    This is my code:

       public static class TreeCallback implements TreeFieldCallback {
            // The "drawTreeItem" method is invoked
            // when a treefield item requires painting.
            public void drawTreeItem(TreeField tree, Graphics g, int node, int y,
                    int width, int indent) {
                // Retrieves the user-supplied cookie object
                // for the given node and casts to a string.
                String text = (String) tree.getCookie(node);
                Bitmap b;
                g.setColor(Color.ANTIQUEWHITE);
                // Draws the text of the treefield item.
                if (text.equals("First Parent")) {
                    b = Bitmap.getBitmapResource("your_first_bitmap");
                    g.drawText(text, indent + b.getWidth() + 20, y + 15);
                    g.drawBitmap(indent + 15, y, b.getWidth() + 5, b.getHeight(),
                            b, 0, 0);
                } else if (text.equals("Second Parent")) {
                    b = Bitmap.getBitmapResource("your_second_bitmap");
                    g.drawText(text, indent + b.getWidth() + 20, y + 15);
                    g.drawBitmap(indent + 15, y, b.getWidth() + 5, b.getHeight(),
                            b, 0, 0);
                } else {
                    b = Bitmap.getBitmapResource("your_default_bitmap");
                    g.drawText(text, indent + b.getWidth() + 50, y + 15);
                    g.drawBitmap(indent + 40, y, b.getWidth() + 5, b.getHeight(),
                            b, 0, 0);
                }
            }
        }
    
  • ADF: Change of color for each value in the column, according to the State

    Hello world

    I use Jdev 11 G.
    I created an ADF only read the table.
    table has 5 columns. (empno, ename, sal, comm, address).

    If comm < 0, then I need to display it in the color blue
    otherwise have to display in red color.

    Note: comm value can be decimal (float).
    How to get there?
    All responses will be very grateful.

    Thank you...

    Something like that?

    cell color

    Arun-

  • Setting different colors for different cells in a list

    Hello

    I was wondering if we could select the two cells in a list and have two different colors for each of them.

    For example, if I select 1 and 9 cells in a list, can I have the first being green and 9th to be red?

    Hello

    Pls check it.

    http://forums.Adobe.com/message/2216445#2216445

    It's for the datagrid control, but you can do the same for the list. Let me know if you have any problem.

    with respect,

    Mayeul Singh Bartwal

  • How can I create a slide show 100% width, but have the caption in different positions for each slide.

    How can I create a slide show 100% width, but have the caption in different positions for each slide.

    There is placement of the legend only one for all the images in a slide show.

    The slideshow widget is specialized to create slideshows of the image. The widget of composition is a much more flexible widget which allows any combination of images and text in the trigger containers or containers of target of the widget. A widget of composition could be used to create a slide show with several legends by image and/or legends of different places for each image. The disadvantage of the widget of composition is that, due to the nature flexible widget, very little is automated for you and so it is much more intensive work to create a slideshow of images using the widget of composition.

    Thank you

    Sanjit

  • Web Gallery - different caption for each photo - broken?

    It's something I've done successfully with versions before LR2.5 but for some reason that I cannot now create different captions for each photo.  The help page in line said: "to display a different caption or title for each photo, click on the menu of settings customized to the right of title or a legend and choose Edit. In the patterns of text editor that appears, insert the IPTC title or caption metadata element, and then click Done. »

    This does not happen.  If I create a title for the first photo, it appears for all others.  If I change the caption for the second picture, everything changes, including the first caption of the photo.  Is this a new bug, or am I just missing something?

    I can always change the HTML gallery, but it is not an elegant solution, to say the least.

    Help appreciated.

    DN

    Enter the title or caption in the library, in the metadata Panel. And select the items in the grid. The titles that you change apply to the web gallery, not the individual photos.

  • Separate colors for each Spry tab?

    Is it possible to have distinct colors for each tab in the Panel tabs Spry? I think it would be a style < <. "TabbedPanelsTab > >, but how can you identify each of the individual tabs - through < < tabindex ="? ' > >?

    Thank you.

    Just add a new class for each spry tab...

    • Tab 1
    • Tab 2
    • Tab 3
    • Tab 4

    CSS:

    li.blue { background-color: blue }
    li.red { background-color: red }
    li.yellow { background-color: yellow }
    li.green { background-color: green }
    

    Yay. colours Disco

  • How to set a different color for the items in selectManyCheckbox

    Hello

    I would like to change the background color of text element for each item in selectManyCheckbox (different for each element).

    It is only 5 points which could be static reference or select.

    I only know how to change background for all items

    AF | selectManyCheckbox:item-{text}

    Background: orange;

    }

    How to select concrete question text and change color for them alone?

    I have the similar problem.
    CSS - background color defined for each individual p:selectManyCheckbox checkbox - Stack Overflow

    but it don't work for me because I don't have a structure very adf

    I need somethink like this:

    AF | selectManyCheckbox:item - XXXX text - select a question by number here in the list or the id {}

    Background: orange;

    }

    I use selectBooleanCheckbox in the forEach loop

  • I want different titles for each photo in a web gallery. The help file says:

    To display a different caption or title for each photo, click on the menu of settings customized to the right of title or a legend and choose Edit. In the model text editor that appears, insert the piece of metadata, IPTC title or caption, and click done.


    But what I do, the latest edition is for every picture the same.


    I have to select the image in a different way, I've already tried?

    Has chosen not to change, choose TITLE and LEGEND in the drop-down list.

    Then change the TITLE and CAPTION for each photo in the library/metadata Panel

    Then, each photo will be another caption/title

  • AS3 - making an index for each item in list box

    Hi guys,.

    I'm puzzled. It could be something simple that I'm doing wrong.


    I have a table populated by XML based on the following inside the function:

    first_special.addItem({label: xmlMenuFile.item.headers[i],data: 
    xmlMenuFile.item.descriptions[i],data2: xmlMenuFile.item.hints[i]});
    

    The problem I have is trying to find a way for the "data2" will fill the text field 'hint_txt' on ROLL_OVER of the same name of items in the list.

    I tried to place an event listener in the function that populates the drop-down list box, but does not

    // this populates the combo box label and data with the Loaded XML File. This works
    function changeHandler(ev:Event):void
    {
         menuText_mc.heading1_txt.text = ev.currentTarget.selectedItem.label;
         menuText_mc.description1_txt.text = ev.currentTarget.selectedItem.data;
         heading1 = ev.currentTarget.selectedItem.label;
         includePrice1_mc.visible=true;
    
    
    // trying to figure out how to activate the 'hinting' function when you ROLL_OVER EACH ITEM in the 'first_special" combo box
    // and when rolling over it trace 'hello'. This DOES NOT WORK.
    first_special.addEventListener(MouseEvent.ROLL_OVER, hinting);
    }
    
    
    function hinting(e:MouseEvent):void{
    // Should trace "hello" everytime I Roll_OVER an item in the Combo Box.     
         trace("hello");
    }
    
    // calls the changeHandler function and works correctly
          first_special.addEventListener(Event.CHANGE, changeHandler);
    
    
    Any help with this would be great.
    
    Thanks
    

    For the features of indicators, I think you want to define...

    Import fl.events.ListEvent;

    function hinting(e:ListEvent):void {}
    var rowIdx:uint = e.rowIndex as uint;
    hint_txt. Text = .data2 first_special.getItemAt (IdxLigne);
    }

    first_special.addEventListener (ListEvent.ITEM_ROLL_OVER, hinting);

    What you react only to roll on the main component, not the elements, and this reversal starts to happen until you have selected an item since you buried the listener inside the change function.  Keep the headset out in the open.

  • Is it possible to draw the same color for each curve automatically

    Hello

    Is it possible to draw the same color for each curve automatically. I use graphic XY basis with data set.

    Lol you'll either need to set the properties through the dialog box.  Or use the nodes property of the graph to adjust the Active plot and then set the color of the plot.  This can be done in a loop For.

  • How to set different color for the table column header

    Can I set different colors for the 4 following as being attached.

    -color of the header text

    -the head of the column of the background color

    -color of the text of the content

    -color of background content

    The value of the cluster - 2, -2 to define all of the cells,

    Then go back and the cluster the value-1, -2 to simply set the line header.

    (If you also had a column of row headers, then -2,-1 would set them.  Course the upper left corner which is the intersection of the column header and row header will change with any of them.)

  • Error in Event Viewer: loading libraries of dynamic links customized for each application. The system administrator should review the list of libraries

    My system features, i7 thinkpad w540, 16 GB of ram and a 256 GB ssd. Using MSE as av with AMBM pro

    whenever I start my system, win 7 x 64, I get the following error in the event viewer:

    Custom dynamic link libraries are loaded for each application. The system administrator should review the list of libraries to ensure that they are linked to trusted applications.

    any help with this error?

    Atul

    Description: NVIDIA shim dll initialization

    Product: Shim NVIDIA D3D drivers
    Company: NVIDIA Corporationhttp://systemexplorer.net/file-database/file/nvinit-dll/33069751

    I would not be concerned by this driver.

Maybe you are looking for

  • Is there a way to get the image out of my iPod 4th generation without knowing / being able to enter the password

    I've had my iPod for about 6 years. About 2 years ago, the screen broken to the point of not being able to enter my password, and since then, I forgot it all together. The power button does not work. I was wondering if there is a way to get the pictu

  • Opening can import metadata?

    I have pictures 6 k + legend who all have had a string of text inserted in the field before the description of photographs. I could delete that text by exporting metadata, opening in text editing and do a "find and replace". I'm stuck but with import

  • Question about a repair time

    Hi allI bought satellite M40 of Toshiba HK (06/14/05) and go back to my country "Egypt".and facing problem for her, in Egypt and sent to the agent of toshiba of the Egypt they said need new motherboard, this was done on 25/07/05and until now, they do

  • where the Publisher hyper?

    good will I be completely blind here? in logic 9 there is a super editor who allowed me to create a rise with the ground effect. It's a great tool... but I can't find it in logic pro x? have they got rid of him! can anyone help

  • Satellite L655 - upgrade RAM causes the system crash

    I bought and inserted 2 RAM Kingston 4 GB chips. When I boot the Windows and Ubuntu 14.04 (I have a dual boot) fails. If I run a test memory Ubuntu start menu, the system hangs. I put the old RAM and all is well. To resolve this problem, I tried upgr