hello
25-03-2016, 22:04
Ciao,
ho due classi NewJFrame1 e NewJFrame2
nella NewJFrame1 ho un JTextField e due bottoni: jButton1 per aprire il Frame presente nell'altra classe e jButton2 per valorizzare il JTextField
nella NewJFrame2 ho un un solo bottone jButton1 che richiama il metodo Prova_Set() della prima classe per valorizzare il JTextField
Il problema che ho è che cliccando sul bottone della classe NewJFrame2 viene eseguito il metodo Prova_Set ma non scrive nel JTextField
:help:
public class NewJFrame1 extends javax.swing.JFrame {
private void initComponents() {
jButton1 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
...
}
public void Prova_Set(){
jTextField1.setText("paperino");
System.out.println("fatto!!!");
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
NewJFrame2 n = new NewJFrame2();
n.setVisible(true);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Prova_Set();
}
public static void main(String args[]) {
...
public void run() {
new NewJFrame1().setVisible(true);
}
}
}
______________________________________________________________________________________________
public class NewJFrame2 extends javax.swing.JFrame {
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel1.setText("Ciao");
...
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
NewJFrame1 t = new NewJFrame1();
t.Prova_Set();
}
public static void main(String args[]) {
...
public void run() {
new NewJFrame2().setVisible(true);
}
}
ho due classi NewJFrame1 e NewJFrame2
nella NewJFrame1 ho un JTextField e due bottoni: jButton1 per aprire il Frame presente nell'altra classe e jButton2 per valorizzare il JTextField
nella NewJFrame2 ho un un solo bottone jButton1 che richiama il metodo Prova_Set() della prima classe per valorizzare il JTextField
Il problema che ho è che cliccando sul bottone della classe NewJFrame2 viene eseguito il metodo Prova_Set ma non scrive nel JTextField
:help:
public class NewJFrame1 extends javax.swing.JFrame {
private void initComponents() {
jButton1 = new javax.swing.JButton();
jTextField1 = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
...
}
public void Prova_Set(){
jTextField1.setText("paperino");
System.out.println("fatto!!!");
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
NewJFrame2 n = new NewJFrame2();
n.setVisible(true);
}
private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
Prova_Set();
}
public static void main(String args[]) {
...
public void run() {
new NewJFrame1().setVisible(true);
}
}
}
______________________________________________________________________________________________
public class NewJFrame2 extends javax.swing.JFrame {
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jButton1 = new javax.swing.JButton();
jLabel1.setText("Ciao");
...
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
NewJFrame1 t = new NewJFrame1();
t.Prova_Set();
}
public static void main(String args[]) {
...
public void run() {
new NewJFrame2().setVisible(true);
}
}