Hello,
I'm trying to create an application that when you click on a button, it just displays a string but it doesnt work. Here's the code:
import java.io.*;
import java.awt.*;
import java.applet.Applet;
import java.awt.Graphics;
import java.awt.event.*;
public class main extends Applet {
TextField input;
Button convert;
public void init () {
// Construct the TextFields
input = new TextField(10);
convert = new Button ("Convert");
//Button b = new Button("Submit");
add(input);
add(convert);
convert.addActionListener(null);
}
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == convert)
{
paint();
}
}
public void paint(Graphics g)
{
g.drawString ("Hello", getWidth()/2, getHeight()/2);
}
}
Any ideas? Thanks