javaQQ
June 16th, 2001, 02:55 AM
I am trying to change the background colour of successive rows as another row is dragged over them. I have run into a problem.
" public boolean dragMoved( DragEvent e ) {
dragEntered( e );
return true;
}
public boolean dragEntered( DragEvent e ) {
int dragEnteredRow = table.rowAtPoint( e.getPoint() );
// dragEnteredRow.setForeground( selected );
// table.rowAtPoint( e.getPoint() ).setForeground( selected );
if ( dragEnteredRow == -1 ) {;
System.out.println( "out of bounds !!" );
} else {
System.out.println( "Drag Entered at : Row" + dragEnteredRow );
System.out.println( "" );
}
return true;
} "
The segment of code above works as indended (this stuff implements the Macintosh Drag and Drop API):
It prints out the following:
" Drag Entered at : Row4
... several times...
Drag Entered at : Row5
... several times...
Drag Entered at : Row6
... several times...
Drag Entered at : Row7
... etc. "
However, when I try to get it to change the rows' background colour:
" dragEnteredRow.setForeground( selected ); "
- OR -
" table.rowAtPoint( e.getPoint() ).setForeground( selected ); "
I get this error message from the compiler:
"... Can't invoke a method on a int.
dragEnteredRow.setForeground( selected ); ... "
- OR -
"... Can't invoke a method on a int.
table.rowAtPoint( e.getPoint() ).setForeground( selected ); ... "
How should I adjust the code to work properly?
Many thanks in advance for your solutions.
" public boolean dragMoved( DragEvent e ) {
dragEntered( e );
return true;
}
public boolean dragEntered( DragEvent e ) {
int dragEnteredRow = table.rowAtPoint( e.getPoint() );
// dragEnteredRow.setForeground( selected );
// table.rowAtPoint( e.getPoint() ).setForeground( selected );
if ( dragEnteredRow == -1 ) {;
System.out.println( "out of bounds !!" );
} else {
System.out.println( "Drag Entered at : Row" + dragEnteredRow );
System.out.println( "" );
}
return true;
} "
The segment of code above works as indended (this stuff implements the Macintosh Drag and Drop API):
It prints out the following:
" Drag Entered at : Row4
... several times...
Drag Entered at : Row5
... several times...
Drag Entered at : Row6
... several times...
Drag Entered at : Row7
... etc. "
However, when I try to get it to change the rows' background colour:
" dragEnteredRow.setForeground( selected ); "
- OR -
" table.rowAtPoint( e.getPoint() ).setForeground( selected ); "
I get this error message from the compiler:
"... Can't invoke a method on a int.
dragEnteredRow.setForeground( selected ); ... "
- OR -
"... Can't invoke a method on a int.
table.rowAtPoint( e.getPoint() ).setForeground( selected ); ... "
How should I adjust the code to work properly?
Many thanks in advance for your solutions.