something tricky with JTextFields
Hello everyone!
Here's the problem:
Is there a possibility in getting some number of JTextFields depending from database column cell count?
For example- in *.mdb database i have one column with 5 rows and some data! So this number of rows is determing JTextField count which show up on JPanel filled with data from database!
Tnx!
[364 byte] By [
kode128a] at [2007-11-26 20:37:09]

# 1
Declare:
Vector<JTextField> vector = new Vector<JTextField>();
then parse the database. Every time you have a row
vector.add(new JTextField())
then in gui building part you just:
for (int i=0;i<vector.size();i++{
panel.add(vector.get(i));
}
as simple as that>
# 8
Connection con = DriverManager.getConnection
( "jdbc:myDriver:wombat", "myLogin","myPassword");
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("SELECT a, b, c FROM Table1");
while (rs.next()) {
int x = rs.getInt("a");
String s = rs.getString("b");
float f = rs.getFloat("c");
vector.add(new JTextField());
}
skeleton taken from:
http://java.sun.com/docs/books/tutorial/jdbc/overview/index.html
Message was edited by:
hellbinder