Search in sources :

Example 1 with RadioButton

use of org.apache.pivot.wtk.RadioButton 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 2 with RadioButton

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

the class FillPanes method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    fillPane = (FillPane) namespace.get("fillPane");
    horizontalOrientationButton = (RadioButton) namespace.get("horizontalOrientationButton");
    verticalOrientationButton = (RadioButton) namespace.get("verticalOrientationButton");
    ButtonStateListener buttonStateListener = new ButtonStateListener() {

        @Override
        public void stateChanged(Button button, Button.State previousState) {
            updateFillPaneState();
        }
    };
    horizontalOrientationButton.getButtonStateListeners().add(buttonStateListener);
    verticalOrientationButton.getButtonStateListeners().add(buttonStateListener);
    updateFillPaneState();
}
Also used : RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) ButtonStateListener(org.apache.pivot.wtk.ButtonStateListener)

Example 3 with RadioButton

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

the class TerraRadioButtonSkin method getPreferredHeight.

@Override
public int getPreferredHeight(int width) {
    RadioButton radioButton = (RadioButton) getComponent();
    Button.DataRenderer dataRenderer = radioButton.getDataRenderer();
    int preferredHeight = BUTTON_DIAMETER;
    Object buttonData = radioButton.getButtonData();
    if (buttonData != null) {
        if (width != -1) {
            width = Math.max(width - (BUTTON_DIAMETER + spacing), 0);
        }
        dataRenderer.render(buttonData, radioButton, false);
        preferredHeight = Math.max(preferredHeight, dataRenderer.getPreferredHeight(width));
    }
    return preferredHeight;
}
Also used : RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) RadioButton(org.apache.pivot.wtk.RadioButton) RadialGradientPaint(java.awt.RadialGradientPaint) Paint(java.awt.Paint)

Example 4 with RadioButton

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

the class TabPanes method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    confirmCloseTabPrompt = (Prompt) namespace.get("confirmCloseTabPrompt");
    tabPane = (TabPane) namespace.get("tabPane");
    closeableCheckbox = (Checkbox) namespace.get("closeableCheckbox");
    collapsibleCheckbox = (Checkbox) namespace.get("collapsibleCheckbox");
    horizontalRadioButton = (RadioButton) namespace.get("horizontalRadioButton");
    verticalRadioButton = (RadioButton) namespace.get("verticalRadioButton");
    cornerBoxPane = (BoxPane) namespace.get("cornerBoxPane");
    tabPane.getTabPaneListeners().add(new TabPaneListener() {

        @Override
        public Vote previewRemoveTabs(final TabPane tabPaneArgument, final int index, final int count) {
            Vote vote;
            if (confirmCloseTab) {
                confirmCloseTabPrompt.open(TabPanes.this, new SheetCloseListener() {

                    @Override
                    public void sheetClosed(Sheet sheet) {
                        if (confirmCloseTabPrompt.getResult() && confirmCloseTabPrompt.getSelectedOptionIndex() == 1) {
                            confirmCloseTab = false;
                            int n = tabPaneArgument.getTabs().getLength();
                            if (index < n - 1) {
                                tabPaneArgument.setSelectedIndex(index + 1);
                            } else {
                                tabPaneArgument.setSelectedIndex(index - 1);
                            }
                            tabPaneArgument.getTabs().remove(index, count);
                            confirmCloseTab = true;
                        }
                    }
                });
                vote = Vote.DENY;
            } else {
                vote = Vote.APPROVE;
            }
            return vote;
        }
    });
    ButtonStateListener checkboxStateListener = new ButtonStateListener() {

        @Override
        public void stateChanged(Button button, Button.State previousState) {
            updateTabPane();
        }
    };
    closeableCheckbox.getButtonStateListeners().add(checkboxStateListener);
    collapsibleCheckbox.getButtonStateListeners().add(checkboxStateListener);
    ButtonStateListener radioButtonStateListener = new ButtonStateListener() {

        @Override
        public void stateChanged(Button button, Button.State previousState) {
            if (button.isSelected()) {
                updateTabPane();
            }
        }
    };
    horizontalRadioButton.getButtonStateListeners().add(radioButtonStateListener);
    verticalRadioButton.getButtonStateListeners().add(radioButtonStateListener);
    updateTabPane();
}
Also used : TabPaneListener(org.apache.pivot.wtk.TabPaneListener) TabPane(org.apache.pivot.wtk.TabPane) Vote(org.apache.pivot.util.Vote) RadioButton(org.apache.pivot.wtk.RadioButton) Button(org.apache.pivot.wtk.Button) ButtonStateListener(org.apache.pivot.wtk.ButtonStateListener) SheetCloseListener(org.apache.pivot.wtk.SheetCloseListener) Sheet(org.apache.pivot.wtk.Sheet)

Example 5 with RadioButton

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

the class RadioButtonSkin method keyReleased.

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

Aggregations

RadioButton (org.apache.pivot.wtk.RadioButton)13 Button (org.apache.pivot.wtk.Button)10 Paint (java.awt.Paint)5 RadialGradientPaint (java.awt.RadialGradientPaint)5 ButtonStateListener (org.apache.pivot.wtk.ButtonStateListener)5 LinkButton (org.apache.pivot.wtk.LinkButton)2 BasicStroke (java.awt.BasicStroke)1 Color (java.awt.Color)1 Graphics2D (java.awt.Graphics2D)1 Rectangle2D (java.awt.geom.Rectangle2D)1 URL (java.net.URL)1 Vote (org.apache.pivot.util.Vote)1 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)1 CardPane (org.apache.pivot.wtk.CardPane)1 CardPaneListener (org.apache.pivot.wtk.CardPaneListener)1 Checkbox (org.apache.pivot.wtk.Checkbox)1 Dimensions (org.apache.pivot.wtk.Dimensions)1 ImageView (org.apache.pivot.wtk.ImageView)1 Label (org.apache.pivot.wtk.Label)1 PushButton (org.apache.pivot.wtk.PushButton)1