Ah! Esquecí de postar o código.
import java.awt.<em>;
import java.awt.event.</em>;
import javax.swing.*;
public class Sorveteria extends JFrame implements ActionListener
{
JLabel L1,L2,L3,L4,L5,L6,L7,L8;
JTextField T1,T2,T3,T4,T5,T6,T7,T8,T9;
JButton B1,B2;
JPasswordField P1;
public static void main(String[] args)
{
JFrame sorveteria = new Sorveteria();
sorveteria.setUndecorated(true);
sorveteria.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
sorveteria.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
sorveteria.setVisible(true);
}
public Sorveteria()
{
setTitle("Sorveteria");
setBounds(350,400,500,150);
getContentPane().setBackground(new Color(150,150,150));
getContentPane().setLayout(new GridLayout( 6,8 ));
L1= new JLabel("Tipo de Sorvete");
L1.setForeground(Color.black);
L1.setFont(new Font("",Font.BOLD,14));
L2= new JLabel("QTDE");
L2.setForeground(Color.black);
L2.setFont(new Font("",Font.BOLD,14));
L3= new JLabel("Preço Unitário");
L3.setForeground(Color.black);
L3.setFont(new Font("",Font.BOLD,14));
L4= new JLabel("Picolé Frutas");
L4.setForeground(Color.black);
L4.setFont(new Font("",Font.BOLD,14));
L5= new JLabel("Chocolate/Frutas");
L5.setForeground(Color.black);
L5.setFont(new Font("",Font.BOLD,14));
L6= new JLabel("Bola");
L6.setForeground(Color.black);
L6.setFont(new Font("",Font.BOLD,14));
L7= new JLabel("Pote de 2 Litros");
L7.setForeground(Color.black);
L7.setFont(new Font("",Font.BOLD,14));
L8= new JLabel("Total");
L8.setForeground(Color.red);
L8.setFont(new Font("",Font.BOLD,14));
B1= new JButton("Calcular"); B1.addActionListener(this);
B2= new JButton("Limpar"); B2.addActionListener(this);
T1= new JTextField();
T2= new JTextField();
T3= new JTextField();
T4= new JTextField();
T5= new JTextField();
T6= new JTextField();
T7= new JTextField();
T8= new JTextField();
T9= new JTextField();
add( L1 ); add( T1 );
add( L2 ); add( T2 );
add( L3 ); add( T3 );
add( L4 ); add( T4 );
add( L5 ); add( T5 );
add( L6 ); add( T6 );
add( L7 ); add( T7 );
add( L8 ); add( T8 );
add( T9 ); add( B1 );
add( B2 );
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource()==B2)
{
T1.setText("");
T2.setText("");
T3.setText("");
T4.setText("");
T5.setText("");
T6.setText("");
T7.setText("");
T8.setText("");
T9.setText("");
return;
}
float N1=0, N2=0, N3=0, N4=0, N5=0, N6=0, N7=0, N8=0, Total=0;
try
{
N1=Float.parseFloat(T1.getText());
N2=Float.parseFloat(T2.getText());
N3=Float.parseFloat(T3.getText());
N4=Float.parseFloat(T4.getText());
N5=Float.parseFloat(T5.getText());
N6=Float.parseFloat(T6.getText());
N7=Float.parseFloat(T7.getText());
N8=Float.parseFloat(T8.getText());
}
catch(NumberFormatException erro)
{
T9.setText("Erro!");
return;
}
if (e.getSource()==B1) Total=( N1*N2 )+( N3*N4 )+( N5*N6 )+( N7*N8 );
T9.setText(""+Total);
}
}