Results 1 to 2 of 2
Thread: SWT List w/ colored lines?
- 03-22-2009, 03:25 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 1
- Rep Power
- 0
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.
- 03-23-2009, 03:23 PM #2
Member
- Join Date
- Mar 2009
- Posts
- 42
- Rep Power
- 0
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);
shell.setLayout(layout);
Composite composite = new Composite(shell,SWT.None);
GridLayout layoutComp = new GridLayout(1,false);
composite.setLayout(layoutComp);
Table table = new Table (composite,SWT.None);
TableItem item = new TableItem(table,SWT.None);
item.setText("Item1");
item.setBackground(display.getSystemColor(SWT.COLO R_BLUE));
TableItem item1 = new TableItem(table,SWT.None);
item1.setText("Item2");
item1.setBackground(display.getSystemColor(SWT.COL OR_DARK_GREEN));
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch())
display.sleep();
}
display.dispose();
}
}
Similar Threads
-
Anyway to fix the lines so they dun shift?
By PeterFeng in forum New To JavaReplies: 0Last Post: 01-14-2009, 10:26 AM -
Linked List integer list
By igniteflow in forum Advanced JavaReplies: 1Last Post: 12-10-2008, 08:53 PM -
Random Lines
By Urgle in forum New To JavaReplies: 29Last Post: 11-12-2008, 03:42 PM -
How to access ArrayList in List of List?
By alvations in forum New To JavaReplies: 5Last Post: 10-08-2008, 12:23 PM -
Preventing inserted text from becoming colored from previous style
By jkhoa in forum AWT / SwingReplies: 2Last Post: 08-10-2007, 12:36 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks