Search in sources :

Example 21 with Frame

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

the class FormTest 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("form_test.bxml")));
    frame.setTitle("Form 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 22 with Frame

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

the class FileBrowserWithCharsetTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BoxPane windowContent = new BoxPane();
    windowContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    final Checkbox showHiddenCheckbox = new Checkbox("Show hidden files");
    windowContent.add(showHiddenCheckbox);
    PushButton button = new PushButton("Open File Browser");
    button.getStyles().put(Style.padding, "[2, 4, 2, 4]");
    button.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button buttonArgument) {
            final Window window = Window.getActiveWindow();
            final FileBrowserWithCharsetTest fileBrowserSheet = new FileBrowserWithCharsetTest(FileBrowserSheet.Mode.OPEN);
            fileBrowserSheet.getStyles().put(Style.showHiddenFiles, showHiddenCheckbox.isSelected());
            fileBrowserSheet.open(window, new SheetCloseListener() {

                @Override
                public void sheetClosed(Sheet sheet) {
                    if (sheet.getResult()) {
                        Sequence<File> selectedFiles = fileBrowserSheet.getSelectedFiles();
                        ListView listView = new ListView();
                        listView.setListData(new ArrayList<>(selectedFiles));
                        listView.setSelectMode(ListView.SelectMode.NONE);
                        listView.getStyles().put(Style.backgroundColor, null);
                        Alert.alert(MessageType.INFO, "You selected (charset " + fileBrowserSheet.getCharsetName() + "):", listView, window);
                    } else {
                        Alert.alert(MessageType.INFO, "You didn't select anything.", window);
                    }
                }
            });
        }
    });
    windowContent.add(button);
    frame = new Frame(windowContent);
    frame.setMaximized(true);
    frame.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Frame(org.apache.pivot.wtk.Frame) SheetCloseListener(org.apache.pivot.wtk.SheetCloseListener) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) ListView(org.apache.pivot.wtk.ListView) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) ListButton(org.apache.pivot.wtk.ListButton) Checkbox(org.apache.pivot.wtk.Checkbox) PushButton(org.apache.pivot.wtk.PushButton) Sheet(org.apache.pivot.wtk.Sheet) FileBrowserSheet(org.apache.pivot.wtk.FileBrowserSheet) File(java.io.File)

Example 23 with Frame

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

the class HyperlinkButtonTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    frame = new Frame();
    frame.setTitle("Hyperlink Button Test");
    frame.setPreferredSize(480, 360);
    HyperlinkButton button1 = new HyperlinkButton("http://pivot.apache.org");
    HyperlinkButton button2 = new HyperlinkButton("Apache website", "http://apache.org");
    TextPane textPane = new TextPane();
    Document document = new Document();
    TextNode text1 = new TextNode("Link to the Apache Pivot site: ");
    TextNode text2 = new TextNode("Main Apache Software Foundation website: ");
    ComponentNode compNode1 = new ComponentNode(button1);
    ComponentNode compNode2 = new ComponentNode(button2);
    Paragraph para1 = new Paragraph();
    para1.add(text1);
    document.add(para1);
    document.add(compNode1);
    Paragraph para2 = new Paragraph();
    para2.add(text2);
    document.add(para2);
    document.add(compNode2);
    ImageNode image1 = new ImageNode("/org/apache/pivot/tests/house.png");
    document.add(image1);
    textPane.setDocument(document);
    frame.setContent(textPane);
    frame.open(display);
}
Also used : Frame(org.apache.pivot.wtk.Frame) HyperlinkButton(org.apache.pivot.wtk.HyperlinkButton) TextPane(org.apache.pivot.wtk.TextPane) TextNode(org.apache.pivot.wtk.text.TextNode) ImageNode(org.apache.pivot.wtk.text.ImageNode) Document(org.apache.pivot.wtk.text.Document) ComponentNode(org.apache.pivot.wtk.text.ComponentNode) Paragraph(org.apache.pivot.wtk.text.Paragraph)

Example 24 with Frame

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

the class TagDecoratorTest method startup.

@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
    frame = new Frame();
    frame.setTitle("Tag Decorator Test");
    frame.setPreferredSize(480, 360);
    Image tag = Image.load(getClass().getResource("go-home.png"));
    frame.getDecorators().add(new TagDecorator(tag, HorizontalAlignment.RIGHT, VerticalAlignment.TOP, 10, -10));
    frame.open(display);
}
Also used : Frame(org.apache.pivot.wtk.Frame) TagDecorator(org.apache.pivot.wtk.effects.TagDecorator) Image(org.apache.pivot.wtk.media.Image)

Example 25 with Frame

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

the class VFSBrowserTest method startup.

@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
    BoxPane windowContent = new BoxPane();
    windowContent.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    final Checkbox showHiddenCheckbox = new Checkbox("Show hidden files");
    windowContent.add(showHiddenCheckbox);
    PushButton button = new PushButton("Open File Browser");
    button.getStyles().put(Style.padding, "[2, 4, 2, 4]");
    button.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(final Button buttonArgument) {
            try {
                final VFSBrowserSheet vfsBrowserSheet = new VFSBrowserSheet(VFSBrowserSheet.Mode.OPEN);
                vfsBrowserSheet.getStyles().put(Style.showHiddenFiles, showHiddenCheckbox.isSelected());
                vfsBrowserSheet.open(frame, new SheetCloseListener() {

                    @Override
                    public void sheetClosed(final Sheet sheet) {
                        if (sheet.getResult()) {
                            Sequence<FileObject> selectedFiles = vfsBrowserSheet.getSelectedFiles();
                            ListView listView = new ListView();
                            listView.setListData(new ArrayList<>(selectedFiles));
                            listView.setSelectMode(ListView.SelectMode.NONE);
                            listView.getStyles().put(Style.backgroundColor, null);
                            Alert.alert(MessageType.INFO, "You selected:", listView, frame);
                        } else {
                            Alert.alert(MessageType.INFO, "You didn't select anything.", frame);
                        }
                    }
                });
            } catch (FileSystemException fse) {
                Alert.alert(MessageType.ERROR, String.format("File System Exception: %1$s", fse.getMessage()), frame);
            }
        }
    });
    windowContent.add(button);
    frame = new Frame(windowContent);
    frame.setMaximized(true);
    frame.open(display);
}
Also used : Frame(org.apache.pivot.wtk.Frame) SheetCloseListener(org.apache.pivot.wtk.SheetCloseListener) ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) FileSystemException(org.apache.commons.vfs2.FileSystemException) VFSBrowserSheet(org.apache.pivot.wtk.VFSBrowserSheet) ListView(org.apache.pivot.wtk.ListView) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) Checkbox(org.apache.pivot.wtk.Checkbox) FileObject(org.apache.commons.vfs2.FileObject) PushButton(org.apache.pivot.wtk.PushButton) Sheet(org.apache.pivot.wtk.Sheet) VFSBrowserSheet(org.apache.pivot.wtk.VFSBrowserSheet)

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