Groups of Radio Buttons [message #443121] |
Sun, 19 September 2004 12:55 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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 |
Eclipse User |
|
|
|
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
|
|
|
Powered by
FUDForum. Page generated in 0.03691 seconds