Package net.rim.device.api.ui.component

Examples of net.rim.device.api.ui.component.BasicEditField


     * Creates a new InfoScreen object
     */
    public InfoScreen() {
        _countryField = new LabelField();
        _popField =
                new BasicEditField(_resources.getString(FIELD_POP), null, 20,
                        Field.NON_FOCUSABLE);
        _langField =
                new BasicEditField(_resources.getString(FIELD_LANG), null, 20,
                        Field.NON_FOCUSABLE);
        _citiesField =
                new BasicEditField(_resources.getString(FIELD_CITIES), null,
                        50, Field.NON_FOCUSABLE);

        add(_countryField);
        add(new SeparatorField());
        add(_popField);
View Full Code Here


        _statusField = new LabelField("");
        setStatus(_statusField);

        // Free form address entry field
        _addressField =
                new BasicEditField("Destination: ", "", 500,
                        TextField.NO_NEWLINE);
        add(_addressField);

        // Start/end time selection
        final VerticalFieldManager vfm = new VerticalFieldManager();
View Full Code Here

                final Dialog clickDialog =
                        new Dialog(Dialog.D_OK_CANCEL,
                                "Specify click location", Dialog.OK, null,
                                Manager.BOTTOMMOST);

                final BasicEditField xPos1Input =
                        new BasicEditField("Click position x1: ", "");
                final BasicEditField yPos1Input =
                        new BasicEditField("Click position y1: ", "");
                final BasicEditField xPos2Input =
                        new BasicEditField("Click position x2: ", "");
                final BasicEditField yPos2Input =
                        new BasicEditField("Click position y2: ", "");

                clickDialog.add(xPos1Input);
                clickDialog.add(yPos1Input);
                clickDialog.add(xPos2Input);
                clickDialog.add(yPos2Input);

                // Display the dialog
                clickDialog.doModal();

                // Check if the user clicked OK
                if (clickDialog.getSelectedValue() == Dialog.OK) {
                    // Clear the output string
                    _output.delete(0, _output.length());

                    try {
                        // Clear the output string
                        _output.delete(0, _output.length());

                        // Check that integers were entered and that the
                        // coordinates are valid.
                        final int x1 = Integer.parseInt(xPos1Input.getText());
                        final int y1 = Integer.parseInt(yPos1Input.getText());
                        final int x2 = Integer.parseInt(xPos2Input.getText());
                        final int y2 = Integer.parseInt(yPos2Input.getText());

                        EventInjector.TouchEvent.invokeClickThrough(x1, y1, x2,
                                y2);

                        updateOutputText();
                    } catch (final NumberFormatException nfe) {
                        Dialog.alert("Invalid input: " + nfe.getMessage()
                                + "\n\nPlease enter a number.");
                    } catch (final IllegalArgumentException iae) {
                        Dialog.alert("Invalid coordinate. \n\nPlease try again.");
                    }
                }
            }
        }));

        /*
         * A menu item to invoke a TouchEvent which clicks the button field on
         * the screen.
         */
        final MenuItem clickButton =
                new MenuItem(new StringProvider("Click the button"), 0x230010,
                        1);
        clickButton.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                // Calculate button position
                final Manager manager = getMainManager();
                final XYRect managerExtent = manager.getExtent(); // Scrollable
                                                                  // section of
                                                                  // the screen
                final int titleHeight = managerExtent.y; // Top of the
                                                         // scrollable section
                final XYRect buttonExtent = _sampleButton.getExtent();
                final int buttonYCoordinate =
                        buttonExtent.y + titleHeight
                                + _sampleButton.getHeight() / 2; // Middle of
                                                                 // the button

                // Create the four touch events needed to click the button
                final EventInjector.TouchEvent downEvent =
                        new EventInjector.TouchEvent(TouchEvent.DOWN, 40,
                                buttonYCoordinate, -1, -1, -1);
                final EventInjector.TouchEvent clickEvent =
                        new EventInjector.TouchEvent(TouchEvent.CLICK, 40,
                                buttonYCoordinate, -1, -1, -1);
                final EventInjector.TouchEvent unclickEvent =
                        new EventInjector.TouchEvent(TouchEvent.UNCLICK, 40,
                                buttonYCoordinate, -1, -1, -1);
                final EventInjector.TouchEvent upEvent =
                        new EventInjector.TouchEvent(TouchEvent.UP, 40,
                                buttonYCoordinate, -1, -1, -1);

                // Clear the output string
                _output.delete(0, _output.length());

                // Invoke the touch events
                EventInjector.invokeEvent(downEvent);
                EventInjector.invokeEvent(clickEvent);
                EventInjector.invokeEvent(unclickEvent);
                EventInjector.invokeEvent(upEvent);

                updateOutputText();
            }
        }));

        // A menu item to swipe the screen
        final MenuItem swipe =
                new MenuItem(new StringProvider("Swipe the screen"), 0x230020,
                        2);
        swipe.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                /**
                 * Create a move event array to pass into injectSwipeGesture().
                 * This array contains move events for one touch point.
                 */
                final EventInjector.TouchEvent[] moveEvents =
                        new EventInjector.TouchEvent[3];
                moveEvents[0] =
                        new EventInjector.TouchEvent(TouchEvent.MOVE, 60, 60,
                                -1, -1, -1);
                moveEvents[1] =
                        new EventInjector.TouchEvent(TouchEvent.MOVE, 120, 120,
                                -1, -1, -1);
                moveEvents[2] =
                        new EventInjector.TouchEvent(TouchEvent.MOVE, 50, 50,
                                -1, -1, -1);

                // Clear the output string
                _output.delete(0, _output.length());

                // Inject a swipe gesture with origin coordinates of (0, 0)
                EventInjector.TouchEvent.injectSwipeGesture(0, 0, moveEvents);
                updateOutputText();
            }
        }));

        /*
         * A menu item to display a dialog that allows the user to specify
         * screen location for injecting a tap gesture.
         */
        final MenuItem tap =
                new MenuItem(new StringProvider("Tap the screen"), 0x230040, 4);
        tap.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                // Dialog containing the input fields for x and y coordinates
                // and
                // number of taps.
                final Dialog tapDialog =
                        new Dialog(Dialog.D_OK_CANCEL, "Specify tap location",
                                Dialog.OK, null, Manager.NO_VERTICAL_SCROLL);

                final BasicEditField xPosInput =
                        new BasicEditField("Tap position x: ", "");
                final BasicEditField yPosInput =
                        new BasicEditField("Tap position y: ", "");
                final BasicEditField tapCountInput =
                        new BasicEditField("Number of taps: ", "");

                tapDialog.add(xPosInput);
                tapDialog.add(yPosInput);
                tapDialog.add(tapCountInput);

                // Display the dialog
                tapDialog.doModal();

                if (tapDialog.getSelectedValue() == Dialog.OK) {

                    // Clear the output string
                    _output.delete(0, _output.length());

                    try {
                        // Check that integers were entered and that the
                        // coordinates
                        // and taps are valid.
                        final int x = Integer.parseInt(xPosInput.getText());
                        final int y = Integer.parseInt(yPosInput.getText());
                        final int taps =
                                Integer.parseInt(tapCountInput.getText());

                        EventInjector.TouchEvent.injectTapGesture(x, y, taps);

                        updateOutputText();
                    } catch (final NumberFormatException nfe) {
                        Dialog.alert("Invalid input: " + nfe.getMessage()
                                + "\n\nPlease enter a number.");
                    } catch (final IllegalArgumentException iae) {
                        Dialog.alert("Invalid coordinate or tap count. \n\nPlease try again.");
                    }
                }
            }
        }));

        /*
         * A menu item to display a dialog that allows the user to specify
         * screen location for injecting a two finger tap.
         */
        final MenuItem twoFingerTap =
                new MenuItem(new StringProvider("Two Finger Tap the screen"),
                        0x230050, 5);
        twoFingerTap.setCommand(new Command(new CommandHandler() {
            /**
             * @see net.rim.device.api.command.CommandHandler#execute(ReadOnlyCommandMetadata,
             *      Object)
             */
            public void execute(final ReadOnlyCommandMetadata metadata,
                    final Object context) {
                final Dialog tapDialog =
                        new Dialog(Dialog.D_OK_CANCEL, "Specify tap location",
                                Dialog.OK, null, Manager.NO_VERTICAL_SCROLL);

                final BasicEditField xPos1Input =
                        new BasicEditField("Tap position x1: ", "");
                final BasicEditField yPos1Input =
                        new BasicEditField("Tap position y1: ", "");
                final BasicEditField xPos2Input =
                        new BasicEditField("Tap position x2: ", "");
                final BasicEditField yPos2Input =
                        new BasicEditField("Tap position y2: ", "");
                final NumericChoiceField touchPointInput =
                        new NumericChoiceField("Touch point: ", 1, 2, 1);

                tapDialog.add(xPos1Input);
                tapDialog.add(yPos1Input);
                tapDialog.add(xPos2Input);
                tapDialog.add(yPos2Input);
                tapDialog.add(touchPointInput);

                // Display the dialog
                tapDialog.doModal();

                if (tapDialog.getSelectedValue() == Dialog.OK) {
                    // Clear the output string
                    _output.delete(0, _output.length());

                    try {
                        final int x1 = Integer.parseInt(xPos1Input.getText());
                        final int y1 = Integer.parseInt(yPos1Input.getText());
                        final int x2 = Integer.parseInt(xPos2Input.getText());
                        final int y2 = Integer.parseInt(yPos2Input.getText());
                        final int touchPoint =
                                touchPointInput.getSelectedValue();

                        EventInjector.TouchEvent.injectTwoFingerTap(x1, y1, x2,
                                y2, touchPoint);
View Full Code Here

    public ConnectionTestsScreen() {
        setTitle("Connection Tests");

        // Display URL label and edit box on top of the screen
        _urlEditField =
                new BasicEditField("URL: ", "http://www.blackberry.com", 128,
                        BasicEditField.FILTER_URL);
        add(_urlEditField);

        // Display "Connect" button that triggers connection to be established
        // with the specified URL.
        final ButtonField connectBtn =
                new ButtonField("Connect", Field.FIELD_HCENTER
                        | ButtonField.CONSUME_CLICK);
        connectBtn.setChangeListener(this);

        // Display "Show Options" button that displays connection options when
        // clicked
        _optionsBtn =
                new ButtonField("Show Options", Field.FIELD_HCENTER
                        | ButtonField.CONSUME_CLICK);
        _optionsBtn.setChangeListener(this);
        _optionsHidden = true;

        add(new SeparatorField());

        // Region to layout "Connect" and "Show Options" buttons side by side
        final HorizontalFieldManager hfmBtns =
                new HorizontalFieldManager(Field.FIELD_HCENTER);
        hfmBtns.add(connectBtn);
        hfmBtns.add(_optionsBtn);
        add(hfmBtns);

        add(new SeparatorField());

        _labelConnectionOpt = new LabelField("Connection Settings [optional]");

        // Connection mode
        final String[] connectionModes = { "READ", "WRITE", "READ/WRITE" };
        _connectionMode =
                new ObjectChoiceField("  Connection Mode: ", connectionModes, 2);

        // Connection timeout
        _timeoutSupported = new CheckboxField("  Support timeouts", false);
        _connectionTimeout =
                new BasicEditField("Connection timeout: ", "", 6,
                        BasicEditField.FILTER_INTEGER);

        // Connection security settings for tls/ssl
        _endToEndRequired =
                new CheckboxField("  tls/ssl end to end required", false);
        _endToEndDesired =
                new CheckboxField("  tls/ssl end to end desired", false);

        // Connection retry options
        _labelRetriesOpt = new LabelField("Retry options [optional]");
        _timeLimit =
                new BasicEditField("  Time Limit for Connections: ", "0", 6,
                        BasicEditField.FILTER_INTEGER);
        _attemptsLimit =
                new BasicEditField("  Attempts Limit: ", "0", 4,
                        BasicEditField.FILTER_INTEGER);
        _retryFactor =
                new BasicEditField("  Retry Factor: ", "0", 6,
                        BasicEditField.FILTER_INTEGER);

        // Transport selection
        final String[] transportNames =
                { "none", "TCP Cellular", "Wap", "Wap2", "Mds", "Bis B",
View Full Code Here

    public UDPClientScreen() {
        // Initialize UI components --------------------------------------------
        setTitle("UDP Client");

        _urlField =
                new BasicEditField("URL:  ", _domain + SERVER_PORT, 128,
                        BasicEditField.FILTER_URL);

        final HorizontalFieldManager hfmButtons = new HorizontalFieldManager();
        _wifiButton =
                new ButtonField("TCP WiFi", Field.FIELD_HCENTER
View Full Code Here

TOP

Related Classes of net.rim.device.api.ui.component.BasicEditField

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.