Código não executa

Boa noite, gente!
Meu código não está executando, e eu não sei porquê. Apenas ocorre isso se eu utilizo 2 classes, se botar tudo em uma só isso não acontece.

Code que não executa:
<package view;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;

public class TelaCalc extends JFrame {
// Autor: - | Data: 2/11/2020 | Hora: 7 : 30

private static final long serialVersionUID = 1L;
private JPanel contentPane;
public JTextField txtNumber1;
public JTextField txtNumber1_;
public JTextField txtResult1;
public JTextField txtResult2;
public JTextField txtNumber2_;
public JTextField txtNumber2;
public JTextField txtResult3;
public JTextField txtNumber3_;
public JTextField txtNumber3;
public JTextField txtResult4;
public JTextField txtNumber4_;
public JTextField txtNumber4;

/**
 * Launch the application.
 */
public static void main(String[] args) {

	EventQueue.invokeLater(new Runnable() {
		public void run() {
			try {
				TelaCalc frame = new TelaCalc();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
}

public TelaCalc() {
	
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 527, 374);
	contentPane = new JPanel();
	contentPane.setForeground(new Color(112, 128, 144));
	contentPane.setBackground(new Color(0, 128, 128));
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);

	// LABELS
	JLabel lblNumber1 = new JLabel("Enter numbers:");
	lblNumber1.setBounds(70, 11, 138, 22);
	lblNumber1.setForeground(new Color(255, 255, 255));
	lblNumber1.setFont(new Font("Tahoma", Font.PLAIN, 18));
	contentPane.add(lblNumber1);

	JLabel lblNewLabel = new JLabel("+");
	lblNewLabel.setBounds(196, 70, 27, 14);
	lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
	contentPane.add(lblNewLabel);

	JLabel lblEqual = new JLabel(" = ");
	lblEqual.setBounds(335, 70, 16, 14);
	contentPane.add(lblEqual);

	JLabel lblEqual_1 = new JLabel(" = ");
	lblEqual_1.setBounds(335, 118, 16, 14);
	contentPane.add(lblEqual_1);

	JLabel lblNewLabel_1 = new JLabel("-");
	lblNewLabel_1.setBounds(196, 118, 27, 14);
	lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 13));
	contentPane.add(lblNewLabel_1);

	JLabel lblEqual_2 = new JLabel(" = ");
	lblEqual_2.setBounds(335, 168, 16, 14);
	contentPane.add(lblEqual_2);

	JLabel lblNewLabel_2 = new JLabel("x");
	lblNewLabel_2.setBounds(196, 168, 27, 14);
	lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 13));
	contentPane.add(lblNewLabel_2);

	JLabel lblEqual_3 = new JLabel(" = ");
	lblEqual_3.setBounds(335, 216, 16, 14);
	contentPane.add(lblEqual_3);

	JLabel lblNewLabel_3 = new JLabel("/");
	lblNewLabel_3.setBounds(196, 216, 27, 14);
	lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 13));
	contentPane.add(lblNewLabel_3);

	// TextBoxs
	// Caixas editaveis

	txtNumber1 = new JTextField();
	txtNumber1.setBounds(70, 63, 97, 27);
	txtNumber1.setFont(new Font("Tahoma", Font.PLAIN, 13));
	contentPane.add(txtNumber1);
	txtNumber1.setColumns(10);
	txtNumber1.setDocument(new JustNumbers());

	txtNumber1_ = new JTextField();
	txtNumber1_.setBounds(228, 63, 97, 27);
	txtNumber1_.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber1_.setColumns(10);
	contentPane.add(txtNumber1_);
	txtNumber1_.setDocument(new JustNumbers()); // Aceita apenas numbers

	txtNumber2 = new JTextField();
	txtNumber2.setBounds(70, 111, 97, 27);
	txtNumber2.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber2.setColumns(10);
	contentPane.add(txtNumber2);
	txtNumber2.setDocument(new JustNumbers());

	txtNumber2_ = new JTextField();
	txtNumber2_.setBounds(228, 111, 97, 27);
	txtNumber2_.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber2_.setColumns(10);
	contentPane.add(txtNumber2_);
	txtNumber2_.setDocument(new JustNumbers());

	txtNumber3 = new JTextField();
	txtNumber3.setBounds(70, 161, 97, 27);
	txtNumber3.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber3.setColumns(10);
	contentPane.add(txtNumber3);
	txtNumber3.setDocument(new JustNumbers());

	txtNumber3_ = new JTextField();
	txtNumber3_.setBounds(228, 161, 97, 27);
	txtNumber3_.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber3_.setColumns(10);
	contentPane.add(txtNumber3_);
	txtNumber3_.setDocument(new JustNumbers());

	txtNumber4 = new JTextField();
	txtNumber4.setBounds(70, 209, 97, 27);
	txtNumber4.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber4.setColumns(10);
	contentPane.add(txtNumber4);
	txtNumber4.setDocument(new JustNumbers());

	txtNumber4_ = new JTextField();
	txtNumber4_.setBounds(228, 209, 97, 27);
	txtNumber4_.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber4_.setColumns(10);
	contentPane.add(txtNumber4_);
	txtNumber4_.setDocument(new JustNumbers());

	// Resultados

	txtResult1 = new JTextField();
	txtResult1.setBounds(361, 63, 97, 27);
	txtResult1.setBackground(Color.DARK_GRAY);
	txtResult1.setEnabled(false);
	txtResult1.setForeground(Color.WHITE);
	txtResult1.setFont(new Font("Tahoma", Font.PLAIN, 15));
	txtResult1.setColumns(10);
	contentPane.add(txtResult1);

	txtResult2 = new JTextField();
	txtResult2.setBounds(361, 111, 97, 27);
	txtResult2.setBackground(Color.DARK_GRAY);
	txtResult2.setEnabled(false);
	txtResult2.setForeground(Color.RED);
	txtResult2.setFont(new Font("Tahoma", Font.PLAIN, 15));
	txtResult2.setColumns(10);
	contentPane.add(txtResult2);

	txtResult3 = new JTextField();
	txtResult3.setBounds(361, 161, 97, 27);
	txtResult3.setBackground(Color.DARK_GRAY);
	txtResult3.setEnabled(false);
	txtResult3.setForeground(Color.RED);
	txtResult3.setFont(new Font("Tahoma", Font.PLAIN, 15));
	txtResult3.setColumns(10);
	contentPane.add(txtResult3);

	txtResult4 = new JTextField();
	txtResult4.setBounds(361, 209, 97, 27);
	txtResult4.setBackground(Color.DARK_GRAY);
	txtResult4.setEnabled(false);
	txtResult4.setForeground(Color.RED);
	txtResult4.setFont(new Font("Tahoma", Font.PLAIN, 15));
	txtResult4.setColumns(10);
	contentPane.add(txtResult4);

	
	SecClass sc = new SecClass(); // Instanciando a classe
	
	JButton btnSum = new JButton("Calc");
	btnSum.setBounds(129, 294, 89, 28);
	btnSum.setFont(new Font("Tahoma", Font.PLAIN, 13));
	btnSum.setForeground(new Color(255, 255, 255));
	btnSum.setBackground(new Color(105, 105, 105));
	btnSum.addActionListener(new ActionListener() {

		public void actionPerformed(ActionEvent e) {
			sc.soma();
			sc.min();
			sc.mul();
			sc.div();
			
			txtResult1.setText(String.valueOf(sc.soma())); //Imprime o numero da soma dentro da TxtBox
			txtResult2.setText(String.valueOf(sc.min()));
			txtResult3.setText(String.valueOf(sc.mul()));
			txtResult4.setText(String.valueOf(sc.div()));
		}
	});
	contentPane.add(btnSum);

	JButton btnClean = new JButton("Clean");
	btnClean.setBounds(284, 294, 89, 28);
	btnClean.setFont(new Font("Tahoma", Font.PLAIN, 13));
	btnClean.setForeground(new Color(255, 245, 238));
	btnClean.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			
			sc.LimparCache(); //Metodo que limpa os campos
		}
	});
	btnClean.setBackground(new Color(112, 128, 144));
	contentPane.add(btnClean);
}

}>

Código sem erro (feio):
<package view;

import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Color;

public class TelaCalc extends JFrame {
//Autor: - | Data: 31/10/2020

private static final long serialVersionUID = 1L;
private JPanel contentPane;
private JTextField txtNumber1;
private JTextField txtNumber1_;
private JTextField txtResult1;
private JTextField txtResult2;
private JTextField txtNumber2_;
private JTextField txtNumber2;
private JTextField txtResult3;
private JTextField txtNumber3_;
private JTextField txtNumber3;
private JTextField txtResult4;
private JTextField txtNumber4_;
private JTextField txtNumber4;

/**
 * Launch the application.
 */
public static void main(String[] args) {
	
	EventQueue.invokeLater(new Runnable() {
		public void run() {
			try {
				TelaCalc frame = new TelaCalc();
				frame.setVisible(true);
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
}

public TelaCalc() {
	setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	setBounds(100, 100, 527, 374);
	contentPane = new JPanel();
	contentPane.setForeground(new Color(112, 128, 144));
	contentPane.setBackground(new Color(0, 128, 128));
	contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
	setContentPane(contentPane);
	contentPane.setLayout(null);
	
	// LABELS
	JLabel lblNumber1 = new JLabel("Enter numbers:");
	lblNumber1.setForeground(new Color(255, 255, 255));
	lblNumber1.setFont(new Font("Tahoma", Font.PLAIN, 18));
	lblNumber1.setBounds(70, 11, 138, 22);
	contentPane.add(lblNumber1);
	
	JLabel lblNewLabel = new JLabel("+");
	lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
	lblNewLabel.setBounds(196, 70, 27, 14);
	contentPane.add(lblNewLabel);
	
	JLabel lblEqual = new JLabel(" = ");
	lblEqual.setBounds(335, 70, 16, 14);
	contentPane.add(lblEqual);
	
	JLabel lblEqual_1 = new JLabel(" = ");
	lblEqual_1.setBounds(335, 118, 16, 14);
	contentPane.add(lblEqual_1);
	
	JLabel lblNewLabel_1 = new JLabel("-");
	lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 13));
	lblNewLabel_1.setBounds(196, 118, 27, 14);
	contentPane.add(lblNewLabel_1);
	
	JLabel lblEqual_2 = new JLabel(" = ");
	lblEqual_2.setBounds(335, 168, 16, 14);
	contentPane.add(lblEqual_2);
	
	JLabel lblNewLabel_2 = new JLabel("x");
	lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 13));
	lblNewLabel_2.setBounds(196, 168, 27, 14);
	contentPane.add(lblNewLabel_2);
	
	JLabel lblEqual_3 = new JLabel(" = ");
	lblEqual_3.setBounds(335, 216, 16, 14);
	contentPane.add(lblEqual_3);
	
	JLabel lblNewLabel_3 = new JLabel("/");
	lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 13));
	lblNewLabel_3.setBounds(196, 216, 27, 14);
	contentPane.add(lblNewLabel_3);
	
	// TextBoxs
	// Caixas editaveis
	
	txtNumber1 = new JTextField();
	txtNumber1.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber1.setBounds(70, 63, 97, 27);
	contentPane.add(txtNumber1);
	txtNumber1.setColumns(10);
	txtNumber1.setDocument(new JustNumbers());
	
	txtNumber1_ = new JTextField();
	txtNumber1_.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber1_.setColumns(10);
	txtNumber1_.setBounds(228, 63, 97, 27);
	contentPane.add(txtNumber1_);
	txtNumber1_.setDocument(new JustNumbers()); //Aceita apenas numbers
	
	txtNumber2 = new JTextField();
	txtNumber2.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber2.setColumns(10);
	txtNumber2.setBounds(70, 111, 97, 27);
	contentPane.add(txtNumber2);
	txtNumber2.setDocument(new JustNumbers());
	
	txtNumber2_ = new JTextField();
	txtNumber2_.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber2_.setColumns(10);
	txtNumber2_.setBounds(228, 111, 97, 27);
	contentPane.add(txtNumber2_);
	txtNumber2_.setDocument(new JustNumbers());
	
	txtNumber3 = new JTextField();
	txtNumber3.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber3.setColumns(10);
	txtNumber3.setBounds(70, 161, 97, 27);
	contentPane.add(txtNumber3);
	txtNumber3.setDocument(new JustNumbers());
	
	txtNumber3_ = new JTextField();
	txtNumber3_.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber3_.setColumns(10);
	txtNumber3_.setBounds(228, 161, 97, 27);
	contentPane.add(txtNumber3_);
	txtNumber3_.setDocument(new JustNumbers());
	
	txtNumber4 = new JTextField();
	txtNumber4.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber4.setColumns(10);
	txtNumber4.setBounds(70, 209, 97, 27);
	contentPane.add(txtNumber4);
	txtNumber4.setDocument(new JustNumbers());
	
	txtNumber4_ = new JTextField();
	txtNumber4_.setFont(new Font("Tahoma", Font.PLAIN, 13));
	txtNumber4_.setColumns(10);
	txtNumber4_.setBounds(228, 209, 97, 27);
	contentPane.add(txtNumber4_);
	txtNumber4_.setDocument(new JustNumbers());
	
	// Resultados
	
	txtResult1 = new JTextField();
	txtResult1.setBackground(Color.DARK_GRAY);
	txtResult1.setEnabled(false);
	txtResult1.setForeground(Color.WHITE);
	txtResult1.setFont(new Font("Tahoma", Font.PLAIN, 15));
	txtResult1.setColumns(10);
	txtResult1.setBounds(361, 63, 97, 27);
	contentPane.add(txtResult1);
	
	txtResult2 = new JTextField();
	txtResult2.setBackground(Color.DARK_GRAY);
	txtResult2.setEnabled(false);
	txtResult2.setForeground(Color.RED);
	txtResult2.setFont(new Font("Tahoma", Font.PLAIN, 15));
	txtResult2.setColumns(10);
	txtResult2.setBounds(361, 111, 97, 27);
	contentPane.add(txtResult2);
	
	txtResult3 = new JTextField();
	txtResult3.setBackground(Color.DARK_GRAY);
	txtResult3.setEnabled(false);
	txtResult3.setForeground(Color.RED);
	txtResult3.setFont(new Font("Tahoma", Font.PLAIN, 15));
	txtResult3.setColumns(10);
	txtResult3.setBounds(361, 161, 97, 27);
	contentPane.add(txtResult3);
	
	txtResult4 = new JTextField();
	txtResult4.setBackground(Color.DARK_GRAY);
	txtResult4.setEnabled(false);
	txtResult4.setForeground(Color.RED);
	txtResult4.setFont(new Font("Tahoma", Font.PLAIN, 15));
	txtResult4.setColumns(10);
	txtResult4.setBounds(361, 209, 97, 27);
	contentPane.add(txtResult4);
	
	// Botoes
	JButton btnSum = new JButton("Calc");
	btnSum.setFont(new Font("Tahoma", Font.PLAIN, 13));
	btnSum.setForeground(new Color(255, 255, 255));
	btnSum.setBackground(new Color(105, 105, 105));
	btnSum.addActionListener(new ActionListener() {
		
		public void actionPerformed(ActionEvent e) {
			
			String a = txtNumber1.getText(); 
			String b = txtNumber1_.getText();
			String f = txtNumber2.getText(); 
			String g = txtNumber2_.getText();
			String j = txtNumber3.getText(); 
			String k = txtNumber3_.getText();
			String n = txtNumber4.getText(); 
			String o = txtNumber4_.getText();
			
			double c = Integer.parseInt(a);
			double d = Integer.parseInt(b);
			double h = Integer.parseInt(f);
			double i = Integer.parseInt(g);
			double l = Integer.parseInt(j);
			double m = Integer.parseInt(k);
			double p = Integer.parseInt(n);
			double q = Integer.parseInt(o);
			
			double soma  = c + d;
			double min = h - i;
			double mul = l * m;
			double div = p / q;
			
			txtResult1.setText(String.valueOf(soma)); //Imprime o numero da soma dentro da TxtBox
			txtResult2.setText(String.valueOf(min));
			txtResult3.setText(String.valueOf(mul));
			txtResult4.setText(String.valueOf(div));
			
		}
	});
	
	btnSum.setBounds(129, 294, 89, 28);
	contentPane.add(btnSum);
	
	JButton btnClean = new JButton("Clean");
	btnClean.setFont(new Font("Tahoma", Font.PLAIN, 13));
	btnClean.setForeground(new Color(255, 245, 238));
	btnClean.addActionListener(new ActionListener() {
		public void actionPerformed(ActionEvent e) {
			
			txtResult1.setText(String.valueOf(""));
			txtResult2.setText(String.valueOf(""));
			txtResult3.setText(String.valueOf(""));
			txtResult4.setText(String.valueOf(""));
			txtNumber1.setText(String.valueOf(""));
			txtNumber1_.setText(String.valueOf(""));
			txtNumber2.setText(String.valueOf(""));
			txtNumber2_.setText(String.valueOf(""));
			txtNumber3.setText(String.valueOf(""));
			txtNumber3_.setText(String.valueOf(""));
			txtNumber4.setText(String.valueOf(""));
			txtNumber4_.setText(String.valueOf(""));

		}
	});
	btnClean.setBackground(new Color(112, 128, 144));
	btnClean.setBounds(284, 294, 89, 28);
	contentPane.add(btnClean);
	
}	

}>

Espero que alguém me ajude.

Salve amigo, sou iniciante e to so olhando aqui, nao entendi public TelaCalc(), se isso for uma função falta o retorno void, Quando tiver em casa vou abrir no pc pra testae

1 curtida

É o construtor padrão da classe TelaCalc. :wink:

Você esqueceu de postar o código das classes SecClass e JustNumbers. :man_shrugging:

package view;

public class SecClass {

	TelaCalc tl = new TelaCalc();
	
	String a = tl.txtNumber1.getText();
	String b = tl.txtNumber1_.getText();
	String f = tl.txtNumber2.getText();
	String g = tl.txtNumber2_.getText();
	String j = tl.txtNumber3.getText();
	String k = tl.txtNumber3_.getText();
	String n = tl.txtNumber4.getText();
	String o = tl.txtNumber4_.getText();
	
	double c = Integer.parseInt(a);
	double d = Integer.parseInt(b);
	double h = Integer.parseInt(f);
	double i = Integer.parseInt(g);
	double l = Integer.parseInt(j);
	double m = Integer.parseInt(k);
	double p = Integer.parseInt(n);
	double q = Integer.parseInt(o);
	
	//Metodos
	public double soma() {
		return c + d;
	}
	
	public double min() {
		return h - i;
	}
	
	public double mul() {
		return l * m;
	}
	
	public double div() {
		return p / q;
	}
		
	public void LimparCache() {
		
		tl.txtResult1.setText("");
		tl.txtResult2.setText("");
		tl.txtResult3.setText("");
		tl.txtResult4.setText("");
		tl.txtNumber1.setText("");
		tl.txtNumber1_.setText("");
		tl.txtNumber2.setText("");
		tl.txtNumber2_.setText("");
		tl.txtNumber3.setText("");
		tl.txtNumber3_.setText("");
		tl.txtNumber4.setText("");
		tl.txtNumber4_.setText("");
	}
	
}
package view;

import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;

public class JustNumbers extends PlainDocument {

/**
 * 
 */
private static final long serialVersionUID = 1L;


	@Override
	public void insertString(int offs, String str, AttributeSet a) throws BadLocationException {
		super.insertString(offs, str.replaceAll("[^0-9]", ""), a);
	}

}
//Essa classe faz com que o text Box só aceitar numeros

Você está criando outro objeto da TelaCalc dentro da classe SecClass.
Não pode, você tem que usar o mesmo objeto da TelaCalc que foi instanciado no seu método main.

Veja seus códigos refatorados:

package view;

public class SecClass {

    final TelaCalc tela;

    public SecClass(TelaCalc tl) { // recebe a tela como parâmetro ao invés de instanciar novamente
        this.tela = tl;
    }

    public double dividir() {
        double a = Double.parseDouble(tela.txtDivisao1.getText());
        double b = Double.parseDouble(tela.txtDivisao2.getText());
        return a / b;
    }

    public void limparCache() {
        tela.txtSoma1.setText("");
        tela.txtSoma2.setText("");
        tela.txtSomaResult.setText("");

        tela.txtSubtracao1.setText("");
        tela.txtSubtracao2.setText("");
        tela.txtSubtracaoResult.setText("");

        tela.txtMultiplicacao1.setText("");
        tela.txtMultiplicacao2.setText("");
        tela.txtMultiplicacaoResult.setText("");

        tela.txtDivisao1.setText("");
        tela.txtDivisao2.setText("");
        tela.txtDivisaoResult.setText("");
    }

    public double multiplicar() {
        double a = Double.parseDouble(tela.txtMultiplicacao1.getText());
        double b = Double.parseDouble(tela.txtMultiplicacao2.getText());
        return a * b;
    }

    public double somar() {
        double a = Double.parseDouble(tela.txtSoma1.getText());
        double b = Double.parseDouble(tela.txtSoma2.getText());
        return a + b;
    }

    public double subtrair() {
        double a = Double.parseDouble(tela.txtSubtracao1.getText());
        double b = Double.parseDouble(tela.txtSubtracao2.getText());
        return a - b;
    }
}

Tela:

package view;

import java.awt.Color;
import java.awt.EventQueue;
import java.awt.Font;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

public class TelaCalc extends JFrame {
// Autor: - | Data: 2/11/2020 | Hora: 7 : 30

    private static final long serialVersionUID = 1L;

    /**
     * Launch the application.
     */
    public static void main(String[] args) {

        EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    TelaCalc frame = new TelaCalc();
                    frame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
    }

    private JPanel contentPane;
    public JTextField txtSoma1;
    public JTextField txtSoma2;
    public JTextField txtSomaResult;
    public JTextField txtSubtracaoResult;
    public JTextField txtSubtracao1;
    public JTextField txtSubtracao2;
    public JTextField txtMultiplicacaoResult;
    public JTextField txtMultiplicacao1;
    public JTextField txtMultiplicacao2;
    public JTextField txtDivisaoResult;
    public JTextField txtDivisao1;
    public JTextField txtDivisao2;

    private SecClass secClass = new SecClass(this); // pssa esta tela como parâmetro pro objeto da SecClass

    public TelaCalc() {

        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(100, 100, 527, 374);
        contentPane = new JPanel();
        contentPane.setForeground(new Color(112, 128, 144));
        contentPane.setBackground(new Color(0, 128, 128));
        contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(contentPane);
        contentPane.setLayout(null);

        // LABELS
        JLabel lblNumber1 = new JLabel("Enter numbers:");
        lblNumber1.setBounds(70, 11, 138, 22);
        lblNumber1.setForeground(new Color(255, 255, 255));
        lblNumber1.setFont(new Font("Tahoma", Font.PLAIN, 18));
        contentPane.add(lblNumber1);

        JLabel lblNewLabel = new JLabel("+");
        lblNewLabel.setBounds(196, 70, 27, 14);
        lblNewLabel.setFont(new Font("Tahoma", Font.PLAIN, 13));
        contentPane.add(lblNewLabel);

        JLabel lblEqual = new JLabel(" = ");
        lblEqual.setBounds(335, 70, 16, 14);
        contentPane.add(lblEqual);

        JLabel lblEqual_1 = new JLabel(" = ");
        lblEqual_1.setBounds(335, 118, 16, 14);
        contentPane.add(lblEqual_1);

        JLabel lblNewLabel_1 = new JLabel("-");
        lblNewLabel_1.setBounds(196, 118, 27, 14);
        lblNewLabel_1.setFont(new Font("Tahoma", Font.PLAIN, 13));
        contentPane.add(lblNewLabel_1);

        JLabel lblEqual_2 = new JLabel(" = ");
        lblEqual_2.setBounds(335, 168, 16, 14);
        contentPane.add(lblEqual_2);

        JLabel lblNewLabel_2 = new JLabel("x");
        lblNewLabel_2.setBounds(196, 168, 27, 14);
        lblNewLabel_2.setFont(new Font("Tahoma", Font.PLAIN, 13));
        contentPane.add(lblNewLabel_2);

        JLabel lblEqual_3 = new JLabel(" = ");
        lblEqual_3.setBounds(335, 216, 16, 14);
        contentPane.add(lblEqual_3);

        JLabel lblNewLabel_3 = new JLabel("/");
        lblNewLabel_3.setBounds(196, 216, 27, 14);
        lblNewLabel_3.setFont(new Font("Tahoma", Font.PLAIN, 13));
        contentPane.add(lblNewLabel_3);

        // TextBoxs
        // Caixas editaveis

        txtSoma1 = new JTextField();
        txtSoma1.setBounds(70, 63, 97, 27);
        txtSoma1.setFont(new Font("Tahoma", Font.PLAIN, 13));
        contentPane.add(txtSoma1);
        txtSoma1.setColumns(10);
        txtSoma1.setDocument(new JustNumbers());

        txtSoma2 = new JTextField();
        txtSoma2.setBounds(228, 63, 97, 27);
        txtSoma2.setFont(new Font("Tahoma", Font.PLAIN, 13));
        txtSoma2.setColumns(10);
        contentPane.add(txtSoma2);
        txtSoma2.setDocument(new JustNumbers()); // Aceita apenas numbers

        txtSubtracao1 = new JTextField();
        txtSubtracao1.setBounds(70, 111, 97, 27);
        txtSubtracao1.setFont(new Font("Tahoma", Font.PLAIN, 13));
        txtSubtracao1.setColumns(10);
        contentPane.add(txtSubtracao1);
        txtSubtracao1.setDocument(new JustNumbers());

        txtSubtracao2 = new JTextField();
        txtSubtracao2.setBounds(228, 111, 97, 27);
        txtSubtracao2.setFont(new Font("Tahoma", Font.PLAIN, 13));
        txtSubtracao2.setColumns(10);
        contentPane.add(txtSubtracao2);
        txtSubtracao2.setDocument(new JustNumbers());

        txtMultiplicacao1 = new JTextField();
        txtMultiplicacao1.setBounds(70, 161, 97, 27);
        txtMultiplicacao1.setFont(new Font("Tahoma", Font.PLAIN, 13));
        txtMultiplicacao1.setColumns(10);
        contentPane.add(txtMultiplicacao1);
        txtMultiplicacao1.setDocument(new JustNumbers());

        txtMultiplicacao2 = new JTextField();
        txtMultiplicacao2.setBounds(228, 161, 97, 27);
        txtMultiplicacao2.setFont(new Font("Tahoma", Font.PLAIN, 13));
        txtMultiplicacao2.setColumns(10);
        contentPane.add(txtMultiplicacao2);
        txtMultiplicacao2.setDocument(new JustNumbers());

        txtDivisao1 = new JTextField();
        txtDivisao1.setBounds(70, 209, 97, 27);
        txtDivisao1.setFont(new Font("Tahoma", Font.PLAIN, 13));
        txtDivisao1.setColumns(10);
        contentPane.add(txtDivisao1);
        txtDivisao1.setDocument(new JustNumbers());

        txtDivisao2 = new JTextField();
        txtDivisao2.setBounds(228, 209, 97, 27);
        txtDivisao2.setFont(new Font("Tahoma", Font.PLAIN, 13));
        txtDivisao2.setColumns(10);
        contentPane.add(txtDivisao2);
        txtDivisao2.setDocument(new JustNumbers());

        // Resultados

        txtSomaResult = new JTextField();
        txtSomaResult.setBounds(361, 63, 97, 27);
        txtSomaResult.setBackground(Color.DARK_GRAY);
        txtSomaResult.setEnabled(false);
        txtSomaResult.setForeground(Color.WHITE);
        txtSomaResult.setFont(new Font("Tahoma", Font.PLAIN, 15));
        txtSomaResult.setColumns(10);
        contentPane.add(txtSomaResult);

        txtSubtracaoResult = new JTextField();
        txtSubtracaoResult.setBounds(361, 111, 97, 27);
        txtSubtracaoResult.setBackground(Color.DARK_GRAY);
        txtSubtracaoResult.setEnabled(false);
        txtSubtracaoResult.setForeground(Color.RED);
        txtSubtracaoResult.setFont(new Font("Tahoma", Font.PLAIN, 15));
        txtSubtracaoResult.setColumns(10);
        contentPane.add(txtSubtracaoResult);

        txtMultiplicacaoResult = new JTextField();
        txtMultiplicacaoResult.setBounds(361, 161, 97, 27);
        txtMultiplicacaoResult.setBackground(Color.DARK_GRAY);
        txtMultiplicacaoResult.setEnabled(false);
        txtMultiplicacaoResult.setForeground(Color.RED);
        txtMultiplicacaoResult.setFont(new Font("Tahoma", Font.PLAIN, 15));
        txtMultiplicacaoResult.setColumns(10);
        contentPane.add(txtMultiplicacaoResult);

        txtDivisaoResult = new JTextField();
        txtDivisaoResult.setBounds(361, 209, 97, 27);
        txtDivisaoResult.setBackground(Color.DARK_GRAY);
        txtDivisaoResult.setEnabled(false);
        txtDivisaoResult.setForeground(Color.RED);
        txtDivisaoResult.setFont(new Font("Tahoma", Font.PLAIN, 15));
        txtDivisaoResult.setColumns(10);
        contentPane.add(txtDivisaoResult);

        JButton btnCalcular = new JButton("Calc");
        btnCalcular.setBounds(129, 294, 89, 28);
        btnCalcular.setFont(new Font("Tahoma", Font.PLAIN, 13));
        btnCalcular.setForeground(new Color(255, 255, 255));
        btnCalcular.setBackground(new Color(105, 105, 105));
        btnCalcular.addActionListener(event -> calcular());
        contentPane.add(btnCalcular);

        JButton btnClean = new JButton("Clean");
        btnClean.setBounds(284, 294, 89, 28);
        btnClean.setFont(new Font("Tahoma", Font.PLAIN, 13));
        btnClean.setForeground(new Color(255, 245, 238));
        btnClean.addActionListener(event -> secClass.limparCache());
        btnClean.setBackground(new Color(112, 128, 144));
        contentPane.add(btnClean);
    }

    private void calcular() {
        txtSomaResult.setText(String.valueOf(secClass.somar())); // Imprime o numero da soma dentro da TxtBox
        txtSubtracaoResult.setText(String.valueOf(secClass.subtrair()));
        txtMultiplicacaoResult.setText(String.valueOf(secClass.multiplicar()));
        txtDivisaoResult.setText(String.valueOf(secClass.dividir()));
    }
}
1 curtida

Valeu, soubem inciante e fui tentando por meus conhecimentos a prova. Percebi que os mesmos nao sao bons kkkkk
obrigado