adding a List of JTextField to the GUI



I've tried moving the loop to before or after the group layout is set, no
change. I'm printing the record instance, and its member data.size() to
the console, and those look ok. I'm just not able to add components with
a loop.

Hmm, too tired right now, but maybe I'll play around with matisse.

any pointers appreciated!




package a00720398.assignment.view;

import a00720398.assignment.beans.Record;
import a00720398.assignment.controller.Controller;
import java.util.ArrayList;
import java.util.List;
import javax.swing.*;



@SuppressWarnings({"unchecked", "serial"})
public class AppFrame extends javax.swing.JFrame {

Controller con = new Controller();
String queryString = "SELECT * FROM Beatles";
Record record = new Record();

/** Creates new form AppFrame */
public AppFrame() {
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() {

center = new javax.swing.JPanel();

setDefaultCloseOperation
(javax.swing.WindowConstants.EXIT_ON_CLOSE);

//send columns to dataPanel

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); //Why isn't it adding??
}

javax.swing.GroupLayout centerLayout = new javax.swing.GroupLayout
(center);
center.setLayout(centerLayout);
centerLayout.setHorizontalGroup(
centerLayout.createParallelGroup
(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
centerLayout.setVerticalGroup(
centerLayout.createParallelGroup
(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);

getContentPane().add(center, java.awt.BorderLayout.CENTER);

pack();
}// </editor-fold>//GEN-END:initComponents

/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new AppFrame().setVisible(true);
}
});
}

// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel center;
// End of variables declaration//GEN-END:variables

}



-Thufir
.



Relevant Pages

  • Re: Best solution for thread safe data in loop.
    ... Make a copy of the info struct at the beginning of every loop run. ... // done with different hardware APIs ... void copyBuffer ... unsigned int Left; ...
    (microsoft.public.vc.language)
  • Re: critique my program!
    ... One person already recommended against the definition for ZER, ... The difference is that LIM, presumably an abbreviation for limit, can be seen as a parameter. ... void printar; ... There are many ways to write a loop for a fixed number of iterations, as you do with the while loop. ...
    (comp.lang.c)
  • Re: Progressbars (probably again...)
    ... > is updated on each iteration of the work loop. ... JProgressBar jProgressBar1 = new JProgressBar; ... void jButton2_actionPerformed{ ... void importData(){ ...
    (comp.lang.java.gui)
  • Re: can this code be improved
    ... Now that you have the first refactored version of your code, you can start to look for duplication*. ... Each loop logic is the same. ... private static void initializeNewList{ ...
    (comp.lang.java.programmer)
  • Help with code
    ... must use a while loop, a do while loop, a for loop, an array, a ... create a prototype for PrintTrials() ... head and tail arrays ... void PrintTrials() ...
    (comp.lang.c)