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