package processing1;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import processing.core.PApplet;
public class estrela2 extends PApplet implements ActionListener{
float r, ang;
// tipos do AWT
Button okButton;
Button wrongButton;
TextField nameField;
public void setup()
{
size(400, 400); // define o tamnho da tela
background(255); // define a cor de fundo como branco
r = min(width,height) / 2 * 0.9f;
ang = 0;
//
setLayout(new FlowLayout());
okButton = new Button("Action!");
wrongButton = new Button("Don't click!");
nameField = new TextField("Type here Something",35);
//
add(okButton);
add(wrongButton);
add(nameField);
//
// Attach actions to the components
okButton.addActionListener(this);
wrongButton.addActionListener(this);
}
public void draw()
{
background(255);
star(r, 5, 3, ang);
ang += 0.01f;
}
public void actionPerformed(ActionEvent evt)
{
if (evt.getSource() == okButton){
nameField.setText("OK button!");
repaint();
}
if (evt.getSource() == wrongButton){
nameField.setText("Wrong button!");
repaint();
}
}
Thursday, November 19, 2009
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment