Search in sources :

Example 1 with Frame

use of org.apache.pivot.wtk.Frame in project pivot by apache.

the class WindowTest method startup.

@Override
public void startup(final Display display, final Map<String, String> properties) {
    window1.setTitle("Window 1");
    window1.setPreferredSize(640, 480);
    window1.setMaximumWidth(640);
    window1.setMaximumHeight(480);
    window1.setMinimumWidth(320);
    window1.setMinimumHeight(240);
    window1.getComponentListeners().add(new ComponentListener() {

        @Override
        public void sizeChanged(final Component component, final int previousWidth, final int previousHeight) {
            window1.align(window1.getDisplay().getBounds(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER);
            window1.getComponentListeners().remove(this);
        }
    });
    display.getStyles().put(Style.backgroundColor, new Color(0, 127, 127));
    window1.setContent(new Label("Hello Bar"));
    window1.open(display);
    ApplicationContext.queueCallback(() -> {
        final Sheet sheet = new Sheet();
        sheet.setPreferredSize(120, 60);
        sheet.open(window1);
        ApplicationContext.queueCallback(() -> {
            Sheet sheet2 = new Sheet();
            sheet2.setPreferredSize(60, 30);
            sheet2.open(sheet);
        });
    });
    Frame window1a = new Frame();
    window1a.setTitle("Window 1 A");
    window1a.setLocation(30, 280);
    window1a.setPreferredSize(160, 120);
    window1a.open(window1);
    Frame window1ai = new Frame();
    window1ai.setTitle("Window 1 A I");
    window1ai.setLocation(150, 300);
    window1ai.setPreferredSize(320, 200);
    window1ai.open(window1a);
    window1ai.getDecorators().update(0, new ReflectionDecorator());
    Frame window1aii = new Frame();
    window1aii.setTitle("Window 1 A II");
    window1aii.setLocation(50, 400);
    window1aii.setPreferredSize(320, 200);
    window1aii.open(window1a);
    Frame window1b = new Frame();
    window1b.setTitle("Window 1 B");
    window1b.setPreferredSize(160, 120);
    window1b.setLocation(260, 60);
    window1b.open(window1);
    Frame window1bi = new Frame();
    window1bi.setTitle("Window 1 B I");
    window1bi.setPreferredSize(180, 60);
    window1bi.setLocation(270, 160);
    window1bi.setContent(new Label("This window is not enabled"));
    // to test even a not enabled window ...
    window1bi.setEnabled(false);
    window1bi.open(window1b);
    Frame window1bii = new Frame();
    window1bii.setTitle("Window 1 B II");
    window1bii.setPreferredSize(160, 60);
    window1bii.setLocation(320, 10);
    window1bii.open(window1b);
    Palette palette1 = new Palette();
    palette1.setTitle("Palette 1bii 1");
    palette1.setPreferredSize(160, 60);
    palette1.setLocation(290, 210);
    palette1.open(window1bii);
    Palette palette2 = new Palette();
    palette2.setTitle("Palette 1bii 2");
    palette2.setPreferredSize(160, 60);
    palette2.setLocation(600, 200);
    palette2.setContent(new Label("This palette is not enabled"));
    // to test even a not enabled palette ...
    palette2.setEnabled(false);
    palette2.open(window1bii);
    dialogOwner.setTitle("Dialog Owner");
    dialogOwner.setPreferredSize(320, 120);
    dialogOwner.open(display);
    // window1bii.requestFocus();
    ApplicationContext.queueCallback(() -> {
        final Dialog dialog = new Dialog();
        dialog.setTitle("Dialog 1");
        dialog.setPreferredSize(280, 100);
        dialog.open(dialogOwner);
        ApplicationContext.queueCallback(() -> {
            Dialog dialog2 = new Dialog();
            dialog2.setTitle("Dialog 2");
            dialog2.setPreferredSize(220, 80);
            dialog2.open(dialog);
        });
    });
}
Also used : ComponentListener(org.apache.pivot.wtk.ComponentListener) Palette(org.apache.pivot.wtk.Palette) Frame(org.apache.pivot.wtk.Frame) Dialog(org.apache.pivot.wtk.Dialog) Color(java.awt.Color) Label(org.apache.pivot.wtk.Label) Component(org.apache.pivot.wtk.Component) Sheet(org.apache.pivot.wtk.Sheet) ReflectionDecorator(org.apache.pivot.wtk.effects.ReflectionDecorator)

Example 2 with Frame

use of org.apache.pivot.wtk.Frame in project pivot by apache.

the class Pivot811 method startup.

@Override
public void startup(final Display displayArgument, Map<String, String> properties) throws Exception {
    this.display = displayArgument;
    Frame listFrame = new Frame();
    listFrame.setTitle("List Frame");
    listFrame.setPreferredSize(400, 300);
    listFrame.setLocation(20, 20);
    listFrame.getStyles().put(Style.padding, Insets.NONE);
    BoxPane boxPane = new BoxPane();
    boxPane.getStyles().put(Style.fill, true);
    boxPane.setOrientation(Orientation.VERTICAL);
    listFrame.setContent(boxPane);
    Label infoLabel = new Label("Double click on a list item to open a detail frame");
    boxPane.add(infoLabel);
    ScrollPane scrollPane = new ScrollPane();
    scrollPane.setHorizontalScrollBarPolicy(ScrollBarPolicy.FILL);
    scrollPane.setVerticalScrollBarPolicy(ScrollBarPolicy.FILL_TO_CAPACITY);
    // workaround for pivot-738,
    scrollPane.setRepaintAllViewport(true);
    // needed only in in some cases
    boxPane.add(scrollPane);
    final ListView listView = new ListView();
    List<String> listData = new ArrayList<>();
    for (int i = 0; i < 50; ++i) {
        listData.add("List Item " + i);
    }
    listView.setListData(listData);
    scrollPane.setView(listView);
    listView.getListViewSelectionListeners().add(new ListViewSelectionListener() {

        @Override
        public void selectedItemChanged(ListView listViewArgument, Object previousSelectedItem) {
            System.out.println("selectedItemChanged : " + listViewArgument.getSelectedItem());
        }
    });
    listView.getComponentMouseButtonListeners().add(new ComponentMouseButtonListener() {

        @Override
        public boolean mouseClick(Component component, Mouse.Button button, int x, int y, int count) {
            System.out.println("mouseClick : " + count);
            if (count == 2) {
                System.out.println("double click, now open a detail frame");
                Frame detailFrame = new Frame();
                detailFrame.setTitle("Detail Frame");
                detailFrame.setPreferredSize(400, 300);
                int selectedIndex = listView.getSelectedIndex();
                detailFrame.setLocation(80 + (selectedIndex * 10), 80 + (selectedIndex * 10));
                detailFrame.getStyles().put(Style.padding, Insets.NONE);
                BoxPane boxPaneLocal = new BoxPane();
                boxPaneLocal.getStyles().put(Style.fill, true);
                boxPaneLocal.setOrientation(Orientation.VERTICAL);
                detailFrame.setContent(boxPaneLocal);
                String selectedItem = listView.getSelectedItem().toString();
                Label label = new Label("Selected Item is \"" + selectedItem + "\"");
                boxPaneLocal.add(label);
                // spacer
                boxPaneLocal.add(new Label(""));
                boxPaneLocal.add(new Label("Click inside the text input to focus it"));
                TextInput textInput = new TextInput();
                textInput.setText("Focusable component");
                // workaround for pivot-811:
                boxPaneLocal.add(textInput);
                // add a focusable element
                // inside the frame
                detailFrame.open(displayArgument);
                // workaround for pivot-811: force the focus on the first
                // focusable element inside the frame
                detailFrame.requestFocus();
            // textInput.requestFocus(); // or use this ...
            }
            return true;
        }
    });
    listFrame.open(displayArgument);
    listView.setSelectedIndex(0);
    listView.requestFocus();
}
Also used : Frame(org.apache.pivot.wtk.Frame) Label(org.apache.pivot.wtk.Label) ArrayList(org.apache.pivot.collections.ArrayList) ListView(org.apache.pivot.wtk.ListView) Mouse(org.apache.pivot.wtk.Mouse) BoxPane(org.apache.pivot.wtk.BoxPane) ScrollPane(org.apache.pivot.wtk.ScrollPane) ComponentMouseButtonListener(org.apache.pivot.wtk.ComponentMouseButtonListener) ListViewSelectionListener(org.apache.pivot.wtk.ListViewSelectionListener) Component(org.apache.pivot.wtk.Component) TextInput(org.apache.pivot.wtk.TextInput)

Example 3 with Frame

use of org.apache.pivot.wtk.Frame in project pivot by apache.

the class WindowFocusTest method startup.

@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
    BoxPane boxPane1 = new BoxPane(Orientation.VERTICAL);
    TextInput textInput1 = new TextInput();
    textInput1.setText("ABCD");
    boxPane1.add(textInput1);
    boxPane1.add(new TextInput());
    boxPane1.add(new TextInput());
    frame1 = new Frame(boxPane1);
    frame1.setPreferredSize(320, 240);
    frame1.open(display);
    BoxPane boxPane2 = new BoxPane(Orientation.VERTICAL);
    TextInput textInput2 = new TextInput();
    textInput2.setText("1234");
    boxPane2.add(textInput2);
    boxPane2.add(new TextInput());
    boxPane2.add(new TextInput());
    frame2 = new Frame(boxPane2);
    frame2.setPreferredSize(320, 240);
    frame2.open(display);
    frame2.requestFocus();
}
Also used : Frame(org.apache.pivot.wtk.Frame) BoxPane(org.apache.pivot.wtk.BoxPane) TextInput(org.apache.pivot.wtk.TextInput)

Example 4 with Frame

use of org.apache.pivot.wtk.Frame in project pivot by apache.

the class BorderTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    frame = new Frame((Component) bxmlSerializer.readObject(getClass().getResource("border_test.bxml")));
    frame.setTitle("Border Test");
    frame.setPreferredSize(480, 360);
    frame.open(display);
}
Also used : Frame(org.apache.pivot.wtk.Frame) Component(org.apache.pivot.wtk.Component) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 5 with Frame

use of org.apache.pivot.wtk.Frame in project pivot by apache.

the class ColorListButtonTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    BoxPane boxPane = (BoxPane) bxmlSerializer.readObject(ColorListButtonTest.class, "color_list_button_test.bxml");
    listButton = (ListButton) bxmlSerializer.getNamespace().get("listButton");
    // test the getListPopup() method
    listButton.getListPopup().getDecorators().add(new ReflectionDecorator());
    frame = new Frame(boxPane);
    frame.setTitle("Color List Button Test");
    frame.setPreferredSize(480, 360);
    frame.open(display);
}
Also used : Frame(org.apache.pivot.wtk.Frame) BoxPane(org.apache.pivot.wtk.BoxPane) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer) ReflectionDecorator(org.apache.pivot.wtk.effects.ReflectionDecorator)

Aggregations

Frame (org.apache.pivot.wtk.Frame)29 Component (org.apache.pivot.wtk.Component)13 BoxPane (org.apache.pivot.wtk.BoxPane)9 Point (org.apache.pivot.wtk.Point)9 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)8 GradientPaint (java.awt.GradientPaint)7 MenuBar (org.apache.pivot.wtk.MenuBar)6 Button (org.apache.pivot.wtk.Button)5 Label (org.apache.pivot.wtk.Label)5 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)4 PushButton (org.apache.pivot.wtk.PushButton)4 Sheet (org.apache.pivot.wtk.Sheet)4 Bounds (org.apache.pivot.wtk.Bounds)3 ListView (org.apache.pivot.wtk.ListView)3 Color (java.awt.Color)2 IOException (java.io.IOException)2 Action (org.apache.pivot.wtk.Action)2 Checkbox (org.apache.pivot.wtk.Checkbox)2 Dimensions (org.apache.pivot.wtk.Dimensions)2 Display (org.apache.pivot.wtk.Display)2