usejroundbutton.java
来自「java程序中关于多媒体编程 既有文件说明 更有例子 希望大家可以一起学习交流」· Java 代码 · 共 57 行
JAVA
57 行
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 + =
减小字号Ctrl + -
显示快捷键?