Re: adding a List of JTextField to the GUI



On Sun, 27 Jul 2008 13:32:40 -0700, Mark Space wrote:


What you should do, imho, is construct the object as best you can in the
GUI builder. Then edit the constructor, not initComponents();

public class AppFrame extends javax.swing.JFrame {

/** Creates new form AppFrame */
public AppFrame() {
initComponents();

// <-- Add your code here
}

}

That way, the GUI has been built, and you don't have to worry about
whether everything is initialized, because everything is initialized by
initComponents already.

It's just a matter of learning where the best spot to edit the Matisse
generated code.

Ok, this makes alot of sense. Plus, mingling my code in with generated
code would confuse me.

I've been admittedly a bit lax in my reading, but I think that what's
required here is to somehow call:

center.getSomething().addSomehow(field);


here's what I have:

public AppFrame() {
initComponents();

record = con.getRecord(queryString, 1);
System.out.println(record.getData().size());

for (int i = 1; i < record.getData().size(); i++) {
JTextField field = new JTextField();
String txt = (record.getData().elementAt(i).toString());
System.out.println(txt);
field.setText(txt);
center.add(field); //how to maintain a reference to fields?

//centerLayout.addComponent(field); //cannot find symbol
//centerLayout, it's out of scope

center.getLayout().addLayoutComponent(txt, field);

}
}



thanks,

Thufir
.