Package pivot.wtk

Examples of pivot.wtk.PushButton


    public void startup(Display display, Dictionary<String, String> properties)
        throws Exception {
        FlowPane flowPane = new FlowPane();
        flowPane.getStyles().put("horizontalAlignment", HorizontalAlignment.CENTER);

        helloButton = new PushButton("Say Hello");
        flowPane.add(helloButton);

        helloButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                BrowserApplicationContext.eval("sayHello(\"Hello from Java!\")", DOMTest.this);
View Full Code Here


                return consumed;
            }
        });

        PushButton submitButton = (PushButton)serializer.getObjectByID("request.submit");
        submitButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(final Button button) {
                button.setEnabled(false);

                Request httpRequest = getRequest();
                httpRequest.execute(new TaskAdapter<Response>(new TaskListener<Response>() {
View Full Code Here

        RadioButton oneButton =
            (RadioButton)wtkxSerializer.getObjectByName("oneButton");
        final Button.Group numbersGroup = oneButton.getGroup();

        // Add a button press listener
        PushButton selectButton =
            (PushButton)wtkxSerializer.getObjectByName("selectButton");

        selectButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                String message = "You selected \""
                    + numbersGroup.getSelection().getButtonData()
                    + "\".";
                Alert.alert(MessageType.INFO, message, window);
View Full Code Here

    private Color disabledGradientEndColor = new Color(0x4c, 0x4c, 0x4c);

    private int cornerRadius = 6;

    public int getPreferredWidth(int height) {
        PushButton pushButton = (PushButton)getComponent();
        Button.DataRenderer dataRenderer = pushButton.getDataRenderer();

        dataRenderer.render(pushButton.getButtonData(), pushButton, false);

        // Include padding in constraint
        if (height != -1) {
            height = Math.max(height - (padding.top + padding.bottom + 2), 0);
        }
View Full Code Here

        return preferredWidth;
    }

    public int getPreferredHeight(int width) {
        PushButton pushButton = (PushButton)getComponent();
        Button.DataRenderer dataRenderer = pushButton.getDataRenderer();

        dataRenderer.render(pushButton.getButtonData(), pushButton, false);

        // Include padding in constraint
        if (width != -1) {
            width = Math.max(width - (padding.left + padding.right + 2), 0);
        }
View Full Code Here

        FlowPane buttonFlowPane = (FlowPane)wtkxSerializer.getObjectByName("buttonFlowPane");

        for (int i = 0, n = alert.getOptionCount(); i < n; i++) {
            Object option = alert.getOption(i);

            PushButton optionButton = new PushButton(option);
            HashMap<String, Object> optionButtonStyles = new HashMap<String, Object>();
            optionButtonStyles.put("color", theme.getColor(4));
            optionButtonStyles.put("backgroundColor", theme.getColor(16));
            optionButtonStyles.put("borderColor", theme.getColor(13));

            optionButton.setStyles(optionButtonStyles);
            optionButton.getStyles().put("preferredAspectRatio", 3);

            optionButton.getButtonPressListeners().add(new ButtonPressListener() {
                public void buttonPressed(Button button) {
                    int optionIndex = optionButtons.indexOf(button);

                    if (optionIndex >= 0) {
                        Alert alert = (Alert)getComponent();
View Full Code Here

        return preferredHeight;
    }

    public Dimensions getPreferredSize() {
        PushButton pushButton = (PushButton)getComponent();
        Button.DataRenderer dataRenderer = pushButton.getDataRenderer();

        dataRenderer.render(pushButton.getButtonData(), pushButton, false);

        Dimensions preferredContentSize = dataRenderer.getPreferredSize();

        int preferredWidth = preferredContentSize.width
            + padding.left + padding.right + 2;
View Full Code Here

        return new Dimensions(preferredWidth, preferredHeight);
    }

    public void paint(Graphics2D graphics) {
        PushButton pushButton = (PushButton)getComponent();

        Color borderColor = null;
        Color gradientStartColor = null;
        Color gradientEndColor = null;

        if (pushButton.isEnabled()) {
            if (pressed
                || pushButton.isSelected()) {
                borderColor = pressedBorderColor;
                gradientStartColor = pressedGradientStartColor;
                gradientEndColor = pressedGradientEndColor;
            } else {
                if (highlighted) {
                    borderColor = highlightedBorderColor;
                    gradientStartColor = highlightedGradientStartColor;
                    gradientEndColor = highlightedGradientEndColor;
                } else {
                    borderColor = this.borderColor;
                    gradientStartColor = this.gradientStartColor;
                    gradientEndColor = this.gradientEndColor;
                }
            }
        }
        else {
            borderColor = disabledBorderColor;
            gradientStartColor = disabledGradientStartColor;
            gradientEndColor = disabledGradientEndColor;
        }

        int width = getWidth();
        int height = getHeight();

        Graphics2D contentGraphics = (Graphics2D)graphics.create();

        // Paint the background
        RoundRectangle2D buttonRectangle = new RoundRectangle2D.Double(0, 0,
            width - 1, height - 1, cornerRadius, cornerRadius);

        graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);

        graphics.setPaint(new GradientPaint(width / 2, 0, gradientStartColor,
            width / 2, height, gradientEndColor));
        graphics.fill(buttonRectangle);

        // Paint the border
        graphics.setPaint(borderColor);
        graphics.setStroke(new BasicStroke());
        graphics.draw(buttonRectangle);

        // Paint the content
        Button.DataRenderer dataRenderer = pushButton.getDataRenderer();
        dataRenderer.render(pushButton.getButtonData(), pushButton, false);
        dataRenderer.setSize(Math.max(width - (padding.left + padding.right + 2), 0),
            Math.max(getHeight() - (padding.top + padding.bottom + 2), 0));

        contentGraphics.translate(padding.left + 1, padding.top + 1);
        contentGraphics.clipRect(0, 0, dataRenderer.getWidth(), dataRenderer.getHeight());
        dataRenderer.paint(contentGraphics);

        // Paint the focus state
        if (pushButton.isFocused()) {
            BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND,
                BasicStroke.JOIN_ROUND, 1.0f, new float[] {0.0f, 2.0f}, 0.0f);

            graphics.setColor(highlightedGradientStartColor);
            graphics.setStroke(dashStroke);
View Full Code Here

        WTKXSerializer wtkxSerializer = new WTKXSerializer();
        Component content =
            (Component)wtkxSerializer.readObject("pivot/tutorials/buttons/push_buttons.wtkx");

        // Get a reference to the button and add a button press listener
        PushButton pushButton =
            (PushButton)wtkxSerializer.getObjectByName("pushButton");
        pushButton.getButtonPressListeners().add(new ButtonPressListener() {
            public void buttonPressed(Button button) {
                Alert.alert(MessageType.INFO, "You clicked me!", window);
            }
        });
View Full Code Here

        FlowPane buttonFlowPane = (FlowPane)wtkxSerializer.getObjectByName("buttonFlowPane");

        for (int i = 0, n = prompt.getOptionCount(); i < n; i++) {
            Object option = prompt.getOption(i);

            PushButton optionButton = new PushButton(option);
            HashMap<String, Object> optionButtonStyles = new HashMap<String, Object>();
            optionButtonStyles.put("color", theme.getColor(4));
            optionButtonStyles.put("backgroundColor", theme.getColor(16));
            optionButtonStyles.put("borderColor", theme.getColor(13));

            optionButton.setStyles(optionButtonStyles);
            optionButton.getStyles().put("preferredAspectRatio", 3);

            optionButton.getButtonPressListeners().add(new ButtonPressListener() {
                public void buttonPressed(Button button) {
                    int optionIndex = optionButtons.indexOf(button);

                    if (optionIndex >= 0) {
                        Prompt prompt = (Prompt)getComponent();
View Full Code Here

TOP

Related Classes of pivot.wtk.PushButton

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.