Search in sources :

Example 16 with Frame

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

the class Pivot714 method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    frame = new Frame();
    frame.setTitle("Pivot714");
    result = (Dialog) getWindow(frame.getRootOwner());
    frame.setPreferredSize(640, 480);
    frame.open(display);
    result.open(owner, dcl);
}
Also used : Frame(org.apache.pivot.wtk.Frame)

Example 17 with Frame

use of org.apache.pivot.wtk.Frame 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)

Example 18 with Frame

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

the class PanoramaTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    frame1 = new Frame();
    frame1.setTitle("Panorama Test 1");
    Panorama panorama = new Panorama();
    frame1.setContent(panorama);
    frame1.setPreferredSize(240, 320);
    ImageView imageView = new ImageView();
    imageView.setImage(getClass().getResource("IMG_0767_2.jpg"));
    panorama.setView(imageView);
    frame1.open(display);
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    frame2 = new Frame((Component) bxmlSerializer.readObject(getClass().getResource("panorama_test.bxml")));
    frame2.setTitle("Panorama Test 2");
    frame2.setPreferredSize(480, 360);
    frame2.open(display);
}
Also used : Frame(org.apache.pivot.wtk.Frame) Panorama(org.apache.pivot.wtk.Panorama) ImageView(org.apache.pivot.wtk.ImageView) Component(org.apache.pivot.wtk.Component) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 19 with Frame

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

the class SheetTest method startup.

@SuppressWarnings("unused")
@Override
public void startup(final Display display, Map<String, String> properties) throws Exception {
    Picture picture = (Picture) Image.load(getClass().getResource("IMG_0767_2.jpg"));
    picture.resample(120);
    BoxPane windowContent = new BoxPane();
    PushButton button = new PushButton(picture);
    button.getStyles().put(Style.toolbar, true);
    windowContent.add(button);
    frame = new Frame(windowContent);
    frame.setPreferredSize(480, 360);
    frame.getStyles().put(Style.padding, 0);
    frame.open(display);
    final TablePane tablePane = new TablePane();
    tablePane.setPreferredSize(320, 240);
    new TablePane.Column(tablePane, 1, true);
    TablePane.Row row0 = new TablePane.Row(tablePane, 1, true);
    TablePane.Row row1 = new TablePane.Row(tablePane, -1);
    final Label sheetContent = new Label("Sheet Content");
    sheetContent.getStyles().put(Style.wrapText, true);
    sheetContent.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    sheetContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    row0.add(sheetContent);
    Label promptBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
    promptBody.getStyles().put(Style.wrapText, true);
    final Prompt prompt = new Prompt(MessageType.INFO, "Prompt", new ArrayList<>("OK"), promptBody);
    prompt.setTitle("Prompt");
    prompt.getStyles().put(Style.resizable, true);
    prompt.getComponentMouseListeners().add(new ComponentMouseListener() {

        @Override
        public void mouseOver(Component component) {
            System.out.println("Mouse Over");
        }

        @Override
        public void mouseOut(Component component) {
            System.out.println("Mouse out");
        }
    });
    Label alertBody = new Label("Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an AS IS BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.");
    alertBody.getStyles().put(Style.wrapText, true);
    final Alert alert = new Alert(MessageType.INFO, "Alert", new ArrayList<>("OK"), alertBody);
    alert.setTitle("Alert");
    BoxPane boxPane = new BoxPane();
    row1.add(boxPane);
    boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.RIGHT);
    final PushButton closeButton = new PushButton("Close");
    closeButton.getStyles().put(Style.minimumAspectRatio, 3);
    boxPane.add(closeButton);
    sheet = new Sheet(tablePane);
    closeButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button buttonArgument) {
            buttonArgument.getWindow().close();
        }
    });
    button.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button buttonArgument) {
            prompt.open(frame);
            Display displayLocal = DesktopApplicationContext.createDisplay(640, 480, 100, 100, true, true, false, buttonArgument.getDisplay().getHostWindow(), null);
            Window window = new Window();
            window.setTitle("New Secondary Window");
            window.setMaximized(true);
            window.setContent(new Label("I am a secondary window!"));
            window.open(displayLocal);
        }
    });
    sheet.getWindowStateListeners().add(new WindowStateListener() {

        @Override
        public void windowOpened(Window window) {
            closeButton.requestFocus();
        }
    });
    DesktopApplicationContext.sizeHostToFit(frame);
}
Also used : Window(org.apache.pivot.wtk.Window) Frame(org.apache.pivot.wtk.Frame) WindowStateListener(org.apache.pivot.wtk.WindowStateListener) Label(org.apache.pivot.wtk.Label) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) Picture(org.apache.pivot.wtk.media.Picture) Prompt(org.apache.pivot.wtk.Prompt) Alert(org.apache.pivot.wtk.Alert) PushButton(org.apache.pivot.wtk.PushButton) Component(org.apache.pivot.wtk.Component) ComponentMouseListener(org.apache.pivot.wtk.ComponentMouseListener) Sheet(org.apache.pivot.wtk.Sheet) TablePane(org.apache.pivot.wtk.TablePane) Display(org.apache.pivot.wtk.Display)

Example 20 with Frame

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

the class NativeDragDropTest method startup.

@Override
public void startup(final Display display, Map<String, String> properties) throws Exception {
    final Label label = new Label("http://pivot.apache.org/");
    label.getStyles().put(Style.font, new Font("Arial", Font.PLAIN, 24));
    label.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    label.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    label.setDragSource(new DragSource() {

        private LocalManifest content = null;

        @Override
        public boolean beginDrag(Component component, int x, int y) {
            content = new LocalManifest();
            content.putText(label.getText());
            return true;
        }

        @Override
        public void endDrag(Component component, DropAction dropAction) {
            content = null;
        }

        @Override
        public boolean isNative() {
            return true;
        }

        @Override
        public LocalManifest getContent() {
            return content;
        }

        @Override
        public Visual getRepresentation() {
            return null;
        }

        @Override
        public Point getOffset() {
            return null;
        }

        @Override
        public int getSupportedDropActions() {
            return DropAction.COPY.getMask();
        }
    });
    label.setDropTarget(new DropTarget() {

        @Override
        public DropAction dragEnter(Component component, Manifest dragContent, int supportedDropActions, DropAction userDropAction) {
            DropAction dropAction = null;
            if (dragContent.containsText()) {
                frame.getStyles().put(Style.backgroundColor, "#ffcccc");
                dropAction = DropAction.COPY;
            }
            return dropAction;
        }

        @Override
        public void dragExit(Component component) {
            frame.getStyles().put(Style.backgroundColor, "#ffffff");
        }

        @Override
        public DropAction dragMove(Component component, Manifest dragContent, int supportedDropActions, int x, int y, DropAction userDropAction) {
            return (dragContent.containsText() ? DropAction.COPY : null);
        }

        @Override
        public DropAction userDropActionChange(Component component, Manifest dragContent, int supportedDropActions, int x, int y, DropAction userDropAction) {
            return (dragContent.containsText() ? DropAction.COPY : null);
        }

        @Override
        public DropAction drop(Component component, Manifest dragContent, int supportedDropActions, int x, int y, DropAction userDropAction) {
            DropAction dropAction = null;
            if (dragContent.containsText()) {
                Label labelLocal = (Label) component;
                try {
                    labelLocal.setText(dragContent.getText());
                } catch (IOException exception) {
                    System.err.println(exception);
                }
            }
            dragExit(component);
            return dropAction;
        }
    });
    frame = new Frame(label);
    frame.open(display);
}
Also used : Frame(org.apache.pivot.wtk.Frame) Label(org.apache.pivot.wtk.Label) DropAction(org.apache.pivot.wtk.DropAction) DragSource(org.apache.pivot.wtk.DragSource) Point(org.apache.pivot.wtk.Point) IOException(java.io.IOException) LocalManifest(org.apache.pivot.wtk.LocalManifest) Manifest(org.apache.pivot.wtk.Manifest) Font(java.awt.Font) LocalManifest(org.apache.pivot.wtk.LocalManifest) Point(org.apache.pivot.wtk.Point) DropTarget(org.apache.pivot.wtk.DropTarget) Component(org.apache.pivot.wtk.Component) Visual(org.apache.pivot.wtk.Visual)

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