use of org.apache.pivot.wtk.BoxPane in project pivot by apache.
the class CardPaneTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
frame = new Frame(new BoxPane());
frame.getStyles().put(Style.padding, 0);
frame.setTitle("Component Pane Test");
frame.setPreferredSize(800, 600);
frame.setLocation(20, 20);
BXMLSerializer bxmlSerializer = new BXMLSerializer();
sheet = (Sheet) bxmlSerializer.readObject(CardPaneTest.class, "card_pane_test.bxml");
cardPane = (CardPane) bxmlSerializer.getNamespace().get("cardPane");
sizeGroup = (ButtonGroup) bxmlSerializer.getNamespace().get("sizeGroup");
sizeGroup.getButtonGroupListeners().add(new ButtonGroupListener() {
@Override
public void selectionChanged(ButtonGroup buttonGroup, Button previousSelection) {
final Button selection = buttonGroup.getSelection();
int selectedIndex = selection == null ? -1 : selection.getParent().indexOf(selection);
cardPane.getCardPaneListeners().add(new CardPaneListener() {
@Override
public Vote previewSelectedIndexChange(CardPane cardPaneArgument, int selectedIndexArgument) {
if (selection != null) {
selection.getParent().setEnabled(false);
}
return Vote.APPROVE;
}
@Override
public void selectedIndexChangeVetoed(CardPane cardPaneArgument, Vote reason) {
if (selection != null && reason == Vote.DENY) {
selection.getParent().setEnabled(true);
}
}
@Override
public void selectedIndexChanged(CardPane cardPaneArgument, int previousSelectedIndex) {
if (selection != null) {
selection.getParent().setEnabled(true);
}
}
});
cardPane.setSelectedIndex(selectedIndex);
}
});
frame.open(display);
ApplicationContext.queueCallback(() -> sheet.open(frame));
}
use of org.apache.pivot.wtk.BoxPane in project pivot by apache.
the class LabelTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
frame = new Frame();
frame.setTitle("Label Test");
String line1 = "There's a lady who's sure all that glitters is gold, and " + "she's buying a stairway to heaven. When she gets there she knows, " + "if the stores are closed, with a word she can get what she came " + "for. Woe oh oh oh oh oh and she's buying a stairway to heaven. " + "There's a sign on the wall, but she wants to be sure, and you know " + "sometimes words have two meanings. In a tree by the brook there's " + "a songbird who sings, sometimes all of our thoughts are misgiven. " + "Woe oh oh oh oh oh and she's buying a stairway to heaven.";
String line2 = "And as we wind on down the road, our shadows taller than " + "our souls, there walks a lady we all know who shines white light " + "and wants to show how everything still turns to gold; and if you " + "listen very hard the tune will come to you at last when all are " + "one and one is all:\nto be a rock and not to roll.";
BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
Label label1 = new Label(line1);
label1.getStyles().put(Style.wrapText, true);
label1.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.LEFT);
boxPane.add(label1);
// strikethrough
Label label2 = new Label(line2);
label2.getStyles().put(Style.wrapText, true);
label2.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.LEFT);
label2.getStyles().put(Style.textDecoration, TextDecoration.STRIKETHROUGH);
boxPane.add(label2);
// disabled
Label label3 = new Label(line2);
label3.getStyles().put(Style.wrapText, true);
label3.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.LEFT);
label3.setEnabled(false);
boxPane.add(label3);
boxPane.getStyles().put(Style.fill, true);
boxPane.getStyles().put(Style.padding, new Insets(10));
frame.setContent(boxPane);
frame.setPreferredSize(340, 400);
frame.open(display);
}
use of org.apache.pivot.wtk.BoxPane in project pivot by apache.
the class LinkButtonTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane boxPane = new BoxPane();
boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
boxPane.getStyles().put(Style.spacing, 8);
boxPane.getComponentMouseListeners().add(new ComponentMouseListener() {
@Override
public boolean mouseMove(Component component, int x, int y) {
System.out.println("BOX PANE " + x + ", " + y);
return false;
}
@Override
public void mouseOver(Component component) {
// empty block
}
@Override
public void mouseOut(Component component) {
// empty block
}
});
Image image = Image.load(getClass().getResource("go-home.png"));
LinkButton linkButton = null;
linkButton = new LinkButton("ABCDE");
boxPane.add(linkButton);
linkButton.getComponentMouseListeners().add(new ComponentMouseListener() {
@Override
public boolean mouseMove(Component component, int x, int y) {
return true;
}
@Override
public void mouseOver(Component component) {
// empty block
}
@Override
public void mouseOut(Component component) {
// empty block
}
});
linkButton = new LinkButton(image);
boxPane.add(linkButton);
linkButton = new LinkButton(new ButtonData(image, "12345"));
boxPane.add(linkButton);
window.setContent(boxPane);
window.open(display);
}
use of org.apache.pivot.wtk.BoxPane in project pivot by apache.
the class PushButtonTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
window = new Window();
BoxPane boxPane = new BoxPane();
boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.RIGHT);
PushButton uploadButton = new PushButton("Upload");
uploadButton.getStyles().put(Style.minimumAspectRatio, 3.0f);
boxPane.add(uploadButton);
window.setContent(boxPane);
window.setMaximized(true);
window.open(display);
}
use of org.apache.pivot.wtk.BoxPane in project pivot by apache.
the class MenuBarTest method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
boxPane.add(new TextInput());
boxPane.add(new TextInput());
boxPane.add(new TextInput());
frame1 = new Frame(boxPane);
frame1.setLocation(50, 50);
frame1.setPreferredSize(320, 240);
frame1.setTitle("Frame 1");
// put this before loading the related bxml, or an
// IllegalArgumentException will be thrown
Action.getNamedActions().put("about", new Action() {
@Override
public void perform(Component source) {
String msg = "Hello from Pivot-" + ApplicationContext.getPivotVersion().toString() + ", running from Java " + // + ApplicationContext.getJVMVersion().toString()
System.getProperty("java.version");
// frame2);
Alert.alert(msg, frame2.getRootOwner());
System.out.println("Help triggered");
}
});
BXMLSerializer bxmlSerializer = new BXMLSerializer();
frame2 = (Frame) bxmlSerializer.readObject(MenuBarTest.class, "menu_bar_test.bxml");
frame2.setTitle("Frame 2, from bxml");
bxmlSerializer.bind(this, MenuBarTest.class);
MenuHandler menuHandler = new MenuHandler() {
@Override
public void configureMenuBar(Component component, MenuBar menuBar) {
System.out.println("Configure menu bar: got focus on " + component.getName());
}
@Override
public void cleanupMenuBar(Component component, MenuBar menuBar) {
System.out.println("Clean up menu bar: lost focus on " + component.getName());
}
};
textInput1.setMenuHandler(menuHandler);
textInput2.setMenuHandler(menuHandler);
textInput3.setMenuHandler(menuHandler);
frame1.open(display);
frame2.open(display);
}
Aggregations