E aew pessoal do fórum, tudo bom?
Meu probleminha é o seguinte:
tenho uma classe main que chama 2 janelas(mesma classe):/*
* Main.java
*
* Created on 16 de Outubro de 2007, 00:01
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package javaapplication4;
/**
*
*/
public class Main {
/** Creates a new instance of Main */
public Main() {
}
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
Janela NovaJanela = new Janela();
NovaJanela.setVisible(true);
Janela NovaJanela_2 = new Janela();
NovaJanela_2.setVisible(true);
}
}
Cada janela tem 1 textfield e um botão. Quando eu preciono o botão, eu preciso enviar o texto de uma janela para outra. Segue o que eu fiz da janela:
/*
* Janela.java
*
* Created on 16 de Outubro de 2007, 00:01
*/
package javaapplication4;
/**
*
*/
public class Janela extends javax.swing.JFrame {
/** Creates new form Janela */
public Janela() {
initComponents();
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
txtTexto = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Troca de texto");
setResizable(false);
jButton1.setText("Troca texto");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(txtTexto, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(154, 154, 154)
.add(jButton1)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(txtTexto, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jButton1)
.addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setBounds((screenSize.width-408)/2, (screenSize.height-104)/2, 408, 104);
}// </editor-fold>//GEN-END:initComponents
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Janela().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
public javax.swing.JTextField txtTexto;
// End of variables declaration//GEN-END:variables
}
como eu termino isso?
abrazzzzzzzz
PH :?: