Search in sources :

Example 16 with BoxPane

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));
}
Also used : Frame(org.apache.pivot.wtk.Frame) CardPane(org.apache.pivot.wtk.CardPane) Vote(org.apache.pivot.util.Vote) BoxPane(org.apache.pivot.wtk.BoxPane) ButtonGroup(org.apache.pivot.wtk.ButtonGroup) Button(org.apache.pivot.wtk.Button) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer) ButtonGroupListener(org.apache.pivot.wtk.ButtonGroupListener) CardPaneListener(org.apache.pivot.wtk.CardPaneListener)

Example 17 with BoxPane

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);
}
Also used : Frame(org.apache.pivot.wtk.Frame) Insets(org.apache.pivot.wtk.Insets) BoxPane(org.apache.pivot.wtk.BoxPane) Label(org.apache.pivot.wtk.Label)

Example 18 with BoxPane

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);
}
Also used : BoxPane(org.apache.pivot.wtk.BoxPane) ButtonData(org.apache.pivot.wtk.content.ButtonData) Component(org.apache.pivot.wtk.Component) Image(org.apache.pivot.wtk.media.Image) ComponentMouseListener(org.apache.pivot.wtk.ComponentMouseListener) LinkButton(org.apache.pivot.wtk.LinkButton)

Example 19 with BoxPane

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);
}
Also used : Window(org.apache.pivot.wtk.Window) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton)

Example 20 with BoxPane

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);
}
Also used : Frame(org.apache.pivot.wtk.Frame) Action(org.apache.pivot.wtk.Action) MenuHandler(org.apache.pivot.wtk.MenuHandler) BoxPane(org.apache.pivot.wtk.BoxPane) MenuBar(org.apache.pivot.wtk.MenuBar) TextInput(org.apache.pivot.wtk.TextInput) Component(org.apache.pivot.wtk.Component) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Aggregations

BoxPane (org.apache.pivot.wtk.BoxPane)38 Component (org.apache.pivot.wtk.Component)18 Label (org.apache.pivot.wtk.Label)15 TextInput (org.apache.pivot.wtk.TextInput)15 Button (org.apache.pivot.wtk.Button)9 Frame (org.apache.pivot.wtk.Frame)9 PushButton (org.apache.pivot.wtk.PushButton)9 Window (org.apache.pivot.wtk.Window)8 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)7 ComponentStateListener (org.apache.pivot.wtk.ComponentStateListener)7 FlowPane (org.apache.pivot.wtk.FlowPane)7 IntValidator (org.apache.pivot.wtk.validation.IntValidator)7 Dimensions (org.apache.pivot.wtk.Dimensions)5 Border (org.apache.pivot.wtk.Border)4 TablePane (org.apache.pivot.wtk.TablePane)4 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)3 ListView (org.apache.pivot.wtk.ListView)3 Sheet (org.apache.pivot.wtk.Sheet)3 Spinner (org.apache.pivot.wtk.Spinner)3 Color (java.awt.Color)2