I wrote this simple java program to test the repaint mechanism in Java for my Eclipse IDE (not that it works on XCode either). The repaint() mechanism is not repainting, it does not erase the code previous to it in the graphic. It should according to everything I've read. Help if you can. Thanks.
import java.awt.*;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
public class pp2 extends JApplet implements ActionListener
{
JButton clearButton;
int i;
String output;
public void init()
{
clearButton = new JButton("Clear");
Container c = getContentPane();
c.setLayout(new FlowLayout());
c.add(clearButton);
clearButton.addActionListener(this);
i = 1;
}
public void actionPerformed(ActionEvent e)
{
if ((i%2)!=0)
output = "I is odd";
else
output = "I is even";
i++;
repaint();
}
public void paint(Graphics g)
{
g.drawString(output, 50, 50);
}
}