Search in sources :

Example 51 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.

the class Pivot694 method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    System.out.println("startup: start");
    System.out.println("Test for clearing (selection) in many Components");
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(this.getClass(), "pivot_694.bxml");
    initializeFields(bxmlSerializer);
    window.open(display);
    System.out.println("Note that elements to clear selection, " + " are to improve Pivot on this feature in a next release, so now only some components will support it");
    System.out.println("Note that elements to clear (data) inside, will be emptied" + " only if they have a buttonDataKey/listDataKey/tableDataKey/treeDataKey/spinnerDataKey/xxxDataKey" + " property set at creation time");
    System.out.println("startup: end");
}
Also used : BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 52 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer 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 53 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.

the class NamespaceTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(NamespaceTest.class, "namespace_test.bxml");
    System.out.println((String) JSON.get(bxmlSerializer.getNamespace(), "content.text"));
    System.out.println((String) JSON.get(bxmlSerializer.getNamespace(), "content['text']"));
    window.open(display);
}
Also used : BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 54 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer 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 55 with BXMLSerializer

use of org.apache.pivot.beans.BXMLSerializer in project pivot by apache.

the class SliderTest method startup.

@Override
public void startup(final Display display, final Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = new Window((Component) bxmlSerializer.readObject(getClass().getResource("slider_test.bxml")));
    slider1 = (Slider) bxmlSerializer.getNamespace().get("slider1");
    slider1.getSliderValueListeners().add((slider, previousValue) -> {
        valueLabel1.setText(Integer.toString(slider.getValue()));
        drawPoint(slider.getValue(), slider2.getValue(), slider.getStart(), slider.getEnd(), slider2.getStart(), slider2.getEnd());
    });
    slider2 = (Slider) bxmlSerializer.getNamespace().get("slider2");
    slider2.getSliderValueListeners().add((slider, previousValue) -> {
        valueLabel2.setText(Integer.toString(slider.getValue()));
        drawPoint(slider1.getValue(), slider.getValue(), slider1.getStart(), slider1.getEnd(), slider.getStart(), slider.getEnd());
    });
    valueLabel1 = (Label) bxmlSerializer.getNamespace().get("valueLabel1");
    valueLabel2 = (Label) bxmlSerializer.getNamespace().get("valueLabel2");
    image = (ImageView) bxmlSerializer.getNamespace().get("imageView");
    int width = slider1.getEnd() - slider1.getStart();
    int height = slider2.getEnd() - slider2.getStart();
    picture = new SliderPicture(width, height);
    picture.clear(Color.LIGHT_GRAY);
    drawPoint(slider1.getValue(), slider2.getValue(), slider1.getStart(), slider1.getEnd(), slider2.getStart(), slider2.getEnd());
    image.setImage(picture);
    window.setTitle("Slider Test");
    window.setMaximized(true);
    window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Component(org.apache.pivot.wtk.Component) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Aggregations

BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)86 Component (org.apache.pivot.wtk.Component)24 IOException (java.io.IOException)19 SerializationException (org.apache.pivot.serialization.SerializationException)14 Window (org.apache.pivot.wtk.Window)13 Button (org.apache.pivot.wtk.Button)11 PushButton (org.apache.pivot.wtk.PushButton)11 File (java.io.File)9 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)9 Frame (org.apache.pivot.wtk.Frame)8 TextInput (org.apache.pivot.wtk.TextInput)8 ArrayList (org.apache.pivot.collections.ArrayList)7 List (org.apache.pivot.collections.List)7 Mouse (org.apache.pivot.wtk.Mouse)6 Sequence (org.apache.pivot.collections.Sequence)5 ComponentMouseButtonListener (org.apache.pivot.wtk.ComponentMouseButtonListener)5 ListButton (org.apache.pivot.wtk.ListButton)5 TextInputContentListener (org.apache.pivot.wtk.TextInputContentListener)5 URL (java.net.URL)4 MalformedURLException (java.net.MalformedURLException)3