craftleft.gif (3002 bytes)QuickTable
Home | API | Tutorial | Download | Support | Contact topblack.gif (108 bytes)


QuickTable User Cp  |  Register  |  Members  |  Search  |  Help
    |- QuickTable Discussion Forums > Column Post New Topic   Post A Reply
columns 4 and higher printer friendly version
next newest post | next oldest post
Author Messages
hcir
Private

Gender: Male
Location: alaska
Registered: Oct 2006
Status: Offline
Posts: 7

Click here to see the profile for hcir Send email to hcir Send private message to hcir Find more posts by hcir Edit or delete this message Reply w/Quote
Posted Friday, October 6, 2006 @ 17:35:03  

after purchasing and using code from the advanced example

col = dBTable1.getColumn(4); col.setPreferredWidth(32); col.setReadOnly(true);
col = dBTable1.getColumn(5); col.setPreferredWidth(64); col.setReadOnly(true);
col = dBTable1.getColumn(6); col.setPreferredWidth(1); col.setReadOnly(true);

produces

Exception in thread "main" java.lang.RuntimeException: Column 4 is not available
at quick.dbtable.s.getColumn(DBTableColumnModel.java:811)
at quick.dbtable.DBTable.getColumn(DBTable.java:2346)
at MakeFrame.<init>(MakeFrame.java:40)
at MakeFrame.main(MakeFrame.java:83)

solution?

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Friday, October 6, 2006 @ 22:40:13  

If the source code is small, could you post it?

Do you really see more than 4 columns in the table when you are calling getColumn(4)?

hcir
Private

Gender: Male
Location: alaska
Registered: Oct 2006
Status: Offline
Posts: 7

Click here to see the profile for hcir Send email to hcir Send private message to hcir Find more posts by hcir Edit or delete this message Reply w/Quote
Posted Saturday, October 7, 2006 @ 14:44:29  

I did get an email from the quicktable admin and replied with more details

the table havs 6 columns and all display as expected without the getColumn code code. the listing below should display what i am doing. the compile works, running it produces "Column 4 is not avail..." i have tried both the free version and the version i downloaded after paying.

thanks

import javax.swing.*;
import quick.dbtable.*;
import java.sql.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Hashtable;
import java.io.*;

public class MakeFrame extends JFrame {
public MakeFrame() {
JFrame mainFrame = new JFrame("MakeFrame");
mainFrame.setLocation(100, 100);
mainFrame.setSize(800, 300);
Container container1 = mainFrame.getContentPane();

JPanel topPanel = new JPanel();
JPanel bottomPanel = new JPanel();

JTextField queryText = new JTextField("select * from alarms");
topPanel.add(queryText);

final quick.dbtable.DBTable dBTable1 = new quick.dbtable.DBTable();
dBTable1.debug=true;
JPanel panel1 = new JPanel();
bottomPanel.add(dBTable1);
dBTable1.setDatabaseDriver("com.mysql.jdbc.Driver");
dBTable1.setJdbcUrl("jdbc:mysql://localhost:3306/test");
dBTable1.setSelectSql("select * from alarms");
dBTable1.addDeleteSql("delete from alarms where id = ?", "1");

// set the columns as we want
// id
Column col;
col = dBTable1.getColumn(0); col.setPreferredWidth(10); col.setReadOnly(true);
col = dBTable1.getColumn(1); col.setPreferredWidth(4); col.setReadOnly(true);
// see col 2 below
col = dBTable1.getColumn(3); col.setPreferredWidth(12); col.setReadOnly(true);
col = dBTable1.getColumn(4); col.setPreferredWidth(32); col.setReadOnly(true);

Admin
Board Owner

Gender: Unspecified
Location:
Registered: Jul 2003
Status: Offline
Posts: 9

Click here to see the profile for Admin Send email to Admin Send private message to Admin Find more posts by Admin Edit or delete this message Reply w/Quote
Posted Sunday, October 8, 2006 @ 00:46:25  

when you set the various sqls like selectSql, deleteSql etc, quicktable does not go to database and execute them immediately. Instead when you call the refresh() method to fetch the data from database to fill the table, we get all the column information from the database. Only after this getColumn(x) will give you valid result.

If you do not want to load the data, at the time when you are setting column properties, then you can use

dbTable.createColumnModelFromQuery()
dbTable.getColumn()

In short either refresh() or createColumnModelFromQuery() should be called before calling getColumn() method.

Please read the CustomerOrderDemo sample to get more information about using quicktable.

hcir
Private

Gender: Male
Location: alaska
Registered: Oct 2006
Status: Offline
Posts: 7

Click here to see the profile for hcir Send email to hcir Send private message to hcir Find more posts by hcir Edit or delete this message Reply w/Quote
Posted Sunday, October 8, 2006 @ 13:23:39  

thanks for the info. i have gotten my code to run with the info you provided. i had ignored the CustomerOrderDemo example due to it not compiling
Post New Topic   Post A Reply Jump to:
Contact Us | QuickTable - A Java DBGrid | Privacy Policy All times are GMT -5 Hours.
Welcome to QuickTable Forums, Guest!  
Login
Username :
Password :
In order to fully utilize the abilities of this board, you are required to register as a member. Registration is free, and allows you to do lots of things including turning on or off certain features of this board. Register now!
Powered by CuteCast v2.0 BETA 2
Copyright © 2001-2003 ArtsCore Studios