Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Display


        // Mouse handler to enable users to quickly close the sheet
        final ContainerMouseListener displayMouseHandler = new ContainerMouseListener.Adapter() {
            @Override
            public boolean mouseDown(Container container, Mouse.Button button, int x, int y) {
                Display display = (Display) container;
                Component component = display.getComponentAt(x, y);

                // Close the sheet by clicking away from it.
                // This allows resizing etc to work without requiring
                // a close button or similar on the sheet.
                boolean consumed = (component != sheet);
                if (consumed) {
                    sheet.close();
                }
                return consumed;
            }
        };

        // Add/remove the mouse handler based on the Sheet's state
        sheet.getWindowStateListeners().add(new WindowStateListener.Adapter() {
            @Override
            public void windowOpened(Window window) {
                window.getDisplay().getContainerMouseListeners().add(displayMouseHandler);
            }

            @Override
            public void windowClosed(Window window, Display display, Window owner) {
                display.getContainerMouseListeners().remove(displayMouseHandler);
            }
        });
    }
View Full Code Here


                Point location = comp.getDisplay().getMouseLocation();
                x = location.x;
                y = location.y;

                // Ensure that the tooltip stays on screen
                Display display = comp.getDisplay();
                int tooltipHeight = tooltip.getPreferredHeight();
                if (y + tooltipHeight > display.getHeight()) {
                    y -= tooltipHeight;
                }

                int tooltipXOffset = 16;
                int padding = 15;

                toolTipTextArea.setMaximumWidth(display.getWidth() - ( x + tooltipXOffset + padding) );
                tooltip.setLocation(x + tooltipXOffset, y);
                tooltip.open(comp.getWindow());
            }
        });
View Full Code Here

    @Override
    public void windowOpened(Window window) {
        super.windowOpened(window);

        Display display = window.getDisplay();
        display.getContainerMouseListeners().add(displayMouseListener);

        MenuPopup menuPopup = (MenuPopup)window;
        Menu menu = menuPopup.getMenu();
        if (menu != null) {
            Menu.Item activeItem = menu.getActiveItem();
View Full Code Here

    MenuPopupStateListener {
    private class RepositionCallback implements Runnable {
        @Override
        public void run() {
            MenuPopup menuPopup = (MenuPopup)getComponent();
            Display display = menuPopup.getDisplay();

            Point location = menuPopup.getLocation();
            Dimensions size = menuPopup.getSize();

            int x = location.x;
            if (x + size.width > display.getWidth()) {
                x -= size.width;
            }

            int y = location.y;
            if (y + size.height > display.getHeight()) {
                y-= size.height;
            }

            menuPopup.setLocation(x, y);
        }
View Full Code Here

            Label tooltipLabel = new Label(tooltipText);
            boolean tooltipWrapText = component.getTooltipWrapText();
            tooltipLabel.getStyles().put("wrapText", tooltipWrapText);
            Tooltip tooltip = new Tooltip(tooltipLabel);

            Display display = component.getDisplay();
            Point location = component.mapPointToAncestor(display, x, y);

            // Ensure that the tooltip stays on screen
            int tooltipX = location.x + 16;
            int tooltipY = location.y;

            int tooltipWidth = tooltip.getPreferredWidth();
            int tooltipHeight = tooltip.getPreferredHeight();
            if (tooltipX + tooltipWidth > display.getWidth()) {
                // Try to just fit it inside the display if
                // there would be room to shift it above the
                // cursor, otherwise move it to the left of
                // the cursor
                if (tooltipY > tooltipHeight) {
                    tooltipX = display.getWidth() - tooltipWidth;
                } else {
                    tooltipX = location.x - tooltipWidth - 16;
                }
                if (tooltipX < 0) {
                    tooltipX = 0;
                }
                // Adjust the y location if the tip ends up
                // being behind the mouse cursor because of
                // these x adjustments
                if (tooltipX < location.x && tooltipX + tooltipWidth > location.x) {
                    tooltipY -= tooltipHeight;
                    if (tooltipY < 0) {
                        tooltipY = 0;
                    }
                }
            }
            if (tooltipY + tooltipHeight > display.getHeight()) {
                tooltipY -= tooltipHeight;
            }

            tooltip.setLocation(tooltipX, tooltipY);
            tooltip.open(component.getWindow());
View Full Code Here

            Color color = colorChooser.getSelectedColor();
            colorChooserButton.setSelectedColor(color);
        } else {
                // Determine the popup's location and preferred size, relative
                // to the button
                Display display = colorChooserButton.getDisplay();

                if (display != null) {
                    int width = getWidth();
                    int height = getHeight();

                    // Ensure that the popup remains within the bounds of the display
                    Point buttonLocation = colorChooserButton.mapPointToAncestor(display, 0, 0);

                    Dimensions displaySize = display.getSize();

                    colorChooserPopup.setPreferredSize(-1, -1);
                    Dimensions popupSize = colorChooserPopup.getPreferredSize();
                    int popupWidth = Math.max(popupSize.width,
                        colorChooserButton.getWidth() - TRIGGER_WIDTH - 1);
View Full Code Here

    @Override
    public void windowOpened(Window window) {
        super.windowOpened(window);

        Display display = window.getDisplay();
        display.getContainerMouseListeners().add(displayMouseListener);

        MenuPopup menuPopup = (MenuPopup)window;
        Menu menu = menuPopup.getMenu();
        if (menu != null) {
            Menu.Item activeItem = menu.getActiveItem();
View Full Code Here

    MenuPopupStateListener {
    private class RepositionCallback implements Runnable {
        @Override
        public void run() {
            MenuPopup menuPopup = (MenuPopup)getComponent();
            Display display = menuPopup.getDisplay();

            Point location = menuPopup.getLocation();
            Dimensions size = menuPopup.getSize();

            int x = location.x;
            if (x + size.width > display.getWidth()) {
                x -= size.width;
            }

            int y = location.y;
            if (y + size.height > display.getHeight()) {
                y-= size.height;
            }

            menuPopup.setLocation(x, y);
        }
View Full Code Here

    @Override
    public void windowOpened(Window window) {
        super.windowOpened(window);

        // Add this as a display mouse and key listener
        Display display = window.getDisplay();
        display.getContainerMouseListeners().add(displayMouseListener);
        display.getComponentKeyListeners().add(displayKeyListener);
    }
View Full Code Here

            if (window != null) {
                int width = getWidth();
                int height = getHeight();

                Display display = menuButton.getDisplay();

                // Ensure that the popup remains within the bounds of the display
                Point buttonLocation = menuButton.mapPointToAncestor(display, 0, 0);

                Dimensions displaySize = display.getSize();
                menuPopup.setPreferredSize(-1, -1);
                Dimensions popupSize = menuPopup.getPreferredSize();
                int popupWidth = Math.max(popupSize.width, menuButton.getWidth());
                int popupHeight = popupSize.height;
View Full Code Here

TOP

Related Classes of org.apache.pivot.wtk.Display

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.