Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Frame


        };

        Action.getNamedActions().put("buttonAction", action);

        WTKXSerializer wtkxSerializer = new WTKXSerializer();
        frame = new Frame((Component)wtkxSerializer.readObject(getClass().getResource("spinner_focus_test.wtkx")));
        frame.setTitle("Spinner Focus Test");
        frame.open(display);

        Spinner spinner = (Spinner)wtkxSerializer.get("spinner");
        spinner.requestFocus();
View Full Code Here


public class LabelTest extends Application.Adapter {
    private Frame frame = null;

    @Override
    public void startup(Display display, Map<String, String> properties) throws Exception {
        frame = new Frame();
        frame.setTitle("Label Test");

        String line1 = "There's a lady who's sure all that glitters is gold, and "
            + "she's buying a stairway to heaven. When she gets there she knows, "
            + "if the stores are closed, with a word she can get what she came "
View Full Code Here

    @Override
    public void install(Component component) {
        super.install(component);

        Frame frame = (Frame)getComponent();

        // Attach the drop-shadow decorator
        dropShadowDecorator = new DropShadowDecorator();
        frame.getDecorators().add(dropShadowDecorator);

        frame.add(titleBarTablePane);

        // Create the frame buttons
        minimizeButton = new FrameButton(minimizeImage);
        maximizeButton = new FrameButton(maximizeImage);
        closeButton = new FrameButton(closeImage);

        buttonBoxPane.add(minimizeButton);
        buttonBoxPane.add(maximizeButton);
        buttonBoxPane.add(closeButton);

        ButtonPressListener buttonPressListener = new ButtonPressListener() {
            @Override
            public void buttonPressed(Button button) {
                Frame frameLocal = (Frame)getComponent();

                if (button == minimizeButton) {
                    frameLocal.setVisible(false);
                } else if (button == maximizeButton) {
                    frameLocal.moveToFront();
                    frameLocal.setMaximized(!frameLocal.isMaximized());
                } else if (button == closeButton) {
                    frameLocal.close();
                }
            }
        };

        minimizeButton.getButtonPressListeners().add(buttonPressListener);
View Full Code Here

    @Override
    public int getPreferredWidth(int height) {
        int preferredWidth = 0;

        Frame frame = (Frame)getComponent();

        // Include title bar width plus left/right title bar borders
        Dimensions titleBarSize = titleBarTablePane.getPreferredSize();
        preferredWidth = Math.max(titleBarSize.width + 2, preferredWidth);

        if (height != -1) {
            // Subtract title bar height and top/bottom title bar borders
            // from height constraint
            height -= titleBarSize.height + 2;
        }

        // Include menu bar width
        MenuBar menuBar = frame.getMenuBar();
        if (menuBar != null) {
            Dimensions menuBarSize = menuBar.getPreferredSize();
            preferredWidth = Math.max(preferredWidth, menuBarSize.width);

            if (height != -1) {
                // Subtract menu bar height from height constraint
                height -= menuBarSize.height;
            }
        }

        Component content = frame.getContent();
        if (content != null) {
            if (height != -1) {
                // Subtract padding, top/bottom content borders, and content bevel
                // from height constraint
                height -= (padding.top + padding.bottom) + (showContentBevel ? 1 : 0) + 2;
View Full Code Here

    @Override
    public int getPreferredHeight(int width) {
        int preferredHeight = 0;

        Frame frame = (Frame)getComponent();

        // Include title bar height plus top/bottom title bar borders
        preferredHeight += titleBarTablePane.getPreferredHeight() + 2;

        // Include menu bar height
        MenuBar menuBar = frame.getMenuBar();
        if (menuBar != null) {
            preferredHeight += menuBar.getPreferredHeight();
        }

        Component content = frame.getContent();
        if (content != null) {
            if (width != -1) {
                // Subtract padding and left/right content borders from constraint
                width -= (padding.left + padding.right) + 2;
View Full Code Here

    @Override
    public Dimensions getPreferredSize() {
        int preferredWidth = 0;
        int preferredHeight = 0;

        Frame frame = (Frame)getComponent();

        // Include title bar width plus left/right title bar borders
        Dimensions titleBarSize = titleBarTablePane.getPreferredSize();
        preferredWidth = Math.max(preferredWidth, titleBarSize.width + 2);

        // Include title bar height plus top/bottom title bar borders
        preferredHeight += titleBarSize.height + 2;

        // Include menu bar size
        MenuBar menuBar = frame.getMenuBar();
        if (menuBar != null) {
            Dimensions preferredMenuBarSize = menuBar.getPreferredSize();

            preferredWidth = Math.max(preferredWidth, preferredMenuBarSize.width);
            preferredHeight += preferredMenuBarSize.height;
        }

        Component content = frame.getContent();
        if (content != null) {
            Dimensions preferredContentSize = content.getPreferredSize();

            preferredWidth = Math.max(preferredWidth, preferredContentSize.width);
            preferredHeight += preferredContentSize.height;
View Full Code Here

        return new Dimensions(preferredWidth, preferredHeight);
    }

    @Override
    public void layout() {
        Frame frame = (Frame)getComponent();

        int width = getWidth();
        int height = getHeight();

        boolean maximized = frame.isMaximized();

        if (!maximized
            || getShowWindowControls()) {
            int clientX = 1;
            int clientY = 1;
            int clientWidth = Math.max(width - 2, 0);
            int clientHeight = Math.max(height - 2, 0);

            // Size/position title bar
            titleBarTablePane.setLocation(clientX, clientY);
            titleBarTablePane.setSize(clientWidth, titleBarTablePane.getPreferredHeight());
            titleBarTablePane.setVisible(true);

            // Add bottom title bar border, top content border, and content bevel
            clientY += titleBarTablePane.getHeight() + (showContentBevel ? 1 : 0) + 2;

            // Size/position resize handle
            resizeHandle.setSize(resizeHandle.getPreferredSize());
            resizeHandle.setLocation(clientWidth - resizeHandle.getWidth(),
                clientHeight - resizeHandle.getHeight());
            resizeHandle.setVisible(resizable
                && !maximized
                && (frame.isPreferredWidthSet()
                    || frame.isPreferredHeightSet()));

            // Size/position menu bar
            MenuBar menuBar = frame.getMenuBar();
            if (menuBar != null
                && menuBar.isVisible()) {
                menuBar.setLocation(clientX, clientY);
                menuBar.setSize(clientWidth, menuBar.getPreferredHeight());

                clientY += menuBar.getHeight();
            }

            // Size/position content
            Component content = frame.getContent();
            if (content != null) {
                int contentX = clientX + padding.left;
                int contentY = clientY + padding.top;
                int contentWidth = Math.max(clientWidth - (padding.left + padding.right), 0);
                int contentHeight = Math.max(clientHeight - (clientY + padding.top + padding.bottom) + (showContentBevel ? 1 : 0), 0);

                content.setLocation(contentX, contentY);
                content.setSize(contentWidth, contentHeight);
            }
        } else {
            titleBarTablePane.setVisible(false);
            resizeHandle.setVisible(false);

            // Size/position menu bar
            int clientY = 0;
            MenuBar menuBar = frame.getMenuBar();
            if (menuBar != null
                && menuBar.isVisible()) {
                menuBar.setLocation(0, clientY);
                menuBar.setSize(width, menuBar.getPreferredHeight());

                clientY += menuBar.getHeight();
            }

            Component content = frame.getContent();
            if (content != null) {
                content.setLocation(padding.left, clientY + padding.top);
                content.setSize(Math.max(width - (padding.left + padding.right), 0),
                    Math.max(height - (clientY + padding.top + padding.bottom), 0));
            }
View Full Code Here

    @Override
    public void paint(Graphics2D graphics) {
        // Call the base class to paint the background
        super.paint(graphics);

        Frame frame = (Frame)getComponent();

        int width = getWidth();
        int height = getHeight();

        boolean maximized = frame.isMaximized();

        if (!maximized
            || getShowWindowControls()) {
            int titleBarHeight = titleBarTablePane.getHeight();

            // Draw the title area
            Color titleBarBackgroundColorLocal = frame.isActive() ?
                this.titleBarBackgroundColor : inactiveTitleBarBackgroundColor;
            Color titleBarBorderColorLocal = frame.isActive() ?
                this.titleBarBorderColor : inactiveTitleBarBorderColor;
            Color titleBarBevelColorLocal = frame.isActive() ?
                this.titleBarBevelColor : inactiveTitleBarBevelColor;

            graphics.setPaint(new GradientPaint(width / 2f, 0, titleBarBevelColorLocal,
                width / 2f, titleBarHeight + 1, titleBarBackgroundColorLocal));
            graphics.fillRect(0, 0, width, titleBarHeight + 1);
View Full Code Here

    public Bounds getClientArea() {
        int width = getWidth();
        int height = getHeight();
        int titleBarHeight = titleBarTablePane.getHeight();

        Frame frame = (Frame)getComponent();
        boolean maximized = frame.isMaximized();

        Bounds clientArea;
        if (maximized
            && !getShowWindowControls()) {
            clientArea = new Bounds(0, 0, width, height);
View Full Code Here

    @Override
    public boolean mouseMove(Component component, int x, int y) {
        boolean consumed = super.mouseMove(component, x, y);

        if (Mouse.getCapturer() == component) {
            Frame frame = (Frame)getComponent();
            Display display = frame.getDisplay();

            Point location = frame.mapPointToAncestor(display, x, y);

            // Pretend that the mouse can't move off screen (off the display)
            location = new Point(Math.min(Math.max(location.x, 0), display.getWidth() - 1),
                Math.min(Math.max(location.y, 0), display.getHeight() - 1));

            if (dragOffset != null) {
                // Move the frame
                frame.setLocation(location.x - dragOffset.x, location.y - dragOffset.y);
            } else {
                if (resizeOffset != null) {
                    // Resize the frame
                    int preferredWidth = -1;
                    int preferredHeight = -1;

                    if (frame.isPreferredWidthSet()) {
                        preferredWidth = Math.max(location.x - frame.getX() + resizeOffset.x,
                            titleBarTablePane.getPreferredWidth(-1) + 2);
                        preferredWidth = Math.min(preferredWidth, frame.getMaximumWidth());
                        preferredWidth = Math.max(preferredWidth, frame.getMinimumWidth());
                    }

                    if (frame.isPreferredHeightSet()) {
                        preferredHeight = Math.max(location.y - frame.getY() + resizeOffset.y,
                            titleBarTablePane.getHeight() + resizeHandle.getHeight() + (showContentBevel ? 1 : 0) + 6);
                        preferredHeight = Math.min(preferredHeight, frame.getMaximumHeight());
                        preferredHeight = Math.max(preferredHeight, frame.getMinimumHeight());
                    }

                    frame.setPreferredSize(preferredWidth, preferredHeight);
                }
            }
        } else {
            Cursor cursor = null;
            if (resizeHandle.isVisible()
View Full Code Here

TOP

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

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.