Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Standard Widget Toolkit (SWT) » Groups of Radio Buttons
Groups of Radio Buttons [message #443121] Sun, 19 September 2004 12:55 Go to next message
Eclipse UserFriend
Originally posted by: henning.odense.kollegienet.dk

In Swing you make groups of Radio buttons by adding them to a ButtonGroup.
but how is it done in SWT? I have not been able to find any examples that
explains how it is done. (I think that it is quite easy though, but how to
do it?)

Regards
Henning.
Re: Groups of Radio Buttons [message #443123 is a reply to message #443121] Sun, 19 September 2004 14:41 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: micasim.gmx.de

On Sun, 19 Sep 2004 12:55:24 +0000 (UTC), Henning Skov
<henning@odense.kollegienet.dk> wrote:

> In Swing you make groups of Radio buttons by adding them to a
> ButtonGroup.
> but how is it done in SWT? I have not been able to find any examples that
> explains how it is done. (I think that it is quite easy though, but how
> to
> do it?)
>
> Regards
> Henning.
>

Buttons you add to the same parent Composite are grouped together, as
shown in the snippet where the radio buttons "1.*" and "2.*" are grouped
together.

<<snippet>>
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Shell;

public class Main {
public static void main (String args[]) {
Display display = new Display();
Shell shell = new Shell (display);
shell.setLayout (new FillLayout());

(new Button (shell, SWT.RADIO)).setText ("radio 1.1");
(new Button (shell, SWT.RADIO)).setText ("radio 1.2");
Group g = new Group (shell, SWT.NONE);
g.setLayout (new FillLayout());
(new Button (g, SWT.RADIO)).setText ("radio 2.1");
(new Button (g, SWT.RADIO)).setText ("radio 2.2");

shell.pack();
shell.open();
while (!shell.isDisposed()) if (!display.readAndDispatch())
display.sleep();
display.dispose();
}
}
<</snippet>>

Hope this helps,
Michael
Re: Groups of Radio Buttons [message #443126 is a reply to message #443123] Sun, 19 September 2004 17:27 Go to previous message
Eclipse UserFriend
Originally posted by: henning.odense.kollegienet.dk

Thanks - now I am up and running.

Regards
Henning.


Michael Simons wrote:

> On Sun, 19 Sep 2004 12:55:24 +0000 (UTC), Henning Skov
> <henning@odense.kollegienet.dk> wrote:

> > In Swing you make groups of Radio buttons by adding them to a
> > ButtonGroup.
> > but how is it done in SWT? I have not been able to find any examples that
> > explains how it is done. (I think that it is quite easy though, but how
> > to
> > do it?)
> >
> > Regards
> > Henning.
> >

> Buttons you add to the same parent Composite are grouped together, as
> shown in the snippet where the radio buttons "1.*" and "2.*" are grouped
> together.

> <<snippet>>
> import org.eclipse.swt.SWT;
> import org.eclipse.swt.layout.FillLayout;
> import org.eclipse.swt.widgets.Button;
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Group;
> import org.eclipse.swt.widgets.Shell;

> public class Main {
> public static void main (String args[]) {
> Display display = new Display();
> Shell shell = new Shell (display);
> shell.setLayout (new FillLayout());

> (new Button (shell, SWT.RADIO)).setText ("radio 1.1");
> (new Button (shell, SWT.RADIO)).setText ("radio 1.2");
> Group g = new Group (shell, SWT.NONE);
> g.setLayout (new FillLayout());
> (new Button (g, SWT.RADIO)).setText ("radio 2.1");
> (new Button (g, SWT.RADIO)).setText ("radio 2.2");

> shell.pack();
> shell.open();
> while (!shell.isDisposed()) if (!display.readAndDispatch())
> display.sleep();
> display.dispose();
> }
> }
> <</snippet>>

> Hope this helps,
> Michael
Previous Topic:Bug 67384 SWT_AWT not implemented for mac status?
Next Topic:Failed to create Ole Client
Goto Forum:
  


Current Time: Wed Apr 24 22:59:04 GMT 2024

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

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

Back to the top