设置宽度、高度和中心 JPanel

set width, height and center JPanel

我想要一个 Jpanel 我的 java 应用程序在宽度和高度 setSize (700.400); 和屏幕中心之外。但是我一直没能得到:

public class MainView extends JFrame {
private static final long serialVersionUID = -3698259040339973565L;

private JPanel _main;
private JPanel _log;
private CardLayout _cl = new CardLayout();

/**
 * 
 */
public MainView() {
    JPanel main = new JPanel();
    main.setLayout(new MigLayout("fill, gapy 2lp, insets 0", "", "[grow 90, 90%][grow 10, 10%]"));

    _main = new JPanel();
    _main.setLayout(_cl);
    _log = new JPanel();

    main.setBackground(Color.decode(Config.Config.COLOR_BACKGROUND));

    main.add(_main,     "grow, align center, wrap");
    main.add(_log,      "grow, hmin 80lp, hmax 80lp");

    this.setUndecorated(true);
    this.add(main);

    this.setTitle("Fotofinisher");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    this.setVisible(true);

    try {
        UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );
    } catch (Exception e) {
        e.printStackTrace();
    }
    this.setFocusable(true);
  }
}

此代码不作为示例,它适合我的项目并且运行但不能调整大小。

and the center of the screen.

setSize (700.400); 
setLocationRelativeTo(null);
setVisible(true);
UIManager.setLookAndFeel( UIManager.getCrossPlatformLookAndFeelClassName() );

此外,上述语句需要在创建任何组件之前执行。