Example usage for javax.swing JInternalFrame setLocation

List of usage examples for javax.swing JInternalFrame setLocation

Introduction

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

Prototype

public void setLocation(int x, int y) 

Source Link

Document

Moves this component to a new location.

Usage

From source file:KjellDirdalNotepad.java

public Component add(JInternalFrame frame) {
    JInternalFrame[] array = getAllFrames();
    Point p;//  w  ww. j ava2s.  c  om
    int w;
    int h;

    Component retval = super.add(frame);
    checkDesktopSize();
    if (array.length > 0) {
        p = array[0].getLocation();
        p.x = p.x + FRAME_OFFSET;
        p.y = p.y + FRAME_OFFSET;
    } else {
        p = new Point(0, 0);
    }
    frame.setLocation(p.x, p.y);
    if (frame.isResizable()) {
        w = getWidth() - (getWidth() / 3);
        h = getHeight() - (getHeight() / 3);
        if (w < frame.getMinimumSize().getWidth())
            w = (int) frame.getMinimumSize().getWidth();
        if (h < frame.getMinimumSize().getHeight())
            h = (int) frame.getMinimumSize().getHeight();
        frame.setSize(w, h);
    }
    moveToFront(frame);
    frame.setVisible(true);
    try {
        frame.setSelected(true);
    } catch (PropertyVetoException e) {
        frame.toBack();
    }
    return retval;
}

From source file:mondrian.gui.Workbench.java

private void cascadeMenuItemActionPerformed(ActionEvent evt) {
    try {/*from  w  ww.j  a v a2 s  .  c om*/
        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:com.opendoorlogistics.studio.AppFrame.java

@Override
public void addInternalFrame(JInternalFrame frame, FramePlacement placement) {
    desktopPane.add(frame);/*from   w ww . j  a  va2  s.co m*/
    frame.pack();
    frame.setVisible(true);

    // if(ScriptEditor.class.isInstance(frame)){
    // try {
    // frame.setMaximum(true);
    // } catch (PropertyVetoException e) {
    // }
    // }
    // else{

    // WindowState state = PreferencesManager.getSingleton().getWindowState(frame)
    if (placement == FramePlacement.AUTOMATIC) {
        boolean placed = false;
        if (ODLInternalFrame.class.isInstance(frame)) {
            ODLInternalFrame odlFrame = (ODLInternalFrame) frame;
            placed = odlFrame.placeInLastPosition(desktopScrollPane.getViewport().getBounds());
        }

        if (!placed) {
            LayoutUtils.placeInternalFrame(desktopPane, frame);
        }
    } else if (placement == FramePlacement.CENTRAL) {
        Dimension desktopSize = desktopPane.getSize();
        Dimension frameSize = frame.getSize();
        int x = (desktopSize.width - frameSize.width) / 2;
        int y = (desktopSize.height - frameSize.height) / 2;
        frame.setLocation(x, y);
    } else if (placement == FramePlacement.CENTRAL_RANDOMISED) {
        Dimension desktopSize = desktopPane.getSize();
        Dimension frameSize = frame.getSize();
        Dimension remaining = new Dimension(Math.max(0, desktopSize.width - frameSize.width),
                Math.max(0, desktopSize.height - frameSize.height));
        Dimension halfRemaining = new Dimension(remaining.width / 2, remaining.height / 2);
        Random random = new Random();
        int x = remaining.width / 4 + random.nextInt(halfRemaining.width);
        int y = remaining.height / 4 + random.nextInt(halfRemaining.height);
        frame.setLocation(x, y);
    }
    frame.toFront();
}

From source file:CSSDFarm.UserInterface.java

/**
 * Configure JxBrowser to be displayed. Load map.html from file to string data, load
 * this data into JxBrowser and add the browser to the panel.
 *//*from  w  w w.  j a v a  2s.c o m*/
public void displayHeatmap() {
    LoggerProvider.getChromiumProcessLogger().setLevel(Level.OFF);
    LoggerProvider.getIPCLogger().setLevel(Level.OFF);
    LoggerProvider.getBrowserLogger().setLevel(Level.OFF);
    BrowserView view = new BrowserView(browser);
    JPanel toolBar = new JPanel();

    Dimension dimension = panelHeatmap.getSize();

    JInternalFrame internalFrame = new JInternalFrame();
    internalFrame.add(view, BorderLayout.CENTER);
    internalFrame.add(toolBar, BorderLayout.NORTH);
    internalFrame.setSize(dimension);
    internalFrame.setLocation(0, 0);
    internalFrame.setBorder(null);
    internalFrame.setVisible(true);
    ((javax.swing.plaf.basic.BasicInternalFrameUI) internalFrame.getUI()).setNorthPane(null);

    URL url = getClass().getResource("map.html");
    File html = new File(url.getPath());

    String htmlString = null;
    try {
        htmlString = FileUtils.readFileToString(html);
    } catch (IOException ex) {
        Logger.getLogger(UserInterface.class.getName()).log(Level.SEVERE, null, ex);
    }

    browser.loadHTML(htmlString);

    panelHeatmap.add(internalFrame);
}

From source file:org.intermine.common.swing.WindowUtils.java

/**
 * Centre the internal frame <code>win</code> over the internal
 * frame <code>parent</code>.
 * //from   w  ww .  j  av a2  s . c o m
 * @param win The JInternalFrame to position.
 * @param parent The reference JInternalFrame.
 */
public static void centreOverFrame(JInternalFrame win, JInternalFrame parent) {
    Rectangle parentBounds = parent.getBounds();
    Dimension windowSize = win.getSize();

    int x = (parentBounds.width - windowSize.width) / 2;
    int y = (parentBounds.height - windowSize.height) / 2;

    x = Math.max(0, x + parentBounds.x);
    y = Math.max(0, y + parentBounds.y);

    win.setLocation(x, y);
}