Search in sources :

Example 21 with BoxPane

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

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

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

the class LabelAntialiasTest method startup.

@Override
public void startup(Display display, Map<String, String> properties) {
    window = new Window();
    showFontDesktopHints();
    showFontFamilies();
    TablePane content = new TablePane();
    new TablePane.Column(content, 1, true);
    BoxPane topBox = new BoxPane(Orientation.HORIZONTAL);
    topBox.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    topBox.add(new Label("Rotation angle:"));
    rotationAngleSpinner = new Spinner(new NumericSpinnerData(0, 359));
    rotationAngleSpinner.setCircular(true);
    rotationAngleSpinner.setPreferredWidth(40);
    topBox.add(rotationAngleSpinner);
    TablePane.Row topRow = new TablePane.Row(content, -1);
    topRow.add(topBox);
    labelRow = new TablePane.Row(content, 1, true);
    window.setContent(content);
    window.setTitle("Label Antialiasing Test");
    window.setMaximized(true);
    rotationAngleSpinner.getSpinnerSelectionListeners().add(new SpinnerSelectionListener() {

        @Override
        public void selectedItemChanged(Spinner spinner, Object previousSelectedItem) {
            currentRotationAngle = (Integer) spinner.getSelectedItem();
            if (labelRow.getLength() > 0) {
                labelRow.remove(0, labelRow.getLength());
            }
            labelRow.add(buildLabel(currentRotationAngle));
        }
    });
    rotationAngleSpinner.setSelectedItem(45);
    window.open(display);
}
Also used : Window(org.apache.pivot.wtk.Window) Spinner(org.apache.pivot.wtk.Spinner) SpinnerSelectionListener(org.apache.pivot.wtk.SpinnerSelectionListener) Label(org.apache.pivot.wtk.Label) NumericSpinnerData(org.apache.pivot.wtk.content.NumericSpinnerData) BoxPane(org.apache.pivot.wtk.BoxPane) TablePane(org.apache.pivot.wtk.TablePane)

Example 24 with BoxPane

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

the class ColorPaletteTest method createCell.

private static Component createCell(int index) {
    StackPane stackPane = new StackPane();
    Border border = new Border();
    border.getStyles().put(Style.backgroundColor, index);
    stackPane.add(border);
    Label label = new Label();
    label.setText(Integer.toString(index));
    label.getStyles().put(Style.backgroundColor, Color.WHITE);
    label.getStyles().put(Style.padding, 2);
    Color themeColor = border.getStyles().getColor(Style.backgroundColor);
    Label colorLabel = new Label();
    colorLabel.setText(String.format("R:%1$d,G:%2$d,B:%3$d", themeColor.getRed(), themeColor.getGreen(), themeColor.getBlue()));
    colorLabel.getStyles().put(Style.backgroundColor, Color.WHITE);
    colorLabel.getStyles().put(Style.padding, 2);
    BoxPane boxPane = new BoxPane(Orientation.VERTICAL);
    boxPane.getStyles().put(Style.horizontalAlignment, HorizontalAlignment.CENTER);
    boxPane.getStyles().put(Style.verticalAlignment, VerticalAlignment.CENTER);
    boxPane.add(new Border(label));
    boxPane.add(new Border(colorLabel));
    stackPane.add(boxPane);
    return stackPane;
}
Also used : BoxPane(org.apache.pivot.wtk.BoxPane) Color(java.awt.Color) Label(org.apache.pivot.wtk.Label) Border(org.apache.pivot.wtk.Border) StackPane(org.apache.pivot.wtk.StackPane)

Example 25 with BoxPane

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

Aggregations

BoxPane (org.apache.pivot.wtk.BoxPane)38 Component (org.apache.pivot.wtk.Component)18 Label (org.apache.pivot.wtk.Label)15 TextInput (org.apache.pivot.wtk.TextInput)15 Button (org.apache.pivot.wtk.Button)9 Frame (org.apache.pivot.wtk.Frame)9 PushButton (org.apache.pivot.wtk.PushButton)9 Window (org.apache.pivot.wtk.Window)8 ButtonPressListener (org.apache.pivot.wtk.ButtonPressListener)7 ComponentStateListener (org.apache.pivot.wtk.ComponentStateListener)7 FlowPane (org.apache.pivot.wtk.FlowPane)7 IntValidator (org.apache.pivot.wtk.validation.IntValidator)7 Dimensions (org.apache.pivot.wtk.Dimensions)5 Border (org.apache.pivot.wtk.Border)4 TablePane (org.apache.pivot.wtk.TablePane)4 BXMLSerializer (org.apache.pivot.beans.BXMLSerializer)3 ListView (org.apache.pivot.wtk.ListView)3 Sheet (org.apache.pivot.wtk.Sheet)3 Spinner (org.apache.pivot.wtk.Spinner)3 Color (java.awt.Color)2