Available in the LEADTOOLS Imaging toolkit. |
KeyPress example for Visual J++
This example demonstrates the KeyPress event.
private void LEAD1_keyPress(Object source, KeyEvent e)
{
// This example uses the KeyPress event to implement a custom scale mode.
// There is no particular reason to put this code in this event, except that
// we needed examples of both the event and the scale mode.
if( e.keyChar == 67 ) // Uppercase C
{
// This example sets an custom scale mode and uses it to crop the
// display. Keep in mind that the actual height and width do not change.
// Only the unit of measure changes.
// Change the scale so that origin is moved one-third right and one-third down
LEAD1.setScaleLeft( -1 );
LEAD1.setScaleTop( -1 );
LEAD1.setScaleWidth( 3 );
LEAD1.setScaleHeight( 3 );
// Crop the display so that it takes up the middle third of the height and width
LEAD1.setDstClipLeft( 0 );
LEAD1.setDstClipTop( 0 );
LEAD1.setDstClipWidth( 1 );
LEAD1.setDstClipHeight( 1 );
LEAD1.ForceRepaint();
}
}