Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Nebula » Radio Group / Listener(add Listener to radio group to change color in another field)
Radio Group / Listener [message #1471734] Thu, 13 November 2014 09:48 Go to next message
charlie schindler is currently offline charlie schindlerFriend
Messages: 28
Registered: June 2014
Junior Member
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 345 times)
Re: Radio Group / Listener [message #1471888 is a reply to message #1471734] Thu, 13 November 2014 12:23 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Hi Charlie,

Please provide a running snippet with only the minimum code that exposes your problem and I will take a look. I have to do too much work to make your sample code work.

For examples on snippets see http://www.eclipse.org/nebula/snippets.php

Best regards,

Wim
Re: Radio Group / Listener [message #1472558 is a reply to message #1471888] Fri, 14 November 2014 00:16 Go to previous messageGo to next message
charlie schindler is currently offline charlie schindlerFriend
Messages: 28
Registered: June 2014
Junior Member
Hi Wim

Thx for the reply. I actually took the listener from the radio example code.
I am currently not at the development machine, but on monday i will put a small dialog with a main() and only the radio group and the text up here for you to have a look at it.
Re: Radio Group / Listener [message #1473124 is a reply to message #1472558] Fri, 14 November 2014 10:59 Go to previous messageGo to next message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Great Thanks!
Re: Radio Group / Listener [message #1476402 is a reply to message #1473124] Mon, 17 November 2014 03:33 Go to previous messageGo to next message
charlie schindler is currently offline charlie schindlerFriend
Messages: 28
Registered: June 2014
Junior Member
Morning Wim
Looks like it works in this demo.
It seems that when using the quick test, the does not use the listener

I add the short test also for others who might be interested in the solution.
Sort of a snippet..
Re: Radio Group / Listener [message #1482120 is a reply to message #1476402] Fri, 21 November 2014 14:02 Go to previous message
Wim Jongman is currently offline Wim JongmanFriend
Messages: 493
Registered: July 2009
Senior Member

Cool. Well done.
Previous Topic:TableCombo with autocomplete
Next Topic:Trace Type SOLID_LANE join all points
Goto Forum:
  


Current Time: Sat Nov 09 01:44:52 GMT 2024

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

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

Back to the top