📄 usejroundbutton.java
字号:
package jroundbutton;import java.awt.*;import javax.swing.JFrame;import java.awt.event.*;/** * <p>Title: Swing按钮</p> * <p>Description: 应用java.awt.geom包中的类制作Swing按钮</p> * <p>Copyright: Copyright (c) 2004</p> * <p>Company: 北京师范大学计算机系</p> * @author 张庆利 * @version 1.0 */public class UseJRoundButton extends JFrame { public static final int DEFAULT_WIDTH = 300; public static final int DEFAULT_HEIGHT = 200; JRoundButton jRoundButton1 = new JRoundButton(); public UseJRoundButton() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } public static void main(String[] args) { UseJRoundButton useJRoundButton = new UseJRoundButton(); useJRoundButton.setSize(DEFAULT_WIDTH,DEFAULT_HEIGHT); useJRoundButton.show(); } private void jbInit() throws Exception { jRoundButton1.setText("单击按钮退出程序"); jRoundButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jRoundButton1_actionPerformed(e); } }); this.setTitle("应用geom包中的类制作Swing按钮"); this.getContentPane().add(jRoundButton1, BorderLayout.CENTER); } void jRoundButton1_actionPerformed(ActionEvent e) { System.exit(1); } protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -