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 > UI , Look and Feel, Colors, Navigation, font, Locale Post New Topic   Post A Reply
background selected row printer friendly version
next newest post | next oldest post
Author Messages
raschetti
Private First Class

Gender: Unspecified
Location:
Registered: Aug 2005
Status: Offline
Posts: 19

Click here to see the profile for raschetti Send email to raschetti Send private message to raschetti Find more posts by raschetti Edit or delete this message Reply w/Quote
Posted Friday, November 11, 2005 @ 11:45:11  

I set a skin on a table for change the default for selected row. (I want bagground white and foregroud red Bold)

In skin intreface I can't impose the fotn size of selected row so I used CellPropetriesModel whit setFont on selected row.
There is a Skin.FOCUS_CELL_FONT properties for skin?

Now I've a problem : the tableModel set different background color depending (??? my terrible english) of cell value
example in myTableModel:
public java.awt.Color getBackground(int row, int col) {
if (this.getColIndex("idcentrale") == col) {
if ( ( (String) table.getValueAt(row, col)).equals("1"))
return Color.BLUE;
if ( ( (String) table.getValueAt(row, col)).equals("2"))
return Color.cyan;
if ( ( (String) table.getValueAt(row, col)).equals("3"))
return Color.green;
}

The problem is : the selected row skip the table model getBackground propeties but it use the skin properties.
So I've all row of table right Color minus the selected row that have white background on all columns.
Is there another possibility for the required results?

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 Saturday, November 12, 2005 @ 01:04:49  

Please download the latest version, two new methods are added in CellPropertiesModel class to handle this case.

public Color getSelectionForeground(int row, int col)
public Color getSelectionBackground(int row, int col)

raschetti
Private First Class

Gender: Unspecified
Location:
Registered: Aug 2005
Status: Offline
Posts: 19

Click here to see the profile for raschetti Send email to raschetti Send private message to raschetti Find more posts by raschetti Edit or delete this message Reply w/Quote
Posted Monday, November 14, 2005 @ 10:56:57  

the single selected cell is white too.
my customer is very very very precise
raschetti
Private First Class

Gender: Unspecified
Location:
Registered: Aug 2005
Status: Offline
Posts: 19

Click here to see the profile for raschetti Send email to raschetti Send private message to raschetti Find more posts by raschetti Edit or delete this message Reply w/Quote
Posted Monday, November 14, 2005 @ 13:04:14  

a big problem.
In my table model I have:

if ( ( (BigDecimal) table.getValueAt(row, getColIndex("CON"))).compareTo(new BigDecimal(0)) !=
0) {
return new Color(255, 255, 193);
}

if I drag a String column before the original 'CON' column index an ClassCast Exception.
The method getColIndex is :

public int getColIndex(String colonna) {
try {
colonna = colonna.toUpperCase();
if (table.getColumnByDatabaseName(colonna) == null) {
throw new Exception("undefined column " + colonna);
}
return table.getColumnByDatabaseName(colonna).getModelIndex() - 1;
}
catch (Exception ex) {
ex.printStackTrace();
return 0;
}
}

the column index is the database col index and not the table index.
Same result whit getColumnByHeaderName.

[Edit by raschetti on Tuesday, November 15, 2005 @ 12:04: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 Monday, November 14, 2005 @ 15:17:57  

Could you post the full stack trace of classcastexception.

Is this the first time you are hitting this classcast exception? If you use the old jar, Are you getting the class cast exception?

raschetti
Private First Class

Gender: Unspecified
Location:
Registered: Aug 2005
Status: Offline
Posts: 19

Click here to see the profile for raschetti Send email to raschetti Send private message to raschetti Find more posts by raschetti Edit or delete this message Reply w/Quote
Posted Tuesday, November 15, 2005 @ 08:39:56  

Version 2.0.5.23

QuickTable Version : QuickTable 2.0.5.23
Executing row count sql=select count(*) from beton.giornale where data='2005-11-15' and chiuso='N'
Database meta data information received from jdbc driver
Column 1: Name: IDCENTRALE
ReadOnly: false
Data Type: CHAR
Length: 1
Column 2: Name: H
ReadOnly: false
Data Type: CHAR
Length: 5
Column 3: Name: POMPATO
ReadOnly: false
Data Type: CHAR
Length: 1
Column 4: Name: COMUNICAZIONE
ReadOnly: false
Data Type: VARCHAR
Length: 5
Column 5: Name: IDCLIENTE
ReadOnly: false
Data Type: DECIMAL
Precision: 6
Scale: 0
Signed: true
Column 6: Name: RAGIONESOCIALE
ReadOnly: false
Data Type: CHAR
Length: 35
Column 7: Name: IDCANTIERE
ReadOnly: false
Data Type: DECIMAL
Precision: 3
Scale: 0
Signed: true
Column 8: Name: DESCANTIERE
ReadOnly: false
Data Type: CHAR
Length: 35

(the message is too long there are more field )

Column 14: Name: CON
ReadOnly: false
Data Type: DECIMAL
Precision: 5
Scale: 1
Signed: true

(the message is too long there are more field )

QuickTable Version : QuickTable 2.0.5.23
Executing row count sql=select count(*) from beton.giornale where data='2005-11-15' and chiuso='N'
java.lang.ClassCastException: java.lang.String
at beton.Giornale_GiornaleTableModel.getBackground(Giornale.java:1622)
at quick.dbtable.DBTableCellRenderer.getTableCellRendererComponent(DBTableCellRenderer.java:344)
at javax.swing.JTable.prepareRenderer(JTable.java:3731)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1149)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4795)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4748)
at javax.swing.JComponent._paintImmediately(JComponent.java:4692)
at javax.swing.JComponent.paintImmediately(JComponent.java:4495)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
java.lang.ClassCastException: java.lang.String
.........................................(one for any row in table)

******************************************************************************************

Version 2.0.5.24

QuickTable Version : QuickTable 2.0.5.24
Executing row count sql=select count(*) from beton.giornale where data='2005-11-15' and chiuso='N'
Database meta data information received from jdbc driver
Column 1: Name: IDCENTRALE
ReadOnly: false
Data Type: CHAR
Length: 1
Column 2: Name: H
ReadOnly: false
Data Type: CHAR
Length: 5
Column 3: Name: POMPATO
ReadOnly: false
Data Type: CHAR
Length: 1
Column 4: Name: COMUNICAZIONE
ReadOnly: false
Data Type: VARCHAR
Length: 5
Column 5: Name: IDCLIENTE
ReadOnly: false
Data Type: DECIMAL
Precision: 6
Scale: 0
Signed: true
Column 6: Name: RAGIONESOCIALE
ReadOnly: false
Data Type: CHAR
Length: 35
Column 7: Name: IDCANTIERE
ReadOnly: false
Data Type: DECIMAL
Precision: 3
Scale: 0
Signed: true
Column 8: Name: DESCANTIERE
ReadOnly: false
Data Type: CHAR
Length: 35

(the message is too long there are more field )

Column 14: Name: CON
ReadOnly: false
Data Type: DECIMAL
Precision: 5
Scale: 1
Signed: true

(the message is too long there are more field )

QuickTable Version : QuickTable 2.0.5.24
Executing row count sql=select count(*) from beton.giornale where data='2005-11-15' and chiuso='N'
Column :1 Warning: Your JDBC driver or your setting, gives the scale of the column data as 0.
Column :1 Warning: If scale is zero, you cannot enter any digits after the '.'
Column :1 Using yourQT.getColumn(i).setScale(2) change the scale, if needed
Hint about Precision/Scale: Lets say, the numeric value is of type 1234.56, then precision is 6 (total number of digits) and scale is 2 (number of digits after the dot).
To hide this message,refer to DBTable.showCriticalWarnings api doc.
Column :1 Warning: Your JDBC driver or your setting, gives the scale of the column data as 0.
Column :1 Warning: If scale is zero, you cannot enter any digits after the '.'
Column :1 Using yourQT.getColumn(i).setScale(2) change the scale, if needed
Hint about Precision/Scale: Lets say, the numeric value is of type 1234.56, then precision is 6 (total number of digits) and scale is 2 (number of digits after the dot).
To hide this message,refer to DBTable.showCriticalWarnings api doc.
Column :1 Warning: Your JDBC driver or your setting, gives the scale of the column data as 0.
Column :1 Warning: If scale is zero, you cannot enter any digits after the '.'
Column :1 Using yourQT.getColumn(i).setScale(2) change the scale, if needed
Hint about Precision/Scale: Lets say, the numeric value is of type 1234.56, then precision is 6 (total number of digits) and scale is 2 (number of digits after the dot).
To hide this message,refer to DBTable.showCriticalWarnings api doc.
Column :1 Warning: Your JDBC driver or your setting, gives the scale of the column data as 0.
Column :1 Warning: If scale is zero, you cannot enter any digits after the '.'
Column :1 Using yourQT.getColumn(i).setScale(2) change the scale, if needed
Hint about Precision/Scale: Lets say, the numeric value is of type 1234.56, then precision is 6 (total number of digits) and scale is 2 (number of digits after the dot).
To hide this message,refer to DBTable.showCriticalWarnings api doc.
java.lang.ClassCastException: java.lang.String
at beton.Giornale_GiornaleTableModel.getBackground(Giornale.java:995)
at beton.Giornale_GiornaleTableModel.getSelectionBackground(Giornale.java:1004)
at quick.dbtable.DBTableCellRenderer.getTableCellRendererComponent(DBTableCellRenderer.java:347)
at javax.swing.JTable.prepareRenderer(JTable.java:3731)
at javax.swing.plaf.basic.BasicTableUI.paintCell(BasicTableUI.java:1149)
at javax.swing.plaf.basic.BasicTableUI.paintCells(BasicTableUI.java:1051)
at javax.swing.plaf.basic.BasicTableUI.paint(BasicTableUI.java:974)
at javax.swing.plaf.ComponentUI.update(ComponentUI.java:142)
at javax.swing.JComponent.paintComponent(JComponent.java:541)
at javax.swing.JComponent.paint(JComponent.java:808)
at javax.swing.JComponent.paintWithOffscreenBuffer(JComponent.java:4795)
at javax.swing.JComponent.paintDoubleBuffered(JComponent.java:4748)
at javax.swing.JComponent._paintImmediately(JComponent.java:4692)
at javax.swing.JComponent.paintImmediately(JComponent.java:4495)
at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:410)
at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:117)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:454)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)
java.lang.ClassCastException: java.lang.String
.........................................(one for any row in table)

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 Wednesday, November 16, 2005 @ 02:37:17  

If you allow user to rearrange the columns, then you should use one of the following methods to convert the column index returned by getColumnByDatabaseName to appropriate index.

public int getOriginalColumnIndex(int colIndex)
If the columns have been moved/rearranged by the user, this method will return the original/created column index for a given (moved) column

public int getCurrentIndexForOriginalColumn(int colIndex)
If the columns have been moved/rearranged by the user, this method will return the new moved location of a original/created column index

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