Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[nebula-dev] New topic in forum Nebula, called Radio Group / Listener, by charlie schindler

Title: Eclipse Community Forums
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?

Attachment: PpmsForm.java
(Size: 64.96KB, Downloaded 0 times)
[ Reply ][ Quote ][ View Topic/Message ][ Unsubscribe from this forum ]

Back to the top