// Hi, Will someone kindly take a peek at the code below, corrrect it and let me know why this simple applet does not work.
// All I am trying to do is, as the buttons are pressed, 1000 to increment or decrement accordingly. Thank you for your time.
import java.applet.*; import java.awt.*; import javax.swing.*; import java.awt.event.*;
public class button2 extends Applet implements ActionListener{
Button increase, decrease;
int value = 1000;
public void init (){
increase = new Button("Increase the value");
add(increase);
decrease = new Button("Decrease the value");
add(decrease);
}
public void actionPerformed( ActionEvent e) {
Object obj = e.getSource( );
if (obj == increase)
value++;
if (obj == decrease)
value--;
repaint();
}
public void paint (Graphics g){
g.drawString("The value is currently " + value, 50, 80);
}
}