Search in sources :

Example 1 with Checkbox

use of org.apache.pivot.wtk.Checkbox in project pivot by apache.

the class ComponentInspectorSkin method updateBooleanControl.

private void updateBooleanControl(Dictionary<String, Object> dictionary, String key) {
    Checkbox checkbox = (Checkbox) controls.get(key);
    if (checkbox != null) {
        boolean value = dictionary.getBoolean(key);
        checkbox.setSelected(value);
    }
}
Also used : Checkbox(org.apache.pivot.wtk.Checkbox)

Example 2 with Checkbox

use of org.apache.pivot.wtk.Checkbox in project pivot by apache.

the class ComponentInspectorSkin method addBooleanControl.

private Component addBooleanControl(final Dictionary<String, Object> dictionary, final String key, Form.Section section) {
    boolean value = dictionary.getBoolean(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) {
                updating = true;
                try {
                    dictionary.put(key, button.isSelected());
                } catch (Exception exception) {
                    displayErrorMessage(exception, button.getWindow());
                    button.setState(previousState);
                } finally {
                    updating = false;
                }
            }
        }
    });
    return checkbox;
}
Also used : CalendarButton(org.apache.pivot.wtk.CalendarButton) ColorChooserButton(org.apache.pivot.wtk.ColorChooserButton) Button(org.apache.pivot.wtk.Button) ListButton(org.apache.pivot.wtk.ListButton) Checkbox(org.apache.pivot.wtk.Checkbox) ButtonStateListener(org.apache.pivot.wtk.ButtonStateListener)

Example 3 with Checkbox

use of org.apache.pivot.wtk.Checkbox in project pivot by apache.

the class BXMLExplorerDocument method setComponentIconOnTreeNode.

private static void setComponentIconOnTreeNode(TreeNode treeNode, Object comp) {
    String resource = null;
    if (comp instanceof Label) {
        resource = "label.png";
    }
    if (comp instanceof ImageView) {
        resource = "/org/apache/pivot/tutorials/IMG_0725_2.jpg";
    }
    if (comp instanceof PushButton) {
        resource = "pushbutton.png";
    }
    if (comp instanceof RadioButton) {
        resource = "radiobutton.png";
    }
    if (comp instanceof Checkbox) {
        resource = "checkbox.png";
    }
    if (comp instanceof LinkButton) {
        resource = "linkbutton.png";
    }
    if (comp instanceof TablePane) {
        resource = "tablepane.png";
    }
    if (resource != null) {
        URL url = BXMLExplorerDocument.class.getResource(resource);
        if (url == null) {
            throw new IllegalStateException("could not load resource " + resource);
        }
        treeNode.setIcon(url);
    }
}
Also used : Checkbox(org.apache.pivot.wtk.Checkbox) Label(org.apache.pivot.wtk.Label) ImageView(org.apache.pivot.wtk.ImageView) RadioButton(org.apache.pivot.wtk.RadioButton) PushButton(org.apache.pivot.wtk.PushButton) LinkButton(org.apache.pivot.wtk.LinkButton) URL(java.net.URL) TablePane(org.apache.pivot.wtk.TablePane)

Example 4 with Checkbox

use of org.apache.pivot.wtk.Checkbox in project pivot by apache.

the class CheckboxSkin method keyReleased.

/**
 * {@link KeyCode#SPACE SPACE} 'presses' the button.
 */
@Override
public boolean keyReleased(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
    boolean consumed = false;
    Checkbox checkbox = (Checkbox) getComponent();
    if (keyCode == Keyboard.KeyCode.SPACE) {
        checkbox.press();
    } else {
        consumed = super.keyReleased(component, keyCode, keyLocation);
    }
    return consumed;
}
Also used : Checkbox(org.apache.pivot.wtk.Checkbox)

Example 5 with Checkbox

use of org.apache.pivot.wtk.Checkbox in project pivot by apache.

the class TerraCheckboxSkin method getPreferredWidth.

@Override
public int getPreferredWidth(int height) {
    Checkbox checkbox = (Checkbox) getComponent();
    Button.DataRenderer dataRenderer = checkbox.getDataRenderer();
    int preferredWidth = CHECKBOX_SIZE;
    Object buttonData = checkbox.getButtonData();
    if (buttonData != null) {
        dataRenderer.render(buttonData, checkbox, false);
        preferredWidth += dataRenderer.getPreferredWidth(height) + spacing * 2;
    }
    return preferredWidth;
}
Also used : Button(org.apache.pivot.wtk.Button) Checkbox(org.apache.pivot.wtk.Checkbox) Paint(java.awt.Paint) GradientPaint(java.awt.GradientPaint)

Aggregations

Checkbox (org.apache.pivot.wtk.Checkbox)13 Button (org.apache.pivot.wtk.Button)9 GradientPaint (java.awt.GradientPaint)5 Paint (java.awt.Paint)5 ListButton (org.apache.pivot.wtk.ListButton)3 PushButton (org.apache.pivot.wtk.PushButton)3 BoxPane (org.apache.pivot.wtk.BoxPane)2 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)2 ButtonStateListener (org.apache.pivot.wtk.ButtonStateListener)2 Frame (org.apache.pivot.wtk.Frame)2 ListView (org.apache.pivot.wtk.ListView)2 Sheet (org.apache.pivot.wtk.Sheet)2 SheetCloseListener (org.apache.pivot.wtk.SheetCloseListener)2 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 File (java.io.File)1 URL (java.net.URL)1 FileObject (org.apache.commons.vfs2.FileObject)1