public class FibonacciTest extends JApplet
implements ActionListener {
JLabel numberLabel, resultLabel;
JTextField numberField, resultField;
// set up applet?s GUI
public void init()
{
// obtain content pane and set its layout to FlowLayout
Container container = getContentPane();
container.setLayout( new FlowLayout() );
// create numberLabel and attach it to content pane
numberLabel =
new JLabel( "Enter an integer and press Enter" );
container.add( numberLabel );
// create numberField and attach it to content pane
numberField = new JTextField( 10 );
container.add( numberField );
// register this applet as numberField?s ActionListener
numberField.addActionListener( this );
// create resultLabel and attach it to content pane
resultLabel = new JLabel( "Fibonacci value is" );
container.add( resultLabel );
// create numberField, make it uneditable
// and attach it to content pane
resultField = new JTextField( 15 );
resultField.setEditable( false );
container.add( resultField );
} // end method init
JLabel numberLabel, resultLabel;
JTextField numberField, resultField;
nao poderia ser feito dentro do metodo init() assim.. JTextField numberFiled = new JTextFiled; ?????
e por que isso é feito antes??
Obrigado!
