Package pivot.wtk

Examples of pivot.wtk.Window$WindowListenerList


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

        Window window = (Window)component;

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

        window.add(titleBarFlowPane);

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

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

        ButtonPressListener buttonPressListener = new ButtonPressListener() {
            public void buttonPressed(Button button) {
                Window window = (Window)getComponent();

                if (button == minimizeButton) {
                    window.setDisplayable(false);
                } else if (button == maximizeButton) {
                    window.setMaximized(!window.isMaximized());
                } else if (button == closeButton) {
                    window.close();
                }
            }
        };

        minimizeButton.getButtonPressListeners().add(buttonPressListener);
        maximizeButton.getButtonPressListeners().add(buttonPressListener);
        closeButton.getButtonPressListeners().add(buttonPressListener);

        window.add(resizeHandle);

        iconChanged(window, null);
        titleChanged(window, null);
        activeChanged(window);
View Full Code Here


        updateMaximizedState();
    }

    @Override
    public void uninstall() {
        Window window = (Window)getComponent();

        // Detach the drop shadow decorator
        window.getDecorators().remove(dropShadowDecorator);
        dropShadowDecorator = null;

        window.remove(titleBarFlowPane);

        frameButtonFlowPane.remove(minimizeButton);
        frameButtonFlowPane.remove(maximizeButton);
        frameButtonFlowPane.remove(closeButton);
View Full Code Here

    }

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

        Window window = (Window)getComponent();
        Component content = window.getContent();

        Dimensions preferredTitleBarSize = titleBarFlowPane.getPreferredSize();
        preferredWidth = preferredTitleBarSize.width;

        if (content != null
View Full Code Here

    }

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

        Window window = (Window)getComponent();
        Component content = window.getContent();

        if (width != -1) {
            width = Math.max(width - 2, 0);
        }
View Full Code Here

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

        Window window = (Window)getComponent();
        Component content = window.getContent();

        Dimensions preferredTitleBarSize = titleBarFlowPane.getPreferredSize();

        preferredWidth = preferredTitleBarSize.width;
        preferredHeight = preferredTitleBarSize.height;
View Full Code Here

        return new Dimensions(preferredWidth, preferredHeight);
    }

    public void layout() {
        Window window = (Window)getComponent();

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

        // Size/position title bar
        titleBarFlowPane.setLocation(1, 1);
        titleBarFlowPane.setSize(Math.max(width - 2, 0),
            Math.max(titleBarFlowPane.getPreferredHeight(width - 2), 0));

        // Size/position resize handle
        resizeHandle.setSize(resizeHandle.getPreferredSize());
        resizeHandle.setLocation(width - resizeHandle.getWidth() - 2,
            height - resizeHandle.getHeight() - 2);

        boolean maximized = window.isMaximized();
        resizeHandle.setVisible(resizable
            && !maximized
            && (window.isPreferredWidthSet()
                || window.isPreferredHeightSet()));

        // Size/position content
        Component content = window.getContent();

        if (content != null) {
            if (content.isDisplayable()) {
                content.setVisible(true);
View Full Code Here

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

        Window window = (Window)getComponent();

        int width = getWidth();
        int height = getHeight();
        int titleBarHeight = titleBarFlowPane.getHeight();

        graphics.setStroke(new BasicStroke());

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

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

        this.resizable = resizable;
        invalidateComponent();
    }

    private void updateMaximizedState() {
        Window window = (Window)getComponent();
        boolean maximized = window.isMaximized();

        if (!maximized) {
            maximizeButton.setButtonData(maximizeImage);

            if (restoreLocation != null) {
                window.setLocation(restoreLocation.x, restoreLocation.y);
            }
        } else {
            maximizeButton.setButtonData(restoreImage);
            restoreLocation = window.getLocation();
        }
    }
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) {
            Window window = (Window)getComponent();
            Display display = window.getDisplay();

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

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

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

                    if (window.isPreferredWidthSet()) {
                        preferredWidth = Math.max(location.x - window.getX() + resizeOffset.x,
                            titleBarFlowPane.getPreferredWidth(-1) + 2);
                    }

                    if (window.isPreferredHeightSet()) {
                        preferredHeight = Math.max(location.y - window.getY() + resizeOffset.y,
                            titleBarFlowPane.getHeight() + resizeHandle.getHeight() + 7);
                    }

                    window.setPreferredSize(preferredWidth, preferredHeight);
                }
            }
        } else {
            Cursor cursor = null;
            if (x > resizeHandle.getX()
View Full Code Here

    @Override
    public boolean mouseDown(Component component, Mouse.Button button, int x, int y) {
        boolean consumed = super.mouseDown(component, button, x, y);

        Window window = (Window)getComponent();
        boolean maximized = window.isMaximized();

        if (button == Mouse.Button.LEFT
            && !maximized) {
            Bounds titleBarBounds = titleBarFlowPane.getBounds();
View Full Code Here

TOP

Related Classes of pivot.wtk.Window$WindowListenerList

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.