Loading and Displaying an Image (Visual J++)

Take the following steps to start a project and to add some code that displays an image on the main form:

1. Start Visual J++, Choose Windows Application and click Open..

2. Add the LEAD Control to your project.

On the Tools pull-down menu, use the Customize Toolbox option, choose the ActiveX Controls tab and select the LEAD Main ActiveX Control (16).

3. image\btnlead.gif Select the LEAD control; then add the control to your main form. Size and position the control as you want it to appear at run time.

4. image\btncmd.gif Add a command button to your form and name it as follows:

Name

Text

LoadLead

Load Image

5. Add the following initialization code to the main form's constructor right under the TODO comment. In online help, you can use the Edit pull-down menu to copy the block of code.

 

// Set defaults for displaying the image.
// These are all persistent properties that can be set in the properties box.
LEAD1.setAppearance( (short) LTOCXU.AppearanceConstants.APPEARANCE_FLAT );
LEAD1.setBorderStyle( (short) 1 );
LEAD1.setBackColor( new Color( 255, 255, 125 ) );
LEAD1.setPaintDither( (short) LTOCXU.PaintDitherConstants.PAINTDITHER_DIFFUSION );
LEAD1.setPaintPalette( (short) LTOCXU.PaintPaletteConstants.PAINTPALETTE_AUTO );
LEAD1.setAutoRepaint( true );
LEAD1.setAutoSize( false );
LEAD1.setAutoSetRects( true );
LEAD1.setPaintSizeMode( (short) LTOCXU.PaintSizeModeConstants.PAINTSIZEMODE_FIT );

6. Code the LoadLead button's click event as follows:

private void LoadLead_click(Object source, Event e)
{
   LEAD1.Load( "c:\\lead\\images\\image1.cmp", (short) 0, (short) 0, (short) 1 );
}

7. Run your program to test it.

8. Save the project to use as a starting point for other tasks in this tutorial.