Java JFrame position(JFrame f)

Here you can find the source of position(JFrame f)

Description

Centers a JFrame so that its position is in the center of the window.

License

Open Source License

Parameter

Parameter Description
f The JFrame to be positioned.

Declaration

public static void position(JFrame f) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import javax.swing.*;

public class Main {
    private static JFrame frame = null;

    /**//from  w  w  w .ja  v a  2 s.  c o m
     * Centers a JFrame so that its position is in the center of
     * the window.
     *
     * @param f The JFrame to be positioned.
     */
    public static void position(JFrame f) {
        f.setLocationRelativeTo(frame);
    }
}

Related

  1. optionDialog(String title, String text, String option1, String option2, int defaultOption, JFrame parentFrame)
  2. packFrame(JFrame frame)
  3. packJFrameWindow(final JComponent comp)
  4. POPUP(JFrame frame, String message)
  5. popupError(JFrame parent, String title, String text)
  6. putOnWidestScreen(JFrame frame)
  7. refreshShape(final JFrame frame)
  8. registerCloseAction(final JFrame dialog, KeyStroke keyStroke)
  9. registerMenuShortcut(String uniqueActionName, Action action, int keyCode, JFrame frame)