Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Integer Text Field


Here is some code that only allows 0..9 in a text field.  In future, you
should post requests like this to eclipse tools.

Steve

public static void main (String [] args) {
        Display display = new Display ();
        Shell shell = new Shell (display);
        Text text = new Text (shell, SWT.SINGLE | SWT.BORDER);
        text.pack ();
        text.addListener (SWT.Verify, new Listener () {
                public void handleEvent (Event event) {
                        String text = event.text;
                        for (int i=0; i<text.length (); i++) {
                                char ch = text.charAt (i);
                                if (!('0' <= ch && ch <= '9')) {
                                        event.doit = false;
                                        return;
                                }
                        }
                }
        });
        shell.open ();
        while (!shell.isDisposed ()) {
                if (!display.readAndDispatch ()) display.sleep ();
        }
        display.dispose ();
}



"Prasad Dantuluri" <dantuluriprasad@xxxxxxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

02/20/02 02:34 PM
Please respond to platform-swt-dev

       
        To:        platform-swt-dev@xxxxxxxxxxx
        cc:        
        Subject:        [platform-swt-dev] Integer Text Field


Hi,
  I am trying to implement an Integer Text Field which allows only integers
to be entered in it. Has anybody done this using SWT? If so can you share
the code?

Thanks,
Prasad

>From: "Scott Stanchfield" <scott@xxxxxxxxxxxx>
>Reply-To: platform-swt-dev@xxxxxxxxxxx
>To: <platform-swt-dev@xxxxxxxxxxx>
>Subject: RE: [platform-swt-dev] SWT/AWT Layouts Available
>Date: Wed, 20 Feb 2002 08:01:11 -0500
>
>Many apologies -- should be
>
>   setLayoutData(BorderLayout.NORTH);
>
>(That's what happens when you don't cut paste code that works and try to do
>it from memory...)
>
>Sorry for the confusion!
>-- Scott
>
>==============================================================
>Scott Stanchfield         FGM, Inc.            scott@xxxxxxx
>
>Home Page: http://javadude.com            scott@xxxxxxxxxxxx
>
>Lead author of "Effective VisualAge for Java, Version 3"
>                                       http://javadude.com/evaj
>
>VisualAge for Java Tips and Tricks     http://javadude.com/vaj
>
>AWT & Swing FAQ Manager, jGuru.com
>Visit for Java Enlightenment!             http://www.jguru.com
>==============================================================
>
>
> > -----Original Message-----
> > From: platform-swt-dev-admin@xxxxxxxxxxx
> > [mailto:platform-swt-dev-admin@xxxxxxxxxxx]On Behalf Of Prasad Dantuluri
> > Sent: Tuesday, February 19, 2002 3:58 PM
> > To: platform-swt-dev@xxxxxxxxxxx
> > Subject: Re: [platform-swt-dev] SWT/AWT Layouts Available
> >
> >
> > Hi,
> >   In the borderlayout code,
> >    Composite parent = ...;
> >
> >    parent.setLayout(new BorderLayout());
> >
> >    Button northButton = new Button(parent, SWT.DEFAULT);
> >    northButton.setLayoutConstraint(BorderLayout.NORTH);
> >    northButton.setText("North");
> >
> > I couldn't find the method setLayoutConstraint(BorderLayout.NORTH) in
> > Control class.
> >
> > Help is appreciated.
> >
> > Thanks,
> > Prasad
> >
> >
> >
> > >From: "Scott Stanchfield" <scott@xxxxxxxxxxxx>
> > >Reply-To: platform-swt-dev@xxxxxxxxxxx
> > >To: <platform-ui-dev@xxxxxxxxxxx>, <platform-swt-dev@xxxxxxxxxxx>
> > >Subject: [platform-swt-dev] SWT/AWT Layouts Available
> > >Date: Sat, 16 Feb 2002 14:21:57 -0500
> > >
> > >I've just posted my SWT/AWT Layout managers to my website. They include
> > >AWT's BorderLayout, GridLayout, and FlowLayout, converted into SWT
>Layout
> > >managers.
> > >
> > >You can get them at http://javadude.com/tools, and follow the
> > "SWT Layouts"
> > >link.
> > >
> > >-- Scott
> > >
> > >==============================================================
> > >Scott Stanchfield    scott@xxxxxxxxxxxx    http://javadude.com
> > >
> > >Lead author of "Effective VisualAge for Java, Version 3"
> > >                                       http://javadude.com/evaj
> > >
> > >VisualAge for Java Tips and Tricks     http://javadude.com/vaj
> > >
> > >AWT & Swing FAQ Manager, jGuru.com
> > >Visit for Java Enlightenment!             http://www.jguru.com
> > >==============================================================
> > >
> > >
> > >_______________________________________________
> > >platform-swt-dev mailing list
> > >platform-swt-dev@xxxxxxxxxxx
> > >http://dev.eclipse.org/mailman/listinfo/platform-swt-dev
> >
> >
> >
> >
> > _________________________________________________________________
> > Join the world's largest e-mail service with MSN Hotmail.
> > http://www.hotmail.com
> >
> > _______________________________________________
> > platform-swt-dev mailing list
> > platform-swt-dev@xxxxxxxxxxx
> > http://dev.eclipse.org/mailman/listinfo/platform-swt-dev
>
>_______________________________________________
>platform-swt-dev mailing list
>platform-swt-dev@xxxxxxxxxxx
>http://dev.eclipse.org/mailman/listinfo/platform-swt-dev




_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

_______________________________________________
platform-swt-dev mailing list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev



Back to the top