- package bbs.istak.org.tw;
- import java.awt.BorderLayout;
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- import javax.swing.border.EmptyBorder;
- import javax.swing.JButton;
- import java.awt.FlowLayout;
- import javax.swing.GroupLayout;
- import javax.swing.GroupLayout.Alignment;
- import javax.swing.JLabel;
- import javax.swing.SwingConstants;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- public class main extends JFrame {
- private JPanel contentPane;
- private int count =0;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- main frame = new main();
- frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the frame.
- */
- public main() {
- setTitle("\u9EDE\u64CA\u8A08\u6578\u5668");
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 322, 118);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- setContentPane(contentPane);
- contentPane.setLayout(null);
-
- JLabel Count = new JLabel("0");
- Count.setHorizontalAlignment(SwingConstants.CENTER);
- Count.setBounds(14, 22, 67, 32);
- contentPane.add(Count);
-
- JButton btnNewButton = new JButton("\u9EDE\u64CA");
- btnNewButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent arg0) {
-
- Count.setText(String.valueOf(++count));
- }
- });
- btnNewButton.setBounds(88, 13, 93, 51);
- contentPane.add(btnNewButton);
-
- JButton button = new JButton("\u6B78\u96F6");
- button.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- count=0;
- Count.setText(String.valueOf(count));
- }
- });
- button.setBounds(195, 13, 93, 51);
- contentPane.add(button);
- }
- }
複製代碼 |