Example usage for javax.swing JInternalFrame moveToFront

List of usage examples for javax.swing JInternalFrame moveToFront

Introduction

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

Prototype

public void moveToFront() 

Source Link

Document

Convenience method that moves this component to position 0 if its parent is a JLayeredPane.

Usage

From source file:GUIUtils.java

public static void moveToFront(final JInternalFrame fr) {
    if (fr != null) {
        processOnSwingEventThread(new Runnable() {
            public void run() {
                fr.moveToFront();
                fr.setVisible(true);/*ww w  .j av  a2s  . co m*/
                try {
                    fr.setSelected(true);
                    if (fr.isIcon()) {
                        fr.setIcon(false);
                    }
                    fr.setSelected(true);
                } catch (PropertyVetoException ex) {

                }
                fr.requestFocus();
            }
        });
    }

}

From source file:KjellDirdalNotepad.java

private void buildChildMenus() {
    int i;/*from  w  ww. j a v a  2s.c  o m*/
    ChildMenuItem menu;
    JInternalFrame[] array = desktop.getAllFrames();

    add(cascade);
    add(tile);
    if (array.length > 0)
        addSeparator();
    cascade.setEnabled(array.length > 0);
    tile.setEnabled(array.length > 0);

    for (i = 0; i < array.length; i++) {
        menu = new ChildMenuItem(array[i]);
        menu.setState(i == 0);
        menu.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                JInternalFrame frame = ((ChildMenuItem) ae.getSource()).getFrame();
                frame.moveToFront();
                try {
                    frame.setSelected(true);
                } catch (PropertyVetoException e) {
                    e.printStackTrace();
                }
            }
        });
        menu.setIcon(array[i].getFrameIcon());
        add(menu);
    }
}

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 av  a 2s.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);/*from   w  w  w  .  j  a v a  2  s  .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: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);// w  ww . j  a v  a  2 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(), 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. jav  a 2 s  .  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 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 {//  w w w.j a  v  a  2  s.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
    }
}

From source file:mondrian.gui.Workbench.java

private void cascadeMenuItemActionPerformed(ActionEvent evt) {
    try {/*from  ww w.  ja va2s . 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:org.en.tealEye.guiMain.MainAppFrame.java

public void insertInternalFrame(ExtendedJPanelImpl name) {
    ExtendedJPanelImpl jPanelImpl;/*from   w ww.  j  a  v  a2s .c  o  m*/
    try {
        jPanelImpl = name;
        panelMap.put(name.getName(), name);
        JInternalFrame jInternalFrame = new JInternalFrame();
        jInternalFrame.setSize(400, 300);
        jInternalFrame.setName(jPanelImpl.getName());
        jInternalFrame.setTitle(jPanelImpl.getTitle());
        jInternalFrame.getContentPane().add(new JScrollPane(jPanelImpl));
        jInternalFrame.setIconifiable(true);
        jInternalFrame.setMaximizable(true);
        jInternalFrame.setResizable(true);
        jInternalFrame.setClosable(true);
        jInternalFrame.addInternalFrameListener(windowController);
        frameMap.put(jInternalFrame.getName(), jInternalFrame);
        desktop.add(jInternalFrame);
        desktop.getDesktopManager().activateFrame(jInternalFrame);
        desktop.getDesktopManager().maximizeFrame(jInternalFrame);
        jInternalFrame.moveToFront();
        jInternalFrame.setSelected(true);
        jInternalFrame.setVisible(true);
        jInternalFrame.validate();
        activeFrameMenu.addFrameButton(jPanelImpl.getName());
        menuController.setActiveFrameName(jInternalFrame.getName());
    } catch (Exception e) {
        log.error("cannot open panel " + name, e);
    }

}

From source file:org.en.tealEye.guiMain.MainAppFrame.java

public void activateInternalFrame(String panelName) {
    JInternalFrame[] frames = desktop.getAllFrames();
    for (JInternalFrame frame : frames) {
        if (frame.getName().equals(panelName)) {
            frame.moveToFront();
            //desktop.getDesktopManager().deactivateFrame(frame);
            desktop.getDesktopManager().activateFrame(frame);
            try {
                frame.setSelected(true);
                menuController.setActiveFrameName(frame.getName());
            } catch (PropertyVetoException e) {
                log.error(e.getMessage(), e);
            }// ww  w .j  a  v  a2s . c  o m
        } else {
            frame.moveToBack();
        }
    }
}