Author
How to change the row color
Tripti srivastava
Greenhorn
Joined: Feb 05, 2009
Posts: 2
Hello Experts,
I am trying to changes the color of few rows into red.
Tried following code for that. but it doesn't work.
private Recordset rst = null;
private Connection dbs = null;
int NewSqlCount=0;
{
rst = dbs.openRecordset( "SELECT * FROM CRVMReq " +
"where [Priority] like '" +Highest Priority + "%' " +
"AND ReqStatus like 'OPEN' " +
"and ReqStatusPool NOT like 'FOCUS' " +
“and ReadyTD like'YES'”+
"", AdoConst.adOpenDynamic, 0 );
if( rst.getRecordCount()>0 )
{
NewSqlCount=rst.getRecordCount();
For(int i=0;i<NewSqlCount ; i++)
{
ListCRVM.setForeground( Color.red ); //The problem is at this point.I don't know at this point how i will force to change the color of that rowset only.I hope there must be some propertry of recordset }
}
Else
{
NewSqlCount=0;
ListCRVM.setForeground( Color.black );
}
}
{
rst = dbs.openRecordset(select * from CRVMReq where priority!='Highest Priority' and ReqStatus like 'OPEN' and ReqStatusPool not like 'FOCUS'and ReadyTD='YES'+"", AdoConst.adOpenDynamic, 0 );
if( rst.getRecordCount()>0 )
{
NewSqlCount=rst.getRecordCount();
For(int i=0;i<NewSqlCount ; i++)
{
ListCRVM.setForeground( Color.black );
}
}
Else
{
NewSqlCount=0;
ListCRVM.setForeground( Color.black );
}
}
Michael Dunn
Ranch Hand
Joined: Jun 09, 2003
Posts: 4632
posted Feb 05, 2009 14:22:09
0
> I am trying to changes the color of few rows into red.
few rows of what?
JList
JComboBox
JTable
Other
generally done via a custom renderer
find the component you're working with under the "How To ..." section,
and there should be a working example
http://java.sun.com/docs/books/tutorial/uiswing/TOC.html
Tripti srivastava
Greenhorn
Joined: Feb 05, 2009
Posts: 2
public MultiColumnListBox ListCRVM = new MultiColumnListBox();
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
For us not familiar with MultiColumnListBox, which framework or library is it part of?
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
subject: How to change the row color