?? centeredjdialog.java
字號:
/* CenteredJDialog.java This file is taken from the ARtool application written by Laurentiu Cristofor (P)2002 Laurentiu Cristofor*//*GAClust - Clustering categorical databases using genetic algorithmsCopyright (C) 2002 Dana CristoforThis program is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2 of the License, or (atyour option) any later version.This program is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with this program; if not, write to the Free SoftwareFoundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307USAGAClust was written by Dana Cristofor (dana@cs.umb.edu).*/import javax.swing.*;import java.awt.*;/** * A centered JDialog. Constructor comments are straight from the JDialog * source. * * @version 1.0 * @author Laurentiu Cristofor */public class CenteredJDialog extends JDialog{ /** * Creates a non-modal dialog without a title and without a * specified <code>Frame</code> owner. A shared, hidden frame will * be set as the owner of the dialog. */ public CenteredJDialog() { super(); } /** * Creates a non-modal dialog without a title with the * specified <code>Frame</code> as its owner. * * @param owner the <code>Frame</code> from which the dialog is displayed */ public CenteredJDialog(Frame owner) { super(owner); } /** * Creates a modal or non-modal dialog without a title and * with the specified owner <code>Frame</code>. * * @param owner the <code>Frame</code> from which the dialog is displayed * @param modal true for a modal dialog, false for one that allows * others windows to be active at the same time */ public CenteredJDialog(Frame owner, boolean modal) { super(owner, modal); } /** * Creates a non-modal dialog with the specified title and * with the specified owner frame. * * @param owner the <code>Frame</code> from which the dialog is displayed * @param title the <code>String</code> to display in the dialog's * title bar */ public CenteredJDialog(Frame owner, String title) { super(owner, title); } /** * Creates a modal or non-modal dialog with the specified title * and the specified owner <code>Frame</code>. All constructors * defer to this one. * <p> * NOTE: Any popup components (<code>JComboBox</code>, * <code>JPopupMenu</code>, <code>JMenuBar</code>) * created within a modal dialog will be forced to be lightweight. * * @param owner the <code>Frame</code> from which the dialog is displayed * @param title the <code>String</code> to display in the dialog's * title bar * @param modal true for a modal dialog, false for one that allows * other windows to be active at the same time */ public CenteredJDialog(Frame owner, String title, boolean modal) { super(owner, title, modal); } /** * Creates a non-modal dialog without a title with the * specified <code>Dialog</code> as its owner. * * @param owner the <code>Dialog</code> from which the dialog is displayed */ public CenteredJDialog(Dialog owner) { super(owner); } /** * Creates a modal or non-modal dialog without a title and * with the specified owner dialog. * <p> * * @param owner the <code>Dialog</code> from which the dialog is displayed * @param modal true for a modal dialog, false for one that allows * other windows to be active at the same time */ public CenteredJDialog(Dialog owner, boolean modal) { super(owner, modal); } /** * Creates a non-modal dialog with the specified title and * with the specified owner dialog. * * @param owner the <code>Dialog</code> from which the dialog is displayed * @param title the <code>String</code> to display in the dialog's * title bar */ public CenteredJDialog(Dialog owner, String title) { super(owner, title); } /** * Creates a modal or non-modal dialog with the specified title * and the specified owner frame. * * @param owner the <code>Dialog</code> from which the dialog is displayed * @param title the <code>String</code> to display in the dialog's * title bar * @param modal true for a modal dialog, false for one that allows * other windows to be active at the same time */ public CenteredJDialog(Dialog owner, String title, boolean modal) { super(owner, title, modal); } /** * The following method should be called to center the dialog. */ public CenteredJDialog center() { if (getParent() == null) return this; Point p = getParent().getLocation(); Dimension p_d = getParent().getSize(); Dimension d = getSize(); int x = p.x + (p_d.width - d.width) / 2; int y = p.y + (p_d.height - d.height) / 2; setLocation(x, y); return this; }}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -