Results 1 to 2 of 2
  1. #1
    p!lle is offline Member
    Join Date
    Mar 2009
    Rep Power

    Default SWT List w/ colored lines?

    Hi everyone,
    I've been googling my brains out for two days now and did not seem to find anything that works for me. I hope that maybe you guys can help me out. And yeah, sure - I looked through your forums as well before posting.

    So, what I want to have is a simple List widget, only with one item kind of marked up. What I have is a list of profiles where one of them is the default profile. Now, I could just put "profile1 (default)" as the actual item, but I wondered if it's possible to create a highlight by making this specific item written in bold or some color.

    Yes, there's setForegroundColor(...), but it obviously sets the color for the whole list, and not only for one (or some) list items.

    I thought that maybe one could create some sort of a style object to append as a list, but that's only possible with the StyledText widget, which I have also worked with repeatedly. Thing is, StyledText just doesn't feel good as a "worked-around" multi-colored list.

    So, in short, I need:
    1. an swt.widgets.List
    2. which is able to have its items (or one of them) displayed in either a bold font or some color (let's say red).

    Any ideas?

    Thank you for your time,
    - p!lle.

  2. #2
    trax is offline Member
    Join Date
    Mar 2009
    Rep Power


    U can use table instead of list n this code will sove ur problem try it out it doesnt make a difference in UI

    public class example {

    public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Dialog Example");
    shell.setSize(300, 200);
    GridLayout layout = new GridLayout(3,false);

    Composite composite = new Composite(shell,SWT.None);
    GridLayout layoutComp = new GridLayout(1,false);

    Table table = new Table (composite,SWT.None);

    TableItem item = new TableItem(table,SWT.None);
    item.setBackground(display.getSystemColor(SWT.COLO R_BLUE));

    TableItem item1 = new TableItem(table,SWT.None);
    item1.setBackground(display.getSystemColor(SWT.COL OR_DARK_GREEN));;
    while (!shell.isDisposed()) {
    if (!display.readAndDispatch())

Similar Threads

  1. Anyway to fix the lines so they dun shift?
    By PeterFeng in forum New To Java
    Replies: 0
    Last Post: 01-14-2009, 11:26 AM
  2. Linked List integer list
    By igniteflow in forum Advanced Java
    Replies: 1
    Last Post: 12-10-2008, 09:53 PM
  3. Random Lines
    By Urgle in forum New To Java
    Replies: 29
    Last Post: 11-12-2008, 04:42 PM
  4. How to access ArrayList in List of List?
    By alvations in forum New To Java
    Replies: 5
    Last Post: 10-08-2008, 01:23 PM
  5. Replies: 2
    Last Post: 08-10-2007, 01:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts