📄 baseframe.java~63~
字号:
package mapcenter.service;import javax.swing.*;import java.awt.*;import java.awt.event.*;import java.net.URL;public class BaseFrame extends JFrame implements ComponentListener,WindowListener{ boolean packFrame = false; public BaseFrame() { //设置窗体图标 URL imgURL = getClass().getResource("/image/icon.gif"); ImageIcon icon = new ImageIcon(imgURL); //Image icon = Toolkit.getDefaultToolkit().getImage("image/icon.gif"); this.setIconImage(icon.getImage()); this.setTitle("地图维护台"); this.addComponentListener(this); this.addWindowListener(this); } /* public void windowActivated(WindowEvent e){} public void windowDeactivated(WindowEvent e){} public void windowIconified(WindowEvent e){} public void windowDeiconified(WindowEvent e){} public void windowOpened(WindowEvent e){} public void windowClosing(WindowEvent e){} public void windowClosed(WindowEvent e){} public void componentHidden(ComponentEvent e){} public void componentMoved(ComponentEvent e){} public void componentShown(ComponentEvent e){}*/ public void componentResized(ComponentEvent e){ //设置窗体居中 Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = this.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } this.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); } public static void main(String[] args){ JFrame baseFrame = new BaseFrame(); baseFrame.setSize(400,300); baseFrame.show(); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -