adding a List of JTextField to the GUI
- From: thufir <hawat.thufir@xxxxxxxxx>
- Date: Sun, 27 Jul 2008 06:55:27 GMT
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
.
- Follow-Ups:
- Re: adding a List of JTextField to the GUI
- From: Mark Space
- Re: adding a List of JTextField to the GUI
- Prev by Date: Re: [NetBeans]changing menuitems
- Next by Date: Re: adding a List of JTextField to the GUI
- Previous by thread: Re: Text in if condition is not displayed in the browser
- Next by thread: Re: adding a List of JTextField to the GUI
- Index(es):
Relevant Pages
|