📄 juzhong.java
字号:
package com.util;
import javax.swing.JDialog;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.JFrame;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2008</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class JuZhong {
public JuZhong() {
}
/**
* 此方法设置Frame居中及大小
* @param frame JFrame
* @param width int
* @param height int
*/
public static void showFrame(JFrame frame, int width, int height) {
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(width, height);
// Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension frameSize = frame.getSize();
if (frameSize.height > screenSize.height) {
frameSize.height = screenSize.height;
}
if (frameSize.width > screenSize.width) {
frameSize.width = screenSize.width;
}
frame.setLocation( (screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
frame.setVisible(true);
}
/**
* 此方法设置Dialog居中及大小
* @param dialog JDialog
* @param width int
* @param heigth int
*/
public static void showDialog(JDialog dialog, int width, int heigth) {
dialog.setSize(width, heigth);
dialog.setResizable(false); //窗体不可改变大小
// Center the window
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension dialogSize = dialog.getSize();
if (dialogSize.height > screenSize.height) {
dialogSize.height = screenSize.height;
}
if (dialogSize.width > screenSize.width) {
dialogSize.width = screenSize.width;
}
dialog.setLocation( (screenSize.width - dialogSize.width) / 2,
(screenSize.height - dialogSize.height) / 2);
dialog.setModal(true);
dialog.setVisible(true);
}
// public static
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -