[RESOLVIDO] Como eu altero o texto de um Label em um frame por um botão em outro frame?

Como eu altero o texto de um Label em um frame por um botão em outro frame?
Ex : No frame 1 eu coloquei :

String ve = "10";
public void valorEnergia(String ve){
    
    int i = Integer.parseInt(ve);
    this.jLabelEnergia.setText(ve);
    
}

e no botão do frame 2 coloquei :

private void jButtonDormirSofaActionPerformed(java.awt.event.ActionEvent evt)
{                                                  
    JFrameInicial jfi = new JFrameInicial();
    jfi.valorEnergia("25");
}                                                 

nao dá erro mas simplismente não altera o jlabel! E o jlabel ta no modo publico!

coloca do jeito que fizemos no seu último post:

JFrameInicial jfi = (JFrameInicial) parent;
frame.trocarNumero(meuCampo.getText());
jfi.valorEnergia("25");

Aqui não precisa ter o “this”

eu tenho que trocar esses nomes? Pra quais? Pq eu coloquei exatamente assim e deu erro

O nome não tem interferência nesse caso não, olha, faz assim:

Isso é no seu PRIMEIRO FRAME

public void valorEnergia(int ve) {
jLabelEnergia.setText(ve);
}

Agora no seu SEGUNDO FRAME:

public class SegundoFrame extends javax.swing.JFrame {

    private JFrameInicial parent;

    public SegundoFrame (JFrameInicial p) {
        initComponents();
        this.parent = p;
    }

Aí agora no seu BOTÃO DO SEGUNDO FRAME

private void jButtonDormirSofaActionPerformed(java.awt.event.ActionEvent evt) {                                                  
JFrameInicial jfi = (JFrameInicial) parent;
int valor = 25;
jfi.valorEnergia(valor);
}

Deixa igual, apaga as outras strings e int q vc fez, só muda se o nome da textField estiver diferente

O problema é que não tem nenhum campo! Eu só quero fazer com que um botão mude o texto de um jlabel em outro frame mas ta dando erro ksks. Os itens q tenho são um jbutton e um jlabel

Tenta agora

Eu tentei man, e deu erro no “this.parent = p;” e nos outros pq n tenho um campo ‘-’

Isso não é um campo? (Quando eu falo campo, é campo de texto, desculpa se me expressei mal)

Onde vc ta colocando o this.parent?

manda seu código

/*

  • To change this license header, choose License Headers in Project Properties.
  • To change this template file, choose Tools | Templates
  • and open the template in the editor.
    */
    package Jframes;

import java.awt.Container;
import javax.swing.JLabel;

/**
*

  • @author ATC
    */
    public class JFrameInicial extends javax.swing.JFrame {

    /**

    • Creates new form JFrameInicial
      */

    public JFrameInicial() {
    initComponents();
    }

    String ve = “10”;

    public void valorEnergia(String ve){

     int i = Integer.parseInt(ve);
     jLabelEnergia.setText(ve);
    

}

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    jLabelDavaJonasIcone = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabelEnergia = new javax.swing.JLabel();
    jLabel1 = new javax.swing.JLabel();
    jLabel5 = new javax.swing.JLabel();
    jLabelSede = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    jLabel4 = new javax.swing.JLabel();
    jLabelSaude = new javax.swing.JLabel();
    jLabel7 = new javax.swing.JLabel();
    jLabel6 = new javax.swing.JLabel();
    jLabelFome = new javax.swing.JLabel();
    jLabel9 = new javax.swing.JLabel();
    jLabel8 = new javax.swing.JLabel();
    jLabelDinheiro = new javax.swing.JLabel();
    jLabel10 = new javax.swing.JLabel();
    jLabelInteligencia = new javax.swing.JLabel();
    jLabel12 = new javax.swing.JLabel();
    jButton1 = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
    setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));

    jLabelDavaJonasIcone.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagens/IconeDavaJonas.png"))); // NOI18N

    jLabel2.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel2.setForeground(new java.awt.Color(102, 255, 102));
    jLabel2.setText("Energia :");
    jLabel2.setToolTipText("dorme pra ganhar ENERGY");

    jLabelEnergia.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabelEnergia.setText(ve);

    jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel1.setText("/ 10");

    jLabel5.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel5.setForeground(new java.awt.Color(0, 153, 153));
    jLabel5.setText("Sede :");
    jLabel5.setToolTipText("Bebe aqua pra ganar energia");

    jLabelSede.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabelSede.setText("0");

    jLabel3.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel3.setText("/ 10");

    jLabel4.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel4.setForeground(new java.awt.Color(255, 51, 0));
    jLabel4.setText("Saúde :");
    jLabel4.setToolTipText("Vai no médico pq ue comé q ta tua saúde");

    jLabelSaude.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabelSaude.setText("100");

    jLabel7.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel7.setText("/ 10");

    jLabel6.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel6.setForeground(new java.awt.Color(204, 204, 0));
    jLabel6.setText("Fome :");
    jLabel6.setToolTipText("Come");

    jLabelFome.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabelFome.setText("0");

    jLabel9.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel9.setText("/ 10");

    jLabel8.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel8.setForeground(new java.awt.Color(0, 153, 0));
    jLabel8.setText("Dinheiro :");
    jLabel8.setToolTipText("Trabalha pra ganhar dinh");

    jLabelDinheiro.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabelDinheiro.setText("0");

    jLabel10.setFont(new java.awt.Font("Tahoma", 0, 15)); // NOI18N
    jLabel10.setForeground(new java.awt.Color(102, 102, 102));
    jLabel10.setText("Inteligência :");
    jLabel10.setToolTipText("SEJA UM FUCKING EINSTEIN E DOMINE O MUNDO AAA");

    jLabelInteligencia.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabelInteligencia.setText("0");

    jLabel12.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
    jLabel12.setText("/ 10");

    jButton1.setBackground(new java.awt.Color(102, 102, 102));
    jButton1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
    jButton1.setText("Menu");
    jButton1.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jButton1ActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(19, 19, 19)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addComponent(jLabel4)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelSaude)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel7))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addComponent(jLabel10)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelInteligencia)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel12))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addComponent(jLabel5)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelSede)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel3))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addComponent(jLabel2)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jLabelEnergia)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel1))
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel8)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelDinheiro))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(jLabel6)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jLabelFome)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel9)))
            .addGap(112, 112, 112)
            .addComponent(jLabelDavaJonasIcone)
            .addGap(26, 26, 26))
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
            .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addComponent(jButton1)
            .addGap(59, 59, 59))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addGap(29, 29, 29)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(jLabelEnergia)
                        .addComponent(jLabel1))
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel5)
                        .addComponent(jLabelSede)
                        .addComponent(jLabel3))
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel4)
                        .addComponent(jLabelSaude)
                        .addComponent(jLabel7))
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel6)
                        .addComponent(jLabelFome)
                        .addComponent(jLabel9))
                    .addGap(18, 18, 18)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel8)
                        .addComponent(jLabelDinheiro)))
                .addComponent(jLabelDavaJonasIcone))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(jLabel10, javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jLabelInteligencia, javax.swing.GroupLayout.Alignment.TRAILING)
                .addComponent(jLabel12, javax.swing.GroupLayout.Alignment.TRAILING))
            .addGap(18, 18, 18)
            .addComponent(jButton1)
            .addContainerGap(21, Short.MAX_VALUE))
    );

    setSize(new java.awt.Dimension(500, 356));
    setLocationRelativeTo(null);
}// </editor-fold>                        

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                         
    Mapa mapa = new Mapa();
    mapa.setVisible(true);
}                                        

/**
 * @param args the command line arguments
 */
public static void main(String args[]) {
    /* Set the Nimbus look and feel */
    //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
    /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
     * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
     */
    try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
            if ("Nimbus".equals(info.getName())) {
                javax.swing.UIManager.setLookAndFeel(info.getClassName());
                break;
            }
        }
    } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(JFrameInicial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(JFrameInicial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(JFrameInicial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(JFrameInicial.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
    }
    //</editor-fold>

    /* Create and display the form */
    java.awt.EventQueue.invokeLater(new Runnable() {
        public void run() {
            new JFrameInicial().setVisible(true);
        }
    });
}

// Variables declaration - do not modify                     
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel10;
private javax.swing.JLabel jLabel12;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JLabel jLabel9;
private javax.swing.JLabel jLabelDavaJonasIcone;
private javax.swing.JLabel jLabelDinheiro;
public javax.swing.JLabel jLabelEnergia;
private javax.swing.JLabel jLabelFome;
private javax.swing.JLabel jLabelInteligencia;
private javax.swing.JLabel jLabelSaude;
private javax.swing.JLabel jLabelSede;
// End of variables declaration                   

}

/*

  • To change this license header, choose License Headers in Project Properties.

  • To change this template file, choose Tools | Templates

  • and open the template in the editor.
    /
    package Jframes;
    import Jframes.JFrameInicial;
    /
    *

  • @author ATC
    */
    public class Casa extends javax.swing.JFrame {

    private JFrameInicial parent;
    /**

    • Creates new form Casa
      */
      public Casa() {
      initComponents();
      this.parent = p;
      }

    /**

    • This method is called from within the constructor to initialize the form.

    • WARNING: Do NOT modify this code. The content of this method is always

    • regenerated by the Form Editor.
      */
      @SuppressWarnings(“unchecked”)
      //
      private void initComponents() {

      jButtonDormirSofa = new javax.swing.JButton();
      jButtonBeberAqua = new javax.swing.JButton();
      jButtonComerComida = new javax.swing.JButton();
      jLabel1 = new javax.swing.JLabel();
      jLabelComida = new javax.swing.JLabel();

      setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

      jButtonDormirSofa.setFont(new java.awt.Font(“Tahoma”, 0, 18)); // NOI18N
      jButtonDormirSofa.setText(“Dormir no sofá”);
      jButtonDormirSofa.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jButtonDormirSofaActionPerformed(evt);
      }
      });

      jButtonBeberAqua.setFont(new java.awt.Font(“Tahoma”, 0, 18)); // NOI18N
      jButtonBeberAqua.setText(“Beber aqua”);

      jButtonComerComida.setFont(new java.awt.Font(“Tahoma”, 0, 18)); // NOI18N
      jButtonComerComida.setText(“Comer comida”);

      jLabel1.setFont(new java.awt.Font(“Tahoma”, 0, 18)); // NOI18N
      jLabel1.setText(“Estoque de Comida :”);

      jLabelComida.setFont(new java.awt.Font(“Tahoma”, 0, 18)); // NOI18N
      jLabelComida.setText(“0”);

      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(jButtonBeberAqua, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addComponent(jButtonDormirSofa)
      .addComponent(jButtonComerComida)
      .addGroup(layout.createSequentialGroup()
      .addComponent(jLabel1)
      .addGap(34, 34, 34)
      .addComponent(jLabelComida)))
      .addContainerGap(166, Short.MAX_VALUE))
      );
      layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addGap(36, 36, 36)
      .addComponent(jButtonDormirSofa, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addGap(18, 18, 18)
      .addComponent(jButtonBeberAqua)
      .addGap(18, 18, 18)
      .addComponent(jButtonComerComida)
      .addGap(46, 46, 46)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
      .addComponent(jLabel1)
      .addComponent(jLabelComida))
      .addContainerGap(65, Short.MAX_VALUE))
      );

      pack();
      setLocationRelativeTo(null);
      }//

    private void jButtonDormirSofaActionPerformed(java.awt.event.ActionEvent evt) {
    JFrameInicial jfi = (JFrameInicial) parent;
    jfi.jLabelEnergia(ve.getText());
    jfi.valorEnergia(“25”);
    }

    /**

    • @param args the command line arguments
      /
      public static void main(String args[]) {
      /
      Set the Nimbus look and feel /
      //
      /
      If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.

      • For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
        */
        try {
        for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
        if (“Nimbus”.equals(info.getName())) {
        javax.swing.UIManager.setLookAndFeel(info.getClassName());
        break;
        }
        }
        } catch (ClassNotFoundException ex) {
        java.util.logging.Logger.getLogger(Casa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
        java.util.logging.Logger.getLogger(Casa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
        java.util.logging.Logger.getLogger(Casa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
        java.util.logging.Logger.getLogger(Casa.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //

      /* Create and display the form */
      java.awt.EventQueue.invokeLater(new Runnable() {
      public void run() {
      new Casa().setVisible(true);
      }
      });
      }

    // Variables declaration - do not modify
    private javax.swing.JButton jButtonBeberAqua;
    private javax.swing.JButton jButtonComerComida;
    private javax.swing.JButton jButtonDormirSofa;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabelComida;
    // End of variables declaration

}

Aff, eu que vacilei, perdão!! Coloca isso no seu segundo frame //Quando vc fizer isso, vai dar erro lá no final, é só vc apertar pra criar o construtor, aí vai dar certo

public SegundoFrame(JFrameInicial p) {
        initComponents();
        this.parent = p;
}

Aí na hora de chamar a janela vc coloca:

SegundoFrame sf = new SegundoFrame(this);
sf.setVisible(true);

Pronto, agora testei o código:

Frame1:

public void valorEnergia(int ve) {
    jLabelEnergia.setText(String.valueOf(ve));
}

Frame2:

public class Form2 extends javax.swing.JFrame {

    private JFrameInicial parent;

    public Form2(JFrameInicial p) {
        initComponents();
        this.parent = p;
    }

private Form2() {
    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}

Meu botão:

JFrameInicial frameCad = (JFrameInicial) parent;
int valor = 25;
frameCad.valorEnergia(valor);

Subi um projeto no git, se quiser pegar e usar, fique a vontade.

Melhorou mas qnd eu fui abrir o segundo jframe apareceu esses erros : Exception in thread “AWT-EventQueue-0” java.lang.RuntimeException: Uncompilable source code - Casa() has private access in Jframes.Casa
at Jframes.Mapa.jButtonCasaActionPerformed(Mapa.java:149)
at Jframes.Mapa.access$000(Mapa.java:12)
at Jframes.Mapa$1.actionPerformed(Mapa.java:49)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6533)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6298)
at java.awt.Container.processEvent(Container.java:2237)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2295)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4889)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4526)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4467)
at java.awt.Container.dispatchEventImpl(Container.java:2281)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:90)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.awt.EventQueue$4.run(EventQueue.java:729)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
CONSTRUÍDO COM SUCESSO (tempo total: 6 segundos)

valeu cara, me resolvi aki

Só trocar de private pra public.

Conseguiu?

Sim sim

1 curtida