Java프로그래밍/예제문제
Timer Source Code: TimerUI
동양상인
2016. 4. 8. 15:41
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | package univ.embedded.timer; import java.awt.Color; import java.awt.event.*; import javax.swing.*; public class TimerUI extends JFrame implements ActionListener { JLabel timeLabel = null; JButton startButton = null; @Override public void actionPerformed(ActionEvent e) { //TimerLogic lc = new TimerLogic(timeLabel); //lc.start(); startButton.setText("NO TOUCH"); startButton.setEnabled(false); (new TimerLogic(timeLabel, this)).start(); } public void activateButton() { startButton.setText("Start"); startButton.setEnabled(true); } public TimerUI() { setSize(300, 200); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setTitle("10 Sec. Timer"); timeLabel = new JLabel("10"); startButton = new JButton("Start"); startButton.addActionListener(this); setLayout(null); timeLabel.setSize(100, 60); startButton.setSize(100, 60); timeLabel.setLocation(50, 20); startButton.setLocation(50, 100); add(timeLabel); add(startButton); setVisible(true); } } |
반응형
LIST