Ciao a tutti, vi spiego il mio problema.
Ho una classe che estende la classe JFrame chiamata EntryFrame. (public class EntryFrame extends javax.swing.JFrame)
questa classe contiene un ArrayList di un oggetto chiamato property. (private ArrayList<Property> properties
Un altro JFrame (public class ViewerFrame extends javax.swing.JFrame) contiene una JTextArea nella quale vorrei mostrare i dati dell'arrayList (che ricordo si trova nell'altra classe).
Ho provato a passare l'arrayList tramite il costruttore della classe ViewerFrame ma la jTextArea risulta vuota.
Any idea???
Cliccando il tasto di cui riporto l'evento l'evento apro l'altra classe jframe.
codice:
private void ViewButtonActionPerformed(java.awt.event.ActionEvent evt) {
ViewerFrame.main(null);
}
Questa è la classe del JFrame che contiene la JTextArea.
codice:
package monashrealestateagency;
import java.util.ArrayList;
/**
*
* @author DARIO
*/
public class ViewerFrame extends javax.swing.JFrame {
private ArrayList<Property> properties;
/** Creates new form ViewerFrame */
public ViewerFrame() {
super();
initComponents();
}
public ViewerFrame(ArrayList<Property> properties) {
initComponents();
this.properties = properties;
int i = 0;
while (i<properties.size())
{
jTextArea1.append(properties.get(i).getAddress());
}
}
private void displayData(ArrayList<Property> properties)
{
int i = 0;
while (i < properties.size())
{
jTextArea1.append(properties.get(i).getAddress());
}
}
/** 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() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextArea1.setColumns(20);
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()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 380, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(193, Short.MAX_VALUE))
);
pack();
}// </editor-fold>
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new ViewerFrame().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JTextArea jTextArea1;
// End of variables declaration
}
Grazie in anticipo e scusate se rompo spesso.
Ciao