Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.PushButton


        messageLabel = (Label)wtkxSerializer.get("messageLabel");
        messageBoxPane = (BoxPane)wtkxSerializer.get("messageBoxPane");
        optionButtonBoxPane = (BoxPane)wtkxSerializer.get("optionButtonBoxPane");

        for (Object option : prompt.getOptions()) {
            PushButton optionButton = new PushButton(option);
            optionButton.setStyles(commandButtonStyles);
            optionButton.getButtonPressListeners().add(optionButtonPressListener);

            optionButtonBoxPane.add(optionButton);
        }

        messageTypeChanged(prompt, null);
View Full Code Here


    @Override
    public void optionInserted(Prompt prompt, int index) {
        Object option = prompt.getOptions().get(index);

        PushButton optionButton = new PushButton(option);
        optionButton.setStyles(commandButtonStyles);
        optionButton.getButtonPressListeners().add(optionButtonPressListener);

        optionButtonBoxPane.insert(optionButton, index);
    }
View Full Code Here

    private int cornerRadius = 6;

    @Override
    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;
    }

    @Override
    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

        return preferredHeight;
    }

    @Override
    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);
    }

    @Override
    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_BUTT,
                BasicStroke.JOIN_ROUND, 1.0f, new float[] {1.0f, 1.0f}, 0.0f);

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

        BoxPane buttonBoxPane = (BoxPane)wtkxSerializer.get("buttonBoxPane");

        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("minimumAspectRatio", 3);

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

                    if (optionIndex >= 0) {
View Full Code Here

        BoxPane buttonBoxPane = (BoxPane)wtkxSerializer.get("buttonBoxPane");

        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("minimumAspectRatio", 3);

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

                    if (optionIndex >= 0) {
View Full Code Here

        throws Exception {
        window = new Window();
        BoxPane boxPane = new BoxPane();
        boxPane.getStyles().put("horizontalAlignment", HorizontalAlignment.RIGHT);

        PushButton uploadButton = new PushButton("Upload");
        uploadButton.getStyles().put("minimumAspectRatio", 3.0f);
        boxPane.add(uploadButton);

        window.setContent(boxPane);
        window.setMaximized(true);
View Full Code Here

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

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

        helloButton.getButtonPressListeners().add(new ButtonPressListener() {
            @Override
            public void buttonPressed(Button button) {
View Full Code Here

TOP

Related Classes of org.apache.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.