Search in sources :

Example 31 with Button

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

the class Pivot718 method controlList.

private void controlList(BXMLSerializer bxmlSerializer) {
    listDelButton = (PushButton) bxmlSerializer.getNamespace().get("listDelButton");
    list = (ListView) bxmlSerializer.getNamespace().get("list");
    list.getListViewSelectionListeners().add(new ListViewSelectionListener() {

        @Override
        public void selectedRangeAdded(ListView listView, int rangeStart, int rangeEnd) {
            System.out.println("selectedRangeAdded");
        }

        @Override
        public void selectedRangeRemoved(ListView listView, int rangeStart, int rangeEnd) {
            System.out.println("selectedRangeRemoved");
        }

        @Override
        public void selectedRangesChanged(ListView listView, Sequence<Span> previousSelectedRanges) {
            System.out.println("selectedRangesChanged");
        }

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

        @Override
        public void buttonPressed(Button button) {
            Object x = list.getSelectedItem();
            System.out.println("delete :: " + x);
            // List data = list.getListData();
            @SuppressWarnings("unchecked") List<Object> data = (List<Object>) list.getListData();
            data.remove(x);
        }
    });
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) ListView(org.apache.pivot.wtk.ListView) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) List(org.apache.pivot.collections.List) ListViewSelectionListener(org.apache.pivot.wtk.ListViewSelectionListener) Span(org.apache.pivot.wtk.Span)

Example 32 with Button

use of org.apache.pivot.wtk.Button 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 33 with Button

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

the class PromptTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BoxPane boxPane = new BoxPane();
    boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.BOTTOM);
    helloButton = new PushButton("Say Hello");
    boxPane.add(helloButton);
    helloButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            String text = button.getButtonData().toString();
            if (window.isBlocked()) {
                System.out.println("I'm already saying \"" + text + "\" !");
            } else {
                Prompt.prompt(text, window);
            }
        }
    });
    Border border = new Border(boxPane);
    border.getStyles().put(Style.color, 7);
    border.getStyles().put(Style.padding, 5);
    window = new Window(border);
    window.setMaximized(true);
    window.open(display);
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) Window(org.apache.pivot.wtk.Window) BoxPane(org.apache.pivot.wtk.BoxPane) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button) PushButton(org.apache.pivot.wtk.PushButton) Border(org.apache.pivot.wtk.Border)

Example 34 with Button

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

the class DataBindingTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
    BXMLSerializer bxmlSerializer = new BXMLSerializer();
    window = (Window) bxmlSerializer.readObject(DataBindingTest.class, "data_binding_test.bxml");
    window.open(display);
    context.put("id1", "1");
    context.put("id2", "2");
    context.put("id3", "3");
    window.getContent().load(context);
    final Label textLabel = (Label) (bxmlSerializer.getNamespace().get("bindingDataText"));
    textLabel.setText(JSONSerializer.toString(context));
    Button storeButton = (Button) (bxmlSerializer.getNamespace().get("storeButton"));
    storeButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            window.getContent().store(context);
            try {
                textLabel.setText(JSONSerializer.toString(context));
                textLabel.getStyles().put(Style.color, getNextColor());
            } catch (Exception ex) {
                throw new RuntimeException(ex);
            }
        }
    });
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) Button(org.apache.pivot.wtk.Button) Label(org.apache.pivot.wtk.Label) BXMLSerializer(org.apache.pivot.beans.BXMLSerializer)

Example 35 with Button

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

the class TestDialog method initialize.

@Override
public void initialize(Map<String, Object> namespace, URL location, Resources resources) {
    System.out.println("TestDialog initialize(...)");
    this.okButton.getButtonPressListeners().add(new ButtonPressListener() {

        @Override
        public void buttonPressed(Button button) {
            TestDialog.this.close(true);
        }
    });
}
Also used : ButtonPressListener(org.apache.pivot.wtk.ButtonPressListener) PushButton(org.apache.pivot.wtk.PushButton) Button(org.apache.pivot.wtk.Button)

Aggregations

Button (org.apache.pivot.wtk.Button)61 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)43 PushButton (org.apache.pivot.wtk.PushButton)40 Component (org.apache.pivot.wtk.Component)15 ListButton (org.apache.pivot.wtk.ListButton)12 IOException (java.io.IOException)11 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)11 File (java.io.File)9 BoxPane (org.apache.pivot.wtk.BoxPane)9 Sheet (org.apache.pivot.wtk.Sheet)9 ListView (org.apache.pivot.wtk.ListView)8 SheetCloseListener (org.apache.pivot.wtk.SheetCloseListener)8 ButtonStateListener (org.apache.pivot.wtk.ButtonStateListener)7 List (org.apache.pivot.collections.List)6 Sequence (org.apache.pivot.collections.Sequence)6 FileBrowserSheet (org.apache.pivot.wtk.FileBrowserSheet)6 Point (org.apache.pivot.wtk.Point)6 Span (org.apache.pivot.wtk.Span)6 GradientPaint (java.awt.GradientPaint)5 SerializationException (org.apache.pivot.serialization.SerializationException)5