Here you can find the source of execLoop(JComponent editor)
public static void execLoop(JComponent editor)
//package com.java2s; /**//from w w w .jav a 2s . co m * Copyright (c) 2005-2011 by Appcelerator, Inc. All Rights Reserved. * Licensed under the terms of the Eclipse Public License (EPL). * Please see the license.txt included with this distribution for details. * Any modifications to this file must keep this entire header intact. */ import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import java.awt.Frame; import java.awt.Toolkit; import java.awt.Window; import javax.swing.JComponent; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JScrollPane; public class Main { public static void execLoop(JComponent editor, Frame parent, boolean modal) { execLoop(editor, parent, modal, 800, 600); } public static void execLoop(JComponent editor, Frame parent, boolean modal, int w, int h) { JDialog dialog = new JDialog(parent, modal); Container contentPane = dialog.getContentPane(); contentPane.setLayout(new BorderLayout()); JScrollPane scrollPane = new JScrollPane(editor); contentPane.add(scrollPane, BorderLayout.CENTER); dialog.setSize(w, h); centerWindow(dialog); dialog.setVisible(true); } public static void execLoop(JComponent editor, boolean modal) { execLoop(editor, new JFrame(), modal); } /** * Addes the given editor to a jframe and halts until it is closed) */ public static void execLoop(JComponent editor) { execLoop(editor, true); } public static void centerWindow(Window component) { //Get the screen size Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension screenSize = toolkit.getScreenSize(); //Calculate the frame location int x = (screenSize.width - component.getWidth()) / 2; int y = (screenSize.height - component.getHeight()) / 2; //Set the new frame location component.setLocation(x, y); } }