Pleeeeeeeeeeeeeeeeeeeeeeeeeeeeease look at the actionPerformed... I gave you
all the code just in case, but the main problem is there.
I am new and I cannot solve it nor have an idea of what is going on.
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;
/*<applet
code=hpm.class
width=200
height=200
></applet>*/
public class hpm extends Applet implements ActionListener
{
public TextField valorb, valorm, resultado;
public Label label1;
public Button botonok;
GridBagLayout gridbag;
GridBagConstraints constraints;
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == botonok) {
/*this is the problem. Why I am not able to create a new TextField at
runtime? Also, is it ok the way I add it to the GridBagLayout ?
Thanks a lot */
resultado = new TextField("Calculando...");
resultado.setFont(new Font("Verdana", Font.BOLD, 10));
resultado.setText("Valor de XXXX");
constraints.gridwidth = GridBagConstraints.SOUTH;
constraints.weighty = 1;
gridbag.setConstraints(resultado, constraints);
add(resultado);
}
}
public void init()
{
setBackground(Color.black);
setForeground(Color.white);
gridbag = new GridBagLayout();
constraints = new GridBagConstraints();
setLayout(gridbag);
constraints.gridwidth = GridBagConstraints.WEST;
constraints.weighty = 1;
label1 = new Label();
label1.setFont(new Font("Verdana", Font.BOLD, 10));
label1.setText("Valor de M");
gridbag.setConstraints(label1, constraints);
add(label1);
valorm = new TextField();
valorm.setColumns(15);
valorm.setForeground(Color.yellow);
constraints.gridwidth = GridBagConstraints.EAST;
constraints.weighty = 1;
gridbag.setConstraints(valorm, constraints);
add(valorm);
constraints.gridwidth = GridBagConstraints.WEST;
label1 = new Label();
label1.setFont(new Font("Verdana", Font.BOLD, 10));
label1.setText("Valor de B");
constraints.weighty = 1;
gridbag.setConstraints(label1, constraints);
add(label1);
valorb = new TextField();
valorb.setColumns(15);
valorb.setForeground(Color.yellow);
constraints.gridwidth = GridBagConstraints. EAST;
constraints.weighty = 1;
gridbag.setConstraints(valorb, constraints);
add(valorb);
botonok = new Button("Calcular");
constraints.gridwidth = GridBagConstraints.SOUTH;
gridbag.setConstraints(botonok, constraints);
add(botonok);
botonok.addActionListener(this);
}
}
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]