⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 countbuttonpushes.java

📁 The code to demonstrate simple GUI in Java
💻 JAVA
字号:
import java.awt.*;import java.awt.event.*;import javax.swing.*;public class CountButtonPushes extends JFrame implements ActionListener {   private JButton button = new JButton("Press me");   private JLabel total = new JLabel( "Running total:");   private JTextField tally  = new JTextField(10);   private int count    = 0;   public CountButtonPushes() {      super("A Container With Components");      Container cp = getContentPane();      setSize(500,500);      cp.setLayout(new FlowLayout());      cp.add(total);      cp.add(tally);      cp.add (button);      button.addActionListener(this);      setVisible(true);      setDefaultCloseOperation(EXIT_ON_CLOSE);   }   public void actionPerformed( ActionEvent e ) {      count++;   // increment counter      tally.setText(Integer.toString(count));   }   public static void main(String args [] ) {         new CountButtonPushes();   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -