?? exercise13_7.java
字號:
// Exercise13_7.java: Draw a star
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Exercise13_7 extends JFrame implements ActionListener {
private JTextField jtfHour = new JTextField(2);
private JTextField jtfMinute = new JTextField(2);
private JTextField jtfSecond = new JTextField(2);
private StillClock clock = new StillClock();
public Exercise13_7() {
Container container = getContentPane();
JPanel p = new JPanel();
p.add(new JLabel("Hour"));
p.add(jtfHour);
p.add(new JLabel("Minute"));
p.add(jtfMinute);
p.add(new JLabel("Second"));
p.add(jtfSecond);
container.add(p, BorderLayout.SOUTH);
container.add(clock, BorderLayout.CENTER);
jtfHour.addActionListener(this);
jtfMinute.addActionListener(this);
jtfSecond.addActionListener(this);
}
public static void main(String[] args) {
Exercise13_7 frame = new Exercise13_7();
frame.setSize(400, 400);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setTitle("Exercise13_7");
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == jtfHour)
clock.setHour(Integer.parseInt(jtfHour.getText()));
else if (e.getSource() == jtfMinute)
clock.setMinute(Integer.parseInt(jtfMinute.getText()));
else if (e.getSource() == jtfSecond)
clock.setSecond(Integer.parseInt(jtfSecond.getText()));
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -