Subject: Radio Group / Listener |
Author: charlie schindler |
Date: Thu, 13 November 2014 04:48 |
Hi
I created a radio group with 2 buttons (Yes/No)
Now depending which button is selected a field needs to change color.
I tried the following Listener (full code attached):
tropicamideGroup.addListener(SWT.Selection, new Listener()
{
public void handleEvent(Event event)
{
switch (tropicamideGroup.getSelectionIndex())
{
case 0:
txtAuthorized.setBackground(SWTResourceManager.getColor(60, 179, 113));
txtAuthorized.setText("\r\nAuthorized");
break;
case 1:
txtAuthorized.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
txtAuthorized.setText("\r\nNot Authorized");
break;
}
// recreateAndLayout();
}
});
I tried also this version:
tropicamideGroup.addSelectionListener(new SelectionAdapter()
{
@Override
public void widgetSelected(SelectionEvent e)
{
RadioItem[] radioItems = tropicamideGroup.getItems();
if (radioItems[0].equals(e.item))
{
txtAuthorized.setBackground(SWTResourceManager.getColor(60, 179, 113));
txtAuthorized.setText("\r\nAuthorized");
}
if (radioItems[1].equals(e.item))
{
txtAuthorized.setBackground(SWTResourceManager.getColor(SWT.COLOR_DARK_RED));
txtAuthorized.setText("\r\nNot Authorized");
}
}
none of them changes the color
what do i do wrong?
|
[ Reply ][ Quote ][ View Topic/Message ][ Unsubscribe from this forum ]
|