Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Ugly image in TreeItem (vs. Label)
Ugly image in TreeItem (vs. Label) [message #452415] Sun, 20 March 2005 17:59
Eclipse UserFriend
Originally posted by: bob.objfac.com

In the snippet below, note the difference in appearance between the icon
shown in the Label vs. TreeItem. The latter has an ugly black artifact
on the right side. How do I fix this? Thanks.

public static void main (String [] args) {
Display display = new Display ();
Shell shell = new Shell (display);
Label label = new Label (shell, SWT.NONE);
label.setText ("Can't find icon for .txt");
Image image = null;
Program p = Program.findProgram (".txt");
if (p != null) {
ImageData data = p.getImageData ();
if (data != null) {
image = new Image (display, data);
label.setImage (image);
}
}
Color white = new Color(display, 255,255,255);
Tree tree = new Tree(shell, SWT.NONE);
tree.setBackground(white);
if (image != null) {
TreeItem item = new TreeItem(tree, SWT.NONE);
item.setBackground(white);
item.setImage(image);
item.setText("?");
}
label.setBackground(white);
label.pack ();
tree.pack();
shell.pack ();
shell.open ();
while (!shell.isDisposed()) {
if (!display.readAndDispatch ()) display.sleep ();
}
white.dispose();
if (image != null) image.dispose ();
display.dispose ();
}

Bob Foster
Previous Topic:Table-type control
Next Topic:Checking & Greying tree items
Goto Forum:
  


Current Time: Sat Oct 19 18:28:51 GMT 2019

Powered by FUDForum. Page generated in 0.01494 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top