super( "Copy to clipboard" );
}
public void actionPerformed( ActionEvent e )
{
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
StringBuffer buf = new StringBuffer();
int[] selectedIndices = logList.getSelectedIndices();
if( selectedIndices.length == 0 )
{
for( int c = 0; c < logList.getModel().getSize(); c++ )
{
buf.append( logList.getModel().getElementAt( c ).toString() );
buf.append( "\r\n" );
}
}
else
{
for( int c = 0; c < selectedIndices.length; c++ )
{
buf.append( logList.getModel().getElementAt( selectedIndices[c] ).toString() );
buf.append( "\r\n" );
}
}
StringSelection selection = new StringSelection( buf.toString() );
clipboard.setContents( selection, selection );
}