【Java开源代码栏目提醒】:网学会员鉴于大家对Java开源代码十分关注,论文会员在此为大家搜集整理了“ButtonFrame.java”一文,供大家参考学习
import javax.swing.*;
import java.awt.event.*;
public class ButtonFrame extends JFrame implements ActionListener {
private Timer theTimer;
/** post: theTimer == t */
public ButtonFrame(Timer t) {
super("");
setBounds(100, 100, 200, 80);
setVisible(true);
setLayout(null);
JButton btn = new JButton("Start Sunrise");
btn.setBounds(10, 10, 180, 30);
btn.addActionListener(this);
add(btn, 0);
repaint();
theTimer = t;
}
public void actionPerformed( ActionEvent e ) {
theTimer.start( );
}
}