Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- public class MultiplicaSenhor extends JFrame implements ActionListener{
- JButton limpar = new JButton("Limpar");
- JButton calcular = new JButton("Calcular");
- JButton soma = new JButton("+");
- JButton subt = new JButton("-");
- JButton mult = new JButton("*");
- JButton divi = new JButton("/");
- JTextField login = new JTextField();
- JTextField senha = new JTextField();
- JTextField resul = new JTextField();
- public MultiplicaSenhor() {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setSize(500,400);
- setTitle("Ela que me diz.."); // PROPRIEDADES DA JANELA
- setResizable(false);
- getContentPane().setLayout(null);
- soma.setBounds(70, 195, 50, 20);
- getContentPane().add(soma);
- soma.addActionListener(new Soma());
- subt.setBounds(130, 195, 50, 20);
- getContentPane().add(subt);
- // subt.addActionListener(new Sub());
- //OPERADORES
- mult.setBounds(190, 195, 50, 20);
- getContentPane().add(mult);
- mult.addActionListener(this);
- divi.setBounds(250, 195, 50, 20);
- getContentPane().add(divi);
- divi.addActionListener(this);
- login.setBounds(120, 145, 140, 20);
- getContentPane().add(login);
- senha.setBounds(120, 170, 140, 20);
- getContentPane().add(senha); //CAIXAS DE TEXTO
- resul.setBounds(120, 220, 140, 20);
- getContentPane().add(resul);
- calcular.setBounds(135, 320, 100, 20);
- getContentPane().add(calcular);
- calcular.addActionListener(new Somou());
- calcular.setEnabled(false);
- //BOTÕES
- limpar.setBounds(135, 350, 100, 20);
- getContentPane().add(limpar);
- limpar.addActionListener(this);
- }
- public static void main(String[] args) {
- MultiplicaSenhor janela = new MultiplicaSenhor();
- janela.setVisible(true);
- janela.show();
- }
- //public void actionPerformed(ActionEvent acao) {
- //soma() {
- class Soma implements ActionListener{
- public void actionPerformed(ActionEvent ev) {
- calcular.setEnabled(true);
- }
- }
- class Somou implements ActionListener {
- public void actionPerformed(ActionEvent ac) {
- double num1 = Double.parseDouble(login.getText());
- double num2 = Double.parseDouble(senha.getText());
- double result = num1 + num2;
- resul.setText(""+result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement