有人可以帮我处理评论行,除了它要求删除的那些。谢谢!
public class ex1011c extends JApplet implements ActionListener
{
// get rid of all winkbutton code
JButton winkbutton = new JButton("Wink At You");
boolean wink = false, first = true;
Container c;
public void init()
{
c = getContentPane();
c.setLayout(new FlowLayout());
c.setBackground(Color.blue);
winkbutton.setForeground(Color.cyan);
c.add(winkbutton);
winkbutton.addActionListener(this);
}
// get rid of actionPerformed
public void actionPerformed(ActionEvent e)
{
wink = !wink;
repaint();
}
public void paint(Graphics g)
{
/* if first time, draw the face and non winking eye,
set first to false */
super.paint(g);
g.setColor(Color.yellow);
g.fillOval(50, 50, 100, 100);
g.setColor(Color.black);
g.fillOval(85, 80, 10, 20);
/* cover just the eye that winks (if winking or not, but do not
cover anything else), switch the wink boolean */
// draw the full eye or winking eye
if (wink)
g.fillOval(105, 88, 10, 5);
else
g.fillOval(105, 80, 10, 20);
// go to sleep for a second
// call repaint
}
// override update to lesson flicker
}