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

📄 ballcontrol.java

📁 JAVA程序设计导论那本书上的一些源代码. 在学那本书的下来的
💻 JAVA
字号:
import javax.swing.*;import java.awt.event.*;import java.awt.*;public class BallControl extends JPanel    implements ActionListener, AdjustmentListener {  private Ball ball = new Ball();  private JButton jbtSuspend = new JButton("Suspend");  private JButton jbtResume = new JButton("Resume");  private JScrollBar jsbDelay = new JScrollBar();  public BallControl() {    // Group buttons in a panel    JPanel panel = new JPanel();    panel.add(jbtSuspend);    panel.add(jbtResume);    // Add ball and buttons to the panel    ball.setBorder(new javax.swing.border.LineBorder(Color.red));    jsbDelay.setOrientation(JScrollBar.HORIZONTAL);    ball.setDelay(jsbDelay.getMaximum());    setLayout(new BorderLayout());    add(jsbDelay, BorderLayout.NORTH);    add(ball, BorderLayout.CENTER);    add(panel, BorderLayout.SOUTH);    // Register listeners    jbtSuspend.addActionListener(this);    jbtResume.addActionListener(this);    jsbDelay.addAdjustmentListener(this);  }  public void actionPerformed(ActionEvent e) {    if (e.getSource() == jbtSuspend)      ball.suspend();    else if (e.getSource() == jbtResume)      ball.resume();  }  public void adjustmentValueChanged(AdjustmentEvent e) {    ball.setDelay(jsbDelay.getMaximum() - e.getValue());  }}

⌨️ 快捷键说明

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