Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Checkbox


        return new Dimensions(preferredWidth, preferredHeight);
    }

    @Override
    public int getBaseline(int width, int height) {
        Checkbox checkbox = (Checkbox) getComponent();

        int baseline = -1;

        Button.DataRenderer dataRenderer = checkbox.getDataRenderer();
        dataRenderer.render(checkbox.getButtonData(), checkbox, false);

        int clientWidth = Math.max(width - (CHECKBOX_SIZE + spacing), 0);
        baseline = dataRenderer.getBaseline(clientWidth, height);

        return baseline;
View Full Code Here


        return baseline;
    }

    @Override
    public void paint(Graphics2D graphics) {
        Checkbox checkbox = (Checkbox)getComponent();
        int width = getWidth();
        int height = getHeight();

        // Paint the button
        int offset = (height - CHECKBOX_SIZE) / 2;
        graphics.translate(0, offset);
        paintButton(graphics, checkbox.isEnabled(), checkbox.getState());
        graphics.translate(0, -offset);

        // Paint the content
        Button.DataRenderer dataRenderer = checkbox.getDataRenderer();
        Object buttonData = checkbox.getButtonData();
        dataRenderer.render(buttonData, checkbox, false);
        dataRenderer.setSize(Math.max(width - (CHECKBOX_SIZE + spacing * 2), 0), height);

        Graphics2D contentGraphics = (Graphics2D)graphics.create();
        contentGraphics.translate(CHECKBOX_SIZE + spacing, 0);
        contentGraphics.clipRect(0, 0, dataRenderer.getWidth(), dataRenderer.getHeight());
        dataRenderer.paint(contentGraphics);
        contentGraphics.dispose();

        // Paint the focus state
        if (checkbox.isFocused()) {
            if (buttonData == null) {
                Color focusColor = new Color(buttonSelectionColor.getRed(),
                    buttonSelectionColor.getGreen(),
                    buttonSelectionColor.getBlue(), 0x44);
                graphics.setColor(focusColor);
View Full Code Here

    private Component addBooleanControl(final Dictionary<String, Object> dictionary,
        final String key, Form.Section section) {
        boolean value = (Boolean)dictionary.get(key);

        Checkbox checkbox = new Checkbox();
        checkbox.setSelected(value);
        section.add(checkbox);
        Form.setLabel(checkbox, key);

        checkbox.getButtonStateListeners().add(new ButtonStateListener() {
            private boolean updating = false;

            @Override
            public void stateChanged(Button button, Button.State previousState) {
                if (!updating) {
View Full Code Here

        return checkbox;
    }

    private void updateBooleanControl(Dictionary<String, Object> dictionary, String key) {
        Checkbox checkbox = (Checkbox)controls.get(key);

        if (checkbox != null) {
            boolean value = (Boolean)dictionary.get(key);
            checkbox.setSelected(value);
        }
    }
View Full Code Here

    private Component addBooleanControl(final Dictionary<String, Object> dictionary,
        final String key, Form.Section section) {
        boolean value = (Boolean)dictionary.get(key);

        Checkbox checkbox = new Checkbox();
        checkbox.setSelected(value);
        section.add(checkbox);
        Form.setLabel(checkbox, key);

        checkbox.getButtonStateListeners().add(new ButtonStateListener() {
            private boolean updating = false;

            @Override
            public void stateChanged(Button button, Button.State previousState) {
                if (!updating) {
View Full Code Here

        return checkbox;
    }

    private void updateBooleanControl(Dictionary<String, Object> dictionary, String key) {
        Checkbox checkbox = (Checkbox)controls.get(key);

        if (checkbox != null) {
            boolean value = (Boolean)dictionary.get(key);
            checkbox.setSelected(value);
        }
    }
View Full Code Here

    private Component addBooleanControl(final Dictionary<String, Object> dictionary,
        final String key, Form.Section section) {
        boolean value = (Boolean)dictionary.get(key);

        Checkbox checkbox = new Checkbox();
        checkbox.setSelected(value);
        section.add(checkbox);
        Form.setLabel(checkbox, key);

        checkbox.getButtonStateListeners().add(new ButtonStateListener() {
            private boolean updating = false;

            @Override
            public void stateChanged(Button button, Button.State previousState) {
                if (!updating) {
View Full Code Here

        return checkbox;
    }

    private void updateBooleanControl(Dictionary<String, Object> dictionary, String key) {
        Checkbox checkbox = (Checkbox)controls.get(key);

        if (checkbox != null) {
            boolean value = (Boolean)dictionary.get(key);
            checkbox.setSelected(value);
        }
    }
View Full Code Here

        ArrayList<String> numbers = new ArrayList<String>("One", "Two", "Three", "Four", "Five",
            "Six", "Seven", "Eight", "Nine", "Ten");

        for (String number : numbers) {
            Checkbox checkbox = new Checkbox(number);
            checkbox.getButtonStateListeners().add(buttonStateListener);
            checkboxBoxPane.add(checkbox);
        }
    }
View Full Code Here

        });

        Action.getNamedActions().put("addCheckbox", new Action() {
            @Override
            public void perform(Component source) {
                componentBoxPane.add(new Checkbox("Checkbox"));
            }
        });

        Action.getNamedActions().put("addRadioButton", new Action() {
            @Override
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Checkbox

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.