Example usage for javax.swing JInternalFrame setMaximum

List of usage examples for javax.swing JInternalFrame setMaximum

Introduction

In this page you can find the example usage for javax.swing JInternalFrame setMaximum.

Prototype

@BeanProperty(description = "Indicates whether this internal frame is maximized.")
public void setMaximum(boolean b) throws PropertyVetoException 

Source Link

Document

Maximizes and restores this internal frame.

Usage

From source file:InternalFrameTest.java

/**
 * Cascades the non-iconified internal frames of the desktop.
 */// w  w  w.j  a v  a 2  s .  c  o  m
public void cascadeWindows() {
    int x = 0;
    int y = 0;
    int width = desktop.getWidth() / 2;
    int height = desktop.getHeight() / 2;

    for (JInternalFrame frame : desktop.getAllFrames()) {
        if (!frame.isIcon()) {
            try {
                // try to make maximized frames resizable; this might be vetoed
                frame.setMaximum(false);
                frame.reshape(x, y, width, height);

                x += frameDistance;
                y += frameDistance;
                // wrap around at the desktop edge
                if (x + width > desktop.getWidth())
                    x = 0;
                if (y + height > desktop.getHeight())
                    y = 0;
            } catch (PropertyVetoException e) {
            }
        }
    }
}

From source file:InternalFrameTest.java

/**
 * Tiles the non-iconified internal frames of the desktop.
 *///from   w w  w .jav  a  2s.  c  o m
public void tileWindows() {
    // count frames that aren't iconized
    int frameCount = 0;
    for (JInternalFrame frame : desktop.getAllFrames())
        if (!frame.isIcon())
            frameCount++;
    if (frameCount == 0)
        return;

    int rows = (int) Math.sqrt(frameCount);
    int cols = frameCount / rows;
    int extra = frameCount % rows;
    // number of columns with an extra row

    int width = desktop.getWidth() / cols;
    int height = desktop.getHeight() / rows;
    int r = 0;
    int c = 0;
    for (JInternalFrame frame : desktop.getAllFrames()) {
        if (!frame.isIcon()) {
            try {
                frame.setMaximum(false);
                frame.reshape(c * width, r * height, width, height);
                r++;
                if (r == rows) {
                    r = 0;
                    c++;
                    if (c == cols - extra) {
                        // start adding an extra row
                        rows++;
                        height = desktop.getHeight() / rows;
                    }
                }
            } catch (PropertyVetoException e) {
            }
        }
    }
}

From source file:com.tag.FramePreferences.java

@SuppressWarnings("serial")
public FramePreferences(final JInternalFrame frame, String pathName) {
    setFrame(new Frame() {

        @Override/*from   w  ww . j a  v  a  2 s.com*/
        public synchronized int getExtendedState() {
            if (frame.isMaximum()) {
                return Frame.MAXIMIZED_BOTH;
            } else if (frame.isIcon()) {
                return Frame.ICONIFIED;
            } else {
                return Frame.NORMAL;
            }
        }

        @Override
        public synchronized void setExtendedState(int state) {
            try {
                switch (state) {
                case Frame.MAXIMIZED_HORIZ:
                case Frame.MAXIMIZED_VERT:
                case Frame.MAXIMIZED_BOTH:
                    frame.setMaximum(true);
                    break;
                case Frame.ICONIFIED:
                    frame.setIcon(true);
                    break;
                case Frame.NORMAL:
                    frame.setIcon(false);
                    frame.setMaximum(false);
                    break;
                }
            } catch (PropertyVetoException e) {
                e.printStackTrace();
            }
        }

        @Override
        public synchronized void addWindowStateListener(final WindowStateListener l) {
            final Frame source = this;
            frame.addInternalFrameListener(new InternalFrameAdapter() {

                @Override
                public void internalFrameIconified(InternalFrameEvent e) {
                    l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_ICONIFIED));
                }

                @Override
                public void internalFrameDeiconified(InternalFrameEvent e) {
                    l.windowStateChanged(new WindowEvent(source, WindowEvent.WINDOW_DEICONIFIED));
                }

            });
        }

        @Override
        public synchronized void removeWindowStateListener(WindowStateListener l) {
            super.removeWindowStateListener(l);
        }

        @Override
        public GraphicsConfiguration getGraphicsConfiguration() {
            return frame.getGraphicsConfiguration();
        }

        public Point getLocation() {
            return frame.getLocation();
        }

        @Override
        public void setLocation(Point p) {
            frame.setLocation(p);
        }

        @Override
        public Dimension getSize() {
            return frame.getSize();
        }

        @Override
        public void setSize(Dimension size) {
            frame.setSize(size);
        }

        @Override
        public synchronized void addComponentListener(ComponentListener l) {
            frame.addComponentListener(l);
        }

        @Override
        public synchronized void removeComponentListener(ComponentListener l) {
            frame.addComponentListener(l);
        }

    });
    setPathName(pathName);
}

From source file:com.opendoorlogistics.studio.appframe.AppFrame.java

@Override
public JComponent launchTableGrid(int tableId) {
    if (loaded != null) {
        for (JInternalFrame frame : getInternalFrames()) {
            if (ODLGridFrame.class.isInstance(frame) && ((ODLGridFrame) frame).getTableId() == tableId) {
                frame.setVisible(true);//  w w w .  j  a v a2 s. c o  m
                frame.moveToFront();
                try {
                    frame.setMaximum(true);
                } catch (Throwable e) {
                    throw new RuntimeException(e);
                }
                // if not within visible areas, then recentre?
                return frame;
            }
        }

        ODLTableDefinition table = loaded.getDs().getTableByImmutableId(tableId);
        if (table != null) {
            ODLGridFrame gf = new ODLGridFrame(loaded.getDs(), table.getImmutableId(), true, null,
                    loaded.getDs());
            addInternalFrame(gf, FramePlacement.AUTOMATIC);
            return gf;
        }
    }
    return null;
}

From source file:com.opendoorlogistics.studio.appframe.AppFrame.java

@Override
public void launchTableSchemaEditor(int tableId) {
    if (loaded != null) {
        for (JInternalFrame frame : getInternalFrames()) {
            if (TableSchemaEditor.class.isInstance(frame)
                    && ((TableSchemaEditor) frame).getTableId() == tableId) {
                frame.setVisible(true);//  www  .  ja  va2  s  .co  m
                frame.moveToFront();
                try {
                    frame.setMaximum(true);
                } catch (Throwable e) {
                    throw new RuntimeException(e);
                }
                return;
            }
        }

        TableSchemaEditor gf = new TableSchemaEditor(loaded.getDs(), tableId);
        addInternalFrame(gf, FramePlacement.AUTOMATIC);
    }
}

From source file:com.moss.bdbadmin.client.ui.BdbAdminClient.java

private void showInDialog(String title, Component ancestor) {

    //      final JDialog dialog;

    //      if (ancestor instanceof JFrame) {
    //         dialog = new JDialog((JFrame)ancestor);
    //      }/*from w  w  w.j a  v a2  s . c om*/
    //      else if (ancestor instanceof JDialog) {
    //         dialog = new JDialog((JDialog)ancestor);
    //      }
    //      else if (ancestor == null) {
    //         dialog = new JDialog();
    //      }
    //      else {
    //         throw new RuntimeException();
    //      }

    JInternalFrame dialog = new JInternalFrame(title);

    //      dialog.setTitle(client.url() + dbPath);
    dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
    //      dialog.setModal(false);
    dialog.getContentPane().add(ancestor);
    dialog.setSize(400, 300);
    //      dialog.setLocationRelativeTo(ancestor);
    dialog.setResizable(true);
    dialog.setClosable(true);
    dialog.setIconifiable(true);
    dialog.setMaximizable(true);
    getDesktopPane().add(dialog);
    try {
        dialog.setMaximum(true);
    } catch (PropertyVetoException e) {
        e.printStackTrace();
    }
    dialog.setVisible(true);
}

From source file:com.opendoorlogistics.studio.AppFrame.java

JComponent launchTableGrid(int tableId) {
    if (loaded != null) {
        for (JInternalFrame frame : desktopPane.getAllFrames()) {
            if (ODLGridFrame.class.isInstance(frame) && ((ODLGridFrame) frame).getTableId() == tableId) {
                frame.setVisible(true);/*www  .  j  av a2 s  . co m*/
                frame.moveToFront();
                try {
                    frame.setMaximum(true);
                } catch (Throwable e) {
                    throw new RuntimeException(e);
                }
                // if not within visible areas, then recentre?
                return frame;
            }
        }

        ODLTableDefinition table = loaded.getDs().getTableByImmutableId(tableId);
        if (table != null) {
            ODLGridFrame gf = new ODLGridFrame(loaded.getDs(), table.getImmutableId(), true, null,
                    loaded.getDs(), this);
            addInternalFrame(gf, FramePlacement.AUTOMATIC);
            return gf;
        }
    }
    return null;
}

From source file:com.opendoorlogistics.studio.AppFrame.java

void launchTableSchemaEditor(int tableId) {
    if (loaded != null) {
        for (JInternalFrame frame : desktopPane.getAllFrames()) {
            if (TableSchemaEditor.class.isInstance(frame)
                    && ((TableSchemaEditor) frame).getTableId() == tableId) {
                frame.setVisible(true);//from ww w  . j  a v a2s.  c o m
                frame.moveToFront();
                try {
                    frame.setMaximum(true);
                } catch (Throwable e) {
                    throw new RuntimeException(e);
                }
                return;
            }
        }

        TableSchemaEditor gf = new TableSchemaEditor(loaded.getDs(), tableId);
        addInternalFrame(gf, FramePlacement.AUTOMATIC);
    }
}

From source file:mondrian.gui.Workbench.java

private void cascadeMenuItemActionPerformed(ActionEvent evt) {
    try {/*from  w w w .j a v  a2s.c  o  m*/
        int sfi = 1;
        for (JInternalFrame sf : getAllFrames()) {
            if (sf != null && !sf.isIcon()) {
                sf.setMaximum(false);
                sf.setLocation(30 * sfi, 30 * sfi);
                sf.moveToFront();
                sf.setSelected(true);
                sfi++;
            }
        }
    } catch (Exception ex) {
        LOGGER.error("cascadeMenuItemActionPerformed", ex);
        // do nothing
    }
}

From source file:mondrian.gui.Workbench.java

private void tileMenuItemActionPerformed(ActionEvent evt) {
    final Dimension dsize = desktopPane.getSize();
    final int desktopW = (int) dsize.getWidth();
    final int desktopH = (int) dsize.getHeight();
    final int darea = desktopW * desktopH;
    final double eacharea = darea / (schemaWindowMap.size() + mdxWindows.size() + jdbcWindows.size());
    final int wh = (int) Math.sqrt(eacharea);

    try {//from w  w w.j  av a  2s  .c o  m
        int x = 0, y = 0;
        for (JInternalFrame sf : getAllFrames()) {
            if (sf != null && !sf.isIcon()) {
                sf.setMaximum(false);
                sf.moveToFront();
                if (x >= desktopW || (desktopW - x) * wh < eacharea / 2) {
                    // move to next row of windows
                    y += wh;
                    x = 0;
                }
                int sfwidth = ((x + wh) < desktopW ? wh : desktopW - x);
                int sfheight = ((y + wh) < desktopH ? wh : desktopH - y);
                sf.setBounds(x, y, sfwidth, sfheight);
                x += sfwidth;
            }
        }
    } catch (Exception ex) {
        LOGGER.error("tileMenuItemActionPerformed", ex);
        // do nothing
    }
}