📄 testbutton.java
字号:
/* * TestButton.java * * Created on July 30, 2002, 2:36 PM */package com.samspublishing.jpp.ch13;import java.awt.*;import java.awt.event.*;/** * * @author Stephen Potts * @version */public class TestButton extends Frame implements ActionListener{ Button btnExit; /** Creates new TestDialog */ public TestButton() { btnExit = new Button("Exit"); btnExit.setFont(new Font("Courier", Font.BOLD, 24)); btnExit.setBackground(Color.cyan); Cursor curs = new Cursor(HAND_CURSOR); btnExit.setCursor(curs); btnExit.addActionListener(this); add(btnExit); this.setLayout(new FlowLayout()); addWindowListener(new WinCloser()); setTitle("Using a Button and an ActionListener"); setBounds( 100, 100, 300, 300); setVisible(true); } public void actionPerformed(ActionEvent ae) { if (ae.getActionCommand().equals("Exit")) System.exit(0); } public static void main(String[] args) { TestButton td = new TestButton(); } }class WinCloser extends WindowAdapter{ public void windowClosing(WindowEvent e) { System.exit(0); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -