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);
}
}
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();
}
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;
}
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();
}
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;
}
Aggregations