File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How to change the row color Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to change the row color " Watch "How to change the row color " New topic
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
> 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: 19541
    
  16

For us not familiar with MultiColumnListBox, which framework or library is it part of?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to change the row color
 
Similar Threads
SQLException: No data found
Not able to apply decode function to my query
ListCellRenderer!!!Help!!
How to use ItemStateChanged()?
Method X not found in class Y error