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
Blank column printer friendly version
next newest post | next oldest post
Author Messages
JustinSkalka
Private First Class

Gender: Unspecified
Location: USA
Registered: Feb 2006
Status: Offline
Posts: 18

Click here to see the profile for JustinSkalka Send email to JustinSkalka Send private message to JustinSkalka Find more posts by JustinSkalka Edit or delete this message Reply w/Quote
Posted Friday, February 17, 2006 @ 15:00:48  

Be gentle... I'm a java n00b. :p

I'd like to have a blank column at the beginning of the table that I can populate based on a value in the data retrieved from the database, i.e. if column 3 contains "Boo", then column 0 gets a ghost gif.

{Edited to add}

Nevermind, I figured something out. See code below:

int cc = dBTable1.getColumnCount();
cc += 1;
Column c = new Column();
c.setHeaderValue("Indicator");
c.setLength(25);
c.setPreferredWidth(25);
dBTable1.addColumn(c);

// clear out the cells, just in case
for (int i=1; i<dBTable1.getRowCount()+1; i++)
{
dBTable1.setValueAt(" ", 1, cc-1);
}

//move new column to new location
dBTable1.moveColumn(cc-1,0);

[Edit by JustinSkalka on Friday, February 17, 2006 @ 16:08:32]

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, February 17, 2006 @ 16:41:16  

The same effect can be acheived in multiple ways without adding a column

Example
Lets say your sql is

select A, B, C from ....

and if you want to have a first column with image, based on data in column C, then I would have the sql as

select C, A, B, C from .... (added column C again as the first column)

Now for the first column, I would use the image component as

Code:

Hashtable imageHash = new Hashtable();
imageHash.put("Boo",new ImageIcon(this.getClass().getResource("images/ghost.gif")));
imageHash.put("D",new ImageIcon(this.getClass().getResource("images/dead.gif")));
imageHash.put("L",new ImageIcon(this.getClass().getResource("images/leave.gif")));
//Note: make sure you have the images directory in classpath

yourQuickTable.setCellComponent(yourQuickTable.getColumn(0), Column.IMAGE_CELL , imageHash)

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