use of org.apache.pivot.wtk.Button in project pivot by apache.
the class TerraCheckboxSkin method paint.
@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 = ColorUtilities.setTransparencyInColor(buttonSelectionColor, ALPHA);
graphics.setColor(focusColor);
graphics.fillRect(0, 0, CHECKBOX_SIZE, CHECKBOX_SIZE);
} else {
BasicStroke dashStroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 0.0f, 2.0f }, 0.0f);
graphics.setStroke(dashStroke);
graphics.setColor(buttonBorderColor);
GraphicsUtilities.setAntialiasingOn(graphics);
Rectangle2D focusRectangle = new Rectangle2D.Double(CHECKBOX_SIZE + 1, 0.5, dataRenderer.getWidth() + spacing * 2 - 2, dataRenderer.getHeight() - 1);
graphics.draw(focusRectangle);
}
}
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class RadioButtons method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
selectButton = (PushButton) namespace.get("selectButton");
// Get a reference to the button group
final ButtonGroup numbersGroup = (ButtonGroup) namespace.get("numbers");
// Add a button press listener
selectButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
String message = "You selected \"" + numbersGroup.getSelection().getButtonData() + "\".";
Alert.alert(MessageType.INFO, message, RadioButtons.this);
}
});
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class DataBinding method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
form = (Form) namespace.get("form");
loadJavaButton = (PushButton) namespace.get("loadJavaButton");
loadJSONButton = (PushButton) namespace.get("loadJSONButton");
clearButton = (PushButton) namespace.get("clearButton");
sourceLabel = (Label) namespace.get("sourceLabel");
loadJavaButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
form.load(new BeanAdapter(CONTACT));
sourceLabel.setText("Java");
}
});
loadJSONButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
JSONSerializer serializer = new JSONSerializer();
try (InputStream inputStream = getClass().getResourceAsStream("contact.json")) {
form.load(serializer.readObject(inputStream));
sourceLabel.setText("JSON");
} catch (Exception exception) {
System.err.println(exception);
}
button.setEnabled(true);
}
});
clearButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
form.clear();
sourceLabel.setText("");
}
});
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class BXMLExplorerWindow method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
// hide until we support editing and saving BXML files
if (!BXMLExplorer.ENABLE_EDITING) {
paletteTabPane.getTabs().remove(paletteTreeViewScrollPane);
splitPane.setSplitRatio(0);
fileMenuSection.remove(fileNewMenuItem);
}
fileBrowserSheet.setDisabledFileFilter(new Filter<File>() {
@Override
public boolean include(File item) {
return !(item.isDirectory() || item.getName().endsWith(".bxml"));
}
});
closeButton.setEnabled(false);
closeButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
int x = tabPane.getSelectedIndex();
tabPane.getTabs().remove(x, 1);
if (tabPane.getTabs().getLength() > 0) {
x = Math.max(x - 1, 0);
tabPane.setSelectedIndex(x);
}
closeButton.setEnabled(tabPane.getTabs().getLength() > 0);
}
});
}
use of org.apache.pivot.wtk.Button in project pivot by apache.
the class ExpenseSheet method initialize.
@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resource) {
this.resources = resource;
dateSpinner = (Spinner) namespace.get("dateSpinner");
typeListButton = (ListButton) namespace.get("typeListButton");
amountTextInput = (TextInput) namespace.get("amountTextInput");
cancelButton = (PushButton) namespace.get("cancelButton");
okButton = (PushButton) namespace.get("okButton");
cancelButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
close(false);
}
});
okButton.getButtonPressListeners().add(new ButtonPressListener() {
@Override
public void buttonPressed(Button button) {
close(true);
}
});
}
Aggregations