Bom dia!
Galera preciso de uma ideia para clacular este botão, pois não consigo realizar um calculo por tras!
Seria bem simples n1*n2/10…porem nao sei o comando.
Alguem poderia me ajudar!!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class button extends JPanel {
private JButton cal;
private JTextField n1;
private JLabel jcomp3;
private JLabel jcomp4;
private JTextField n2;
private JLabel res;
private JTextField resul;
public button() {
//construct components
cal = new JButton ("Calcular");
n1 = new JTextField (5);
jcomp3 = new JLabel ("nota1");
jcomp4 = new JLabel ("nota2");
n2 = new JTextField (5);
res = new JLabel ("Resultado");
resul = new JTextField (5);
//adjust size and set layout
setPreferredSize (new Dimension (624, 531));
setLayout (null);
//add components
add (cal);
add (n1);
add (jcomp3);
add (jcomp4);
add (n2);
add (res);
add (resul);
//set component bounds (only needed by Absolute Positioning)
cal.setBounds (155, 125, 140, 20);
n1.setBounds (40, 75, 100, 25);
jcomp3.setBounds (70, 40, 100, 25);
jcomp4.setBounds (195, 40, 100, 25);
n2.setBounds (160, 75, 100, 25);
res.setBounds (290, 40, 100, 25);
resul.setBounds (280, 75, 100, 25);
}
public static void main (String[] args) {
JFrame frame = new JFrame ("Botao");
frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add (new button());
frame.pack();
frame.setVisible (true);
}
}
