Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » how to get a disabled icon
how to get a disabled icon [message #278615] Wed, 05 January 2005 09:44 Go to next message
Eclipse UserFriend
Originally posted by: tom_edwards.hotmail.com

I have a question about icons. If I have an action in a context menu and
an icon associated with it. How can I disable this icon when I disable the
action? Do I need to draw the disabled icon myself and set it as new image
or is there a way Eclipse would do this for me?
TIA, Tom
Re: how to get a disabled icon [message #278640 is a reply to message #278615] Wed, 05 January 2005 11:14 Go to previous message
Eclipse UserFriend
Assuming you're running on XP, you're seeing the correct platform behaviour.
When I run the snippet at the bottom on win2000 the images do appear
disabled, but on XP they don't. If you really want to override this
behaviour then you can listen for MenuDetect and run through the MenuItems
and set each's image to a standard or disabled-looking image as needed.

public static void main(String[] args) {
final Display display = new Display();
Image image = new Image(display, "c:\\smiley.ico"); // <-- image file
final Shell shell = new Shell(display);
shell.setBounds(10, 10, 100, 100);
final Menu menu = new Menu(shell, SWT.POP_UP);
for (int i = 0; i < 9; i++) {
MenuItem item = new MenuItem(menu, SWT.PUSH);
item.setText("Menu Item " + i);
item.setImage(image);
if (i % 2 == 0) item.setEnabled(false);
}
shell.setMenu(menu);
shell.open();
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
image.dispose();
display.dispose();
}

Grant

"Tom Edwards" <tom_edwards@hotmail.com> wrote in message
news:crgugl$3l7$1@www.eclipse.org...
> I have a question about icons. If I have an action in a context menu and
> an icon associated with it. How can I disable this icon when I disable the
> action? Do I need to draw the disabled icon myself and set it as new image
> or is there a way Eclipse would do this for me?
> TIA, Tom
>
Previous Topic:DynamicImport-Package: Can't import the same package from two different bundles?
Next Topic:Help with UI Thread and StatusLineManager
Goto Forum:
  


Current Time: Tue May 06 15:16:08 EDT 2025

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

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

Back to the top