Package org.apache.pivot.wtk

Examples of org.apache.pivot.wtk.Frame


    @Override
    public boolean keyPressed(Component component, int keyCode, Keyboard.KeyLocation keyLocation) {
        boolean consumed = super.keyPressed(component, keyCode, keyLocation);

        Frame frame = (Frame)component;
        MenuBar menuBar = frame.getMenuBar();

        if (menuBar != null
            && keyCode == Keyboard.KeyCode.SPACE
            && Keyboard.isPressed(Keyboard.Modifier.ALT)) {
            MenuBar.Item activeItem = menuBar.getActiveItem();
View Full Code Here


     * 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 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

            }
        });

        windowContent.add(button);

        frame = new Frame(windowContent);
        frame.setMaximized(true);
        frame.open(display);
    }
View Full Code Here

    private Frame frame = null;

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

        Image tag = Image.load(getClass().getResource("go-home.png"));
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.