Duvida sobre Area de texto e Calculadora

Codigos da Classe e do JFrame…

O frame:


public class Frame1 extends javax.swing.JFrame {

    /** Creates new form Frame1 */
    public Frame1() {
        initComponents();
    }


    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">                          
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jCheckBox1 = new javax.swing.JCheckBox();
        jCheckBox2 = new javax.swing.JCheckBox();
        jCheckBox3 = new javax.swing.JCheckBox();
        jCheckBox4 = new javax.swing.JCheckBox();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Operação"));

        jCheckBox1.setText("Adicão");
        jCheckBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCheckBox1ActionPerformed(evt);
            }
        });

        jCheckBox2.setText("Subtração");

        jCheckBox3.setText("Divisão");

        jCheckBox4.setText("Multiplicação");

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jCheckBox1)
                    .addComponent(jCheckBox2)
                    .addComponent(jCheckBox3)
                    .addComponent(jCheckBox4))
                .addContainerGap(28, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jCheckBox1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCheckBox2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCheckBox3)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jCheckBox4)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jButton1.setText("Executar Operações");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText("Selecionar Todas");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jTextArea1.setColumns(20);
        jTextArea1.setEditable(false);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 213, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 219, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>                        

    private void jCheckBox1ActionPerformed(java.awt.event.ActionEvent evt) {                                           


    }                                          

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    if (jCheckBox1.isSelected()){
        Operacoes.adicao();
    }
    if (jCheckBox2.isSelected()){
        Operacoes.subtracao();
    }
    if (jCheckBox3.isSelected()){
        Operacoes.divisao();
    }
    if (jCheckBox2.isSelected()){
        Operacoes.multiplicacao();
    }
    }                                        

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    jCheckBox1.setSelected(true);
    jCheckBox2.setSelected(true);
    jCheckBox3.setSelected(true);
    jCheckBox4.setSelected(true);
    }                                        

  
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new Frame1().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify                     
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JCheckBox jCheckBox2;
    private javax.swing.JCheckBox jCheckBox3;
    private javax.swing.JCheckBox jCheckBox4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextArea jTextArea1;
    // End of variables declaration                   

}

A classe com as operações:

import javax.swing.JOptionPane;
public class Operacoes {
    public static void principal(){
        String n1,n2;
        n1 = JOptionPane.showInputDialog("Digite o primeiro número:");
        n2 = JOptionPane.showInputDialog("Digite o segundo  número:");
    }
    public static void adicao() {
         String n1,n2;
         int res;
        n1 = JOptionPane.showInputDialog("Digite o primeiro número:");
        n2 = JOptionPane.showInputDialog("Digite o segundo  número:");
       res = (Integer.parseInt(n1)+Integer.parseInt(n2));
       JOptionPane.showMessageDialog(null,"Resultado da adição:"+res);
       
    }
    public static void subtracao() {
    String n1,n2;
    int res;
        n1 = JOptionPane.showInputDialog("Digite o primeiro número:");
        n2 = JOptionPane.showInputDialog("Digite o segundo  número:");
       res = (Integer.parseInt(n1)-Integer.parseInt(n2));
       JOptionPane.showMessageDialog(null,"Resultado da subtração:"+res);
    }
    public static void divisao() {
    String n1,n2;
    int res;
        n1 = JOptionPane.showInputDialog("Digite o primeiro número:");
        n2 = JOptionPane.showInputDialog("Digite o segundo  número:");
        res = (Integer.parseInt(n1)/Integer.parseInt(n2));
        JOptionPane.showMessageDialog(null,"Resultado da divisão:"+res);
    }
    public static void multiplicacao() {
    String n1,n2;
    int res;
        n1 = JOptionPane.showInputDialog("Digite o primeiro número:");
        n2 = JOptionPane.showInputDialog("Digite o segundo  número:");
        res = (Integer.parseInt(n1)*Integer.parseInt(n2));
        JOptionPane.showMessageDialog(null,"Resultado da multiplicação:"+res);
    }

}

Maicon,

Eu não sei se entendi o que você quer, mas se for o que estou pensando uma solução é: jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt, Frame1.this.jTextArea1); } });private void jButton1ActionPerformed(java.awt.event.ActionEvent evt, JTextArea textArea) { if(jCheckBox1.isSelected()) { Operacoes.adicao(textArea); } ... }[code]public static void adicao(JTextArea textArea) {
String n1 = JOptionPane.showInputDialog(“Digite o primeiro número:”);
String n2 = JOptionPane.showInputDialog(“Digite o segundo número:”);
int res = (Integer.parseInt(n1) + Integer.parseInt(n2));

textArea.setText("Resultado da adição:" + res);

}[/code]Abraço.

Seguinte vc, pode resolver isto de várias maneiras, mas vou colocar a que eu imaginei.

Nas suas classes que realizam as operações, vc deve colocar um retorno para que ele retorne o texto com o resultado.
Ex:

public static String adicao() {  
         String n1,n2;  
         int res;  
         n1 = JOptionPane.showInputDialog("Digite o primeiro número:");  
         n2 = JOptionPane.showInputDialog("Digite o segundo  número:");  
         res = (Integer.parseInt(n1)+Integer.parseInt(n2));  
         //JOptionPane.showMessageDialog(null,"Resultado da adição:"+res);  
         return "Resultado da adição: "+res;
}  

ai quando você for verificar qual o checkbox esta selecionado e chamar a operação.

Vamos supor que o nome do campo onde você qr colocar o resultado seja: " txt_resultado "
ex:

    if (jCheckBox1.isSelected()){  

      txt_resultado.setText( Operacoes.adicao() ); // Assim ele coloca o retorno daquele método no campo de texto.  

    }  

Qual é a dúvida?