要有界面的。
解决方案 »
- 一道排序题,满分奉上,不难!急用 谢谢
- java经典题
- JAVA里如何将Long转为Integer
- 我已经放弃了,哪位大虾,推荐一个 简体中文的 JAVA 开源 的 BBS
- JAVA 中如何实现点击按钮,执行我做好的帮助文件
- 救命啊,一个XML设置编码的问题,大家帮我看看啊,痛苦不堪。。。。。。
- 写一java 程序,在运行时,让所有的键盘控制键(诸如,Ctrl,Alt 等)输入无效,用户只能输字母与数字,How to ?
- Applet问题,特别简单(这两句有什么不同)
- 请教一个Swing的窗口开发技术问题.
- jdbc驱动的位置?
- 新手安装Eclipse和JRE遇到得问题?
- 一个通讯接口的问题(回答者有分)
* Created on 2005-7-22
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*//**
* @author Administrator
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;public class FibonacciTest extends JApplet implements ActionListener {
JLabel numLabel, resultLabel;
JTextField num, result;
public void init()
{
Container c = getContentPane();
c.setLayout( new FlowLayout());
numLabel = new JLabel ( " Enter integer and press Enter" );
c.add(numLabel);
num = new JTextField ( 10 );
num.addActionListener( this );
c.add( num );
resultLabel = new JLabel ( "Fibonacci Value is" );
c.add(resultLabel);
result = new JTextField ( 15 );
result.setEditable( false );
c.add ( result );
}
public void actionPerformed ( ActionEvent e )
{
long number, fibonacciValue;
number = Long.parseLong(num.getText());
showStatus( "Calculating...");
fibonacciValue = fibonacci( number );
showStatus( "done.");
result.setText( Long.toString(fibonacciValue));
}
public long fibonacci (long n)
{
if( n == 0 || n == 1 )
return n;
else
return fibonacci( n - 1 ) + fibonacci( n - 2 );
}
}