Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Frame$FrameListenerList


     * Minimize button image.
     */
    protected class MinimizeImage extends ButtonImage {
        @Override
        public void paint(Graphics2D graphics) {
            Frame frame = (Frame)getComponent();
            graphics.setPaint(frame.isActive() ? titleBarColor : inactiveTitleBarColor);
            graphics.fillRect(0, 6, 8, 2);
        }
View Full Code Here


     * Maximize button image.
     */
    protected class MaximizeImage extends ButtonImage {
        @Override
        public void paint(Graphics2D graphics) {
            Frame frame = (Frame)getComponent();
            graphics.setPaint(frame.isActive() ? titleBarColor : inactiveTitleBarColor);
            graphics.fillRect(0, 0, 8, 8);

            graphics.setPaint(frame.isActive() ? titleBarBackgroundColor : inactiveTitleBarBackgroundColor);
            graphics.fillRect(2, 2, 4, 4);
        }
View Full Code Here

     * Restore button image.
     */
    protected class RestoreImage extends ButtonImage {
        @Override
        public void paint(Graphics2D graphics) {
            Frame frame = (Frame)getComponent();
            graphics.setPaint(frame.isActive() ?
                titleBarColor : inactiveTitleBarColor);
            graphics.fillRect(1, 1, 6, 6);

            graphics.setPaint(frame.isActive() ?
                titleBarBackgroundColor : inactiveTitleBarBackgroundColor);
            graphics.fillRect(3, 3, 2, 2);
        }
View Full Code Here

     * Close button image.
     */
    protected class CloseImage extends ButtonImage {
        @Override
        public void paint(Graphics2D graphics) {
            Frame frame = (Frame)getComponent();
            graphics.setPaint(frame.isActive() ?
                titleBarColor : inactiveTitleBarColor);
            graphics.setStroke(new BasicStroke(2));

            graphics.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
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 frame = (Frame)getComponent();

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

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

        frame.add(resizeHandle);

        iconAdded(frame, null);
        titleChanged(frame, null);
        activeChanged(frame, null);
        maximizedChanged(frame);
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 titleBarBackgroundColor = frame.isActive() ?
                this.titleBarBackgroundColor : inactiveTitleBarBackgroundColor;
            Color titleBarBorderColor = frame.isActive() ?
                this.titleBarBorderColor : inactiveTitleBarBorderColor;
            Color titleBarBevelColor = frame.isActive() ?
                this.titleBarBevelColor : inactiveTitleBarBevelColor;

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

TOP

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

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.