test.java

来自「java菜单设计小例子」· Java 代码 · 共 51 行

JAVA
51
字号

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Test extends JApplet implements ActionListener
{
	UseFan f; 
	JButton BtStart;
	JButton BtStop;
	JButton BtReverse;
	public static Scrollbar srb = new Scrollbar(Scrollbar.HORIZONTAL,100,100,100,1000);
	public void init()
	{
		JPanel p = new JPanel();
		BtStart = new JButton("Start");
		BtStop = new JButton("Stop");
		BtReverse = new JButton("Reverse");
		p.setLayout(new FlowLayout(FlowLayout.LEFT));
		p.add(BtStart);
		p.add(BtStop);
		p.add(BtReverse);
		f = new UseFan();
		getContentPane().add(p,BorderLayout.NORTH);
		getContentPane().add(f,BorderLayout.CENTER);
		getContentPane().add(srb,BorderLayout.SOUTH);
		BtStart.addActionListener(this);
		BtStop.addActionListener(this);
		BtReverse.addActionListener(this);
	}

	public void actionPerformed(ActionEvent e)
	{
		if (e.getSource() == BtStart)
		{
			f.resume();
		}
		else if (e.getSource() == BtStop)
		{
			f.suspend();
		}
		else if (e.getSource() == BtReverse)
		{
			f.reverse();
		}
	}
	public static void main(String[] args)
   {
      Test fancontrol = new Test();     
   }
}

⌨️ 快捷键说明

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