Creating Custom Code Panels Using NetBeans

searchcoilSoftware and s/w Development

Aug 15, 2012 (5 years and 7 days ago)

638 views

Creating Custom Code Panels Using
NetBeans

InstallAnywhere allows developers to include custom code panels in their installers. Custom
code panels extend com.zerog.ia.api.pub.CustomCodePanel and allow installation
developers to design and employ custom panels in their installers. In this example, we’ll
build a relatively simple panel for choosing the install drive.
Using the NetBeans IDE
The NetBeans IDE provides the tools necessary to quickly prototype and easily refactor
custom installer panels.
These instructions are intended to provide a blueprint for the general creation of a custom
code panel, but screen captures included here reflect the creation of a Choose Install Drive
panel.
Sample Code
Refer to the sample code (included with the download of this white paper) for a complete,
working example of this process. The sample code for this panel is in the
ChooseInstallDriveNetBeans.zip
archive.
Requirements
The following tasks require you have NetBeans IDE installed (version 5.5 or newer
recommended) and properly configured. For more information on this tool, visit
http://www.netbeans.org

You must also ensure that the IAClasses.zip library is on your classpath. IAClasses.zip is
installed with InstallAnywhere at \IAClasses.zip.
Tip: If your custom code panel uses the ISMP Service Layer APIs,
remember to add services.jar to your classpath. You can find services.jar
at \resource\services\services.jar.

Task: To create a custom code panel with NetBeans
1.In the NetBeans IDE, create a new Java Application project.

InstallAnywhere Tips & Tricks
©2002-2007 Macrovision Corporation. All rights reserved.
1 of 10


Figure 1-1: Creating a new project.


2.Create a new JPanel form. Right-click on Source Package, and choose New >
JPanel Form. The New JPanel Form dialog box opens.



Figure 1-2: Creating a new panel.


InstallAnywhere Tips & Tricks
©2002-2007 Macrovision Corporation. All rights reserved.
2 of 10
3.Configure the JPanel form. In the New JPanel Form dialog box, provide the following
entries:

a.Class Name: ChooseInstallDrivePanel

b.Package: com.macrovision.ia.customcode.panel



Figure 1-3: Configuring the new panel.


4.Layout the panel components.

InstallAnywhere Tips & Tricks
©2002-2007 Macrovision Corporation. All rights reserved.
3 of 10


Figure 1-4: Adding a label, a combo box, and a button to the panel.


5.Show the source code. On the ChooseInstallDrivePanel.java tab, click Source.

InstallAnywhere Tips & Tricks
©2002-2007 Macrovision Corporation. All rights reserved.
4 of 10


Figure 1-5: Showing the source.


6.Add import com.zerog.ia.api.pub.* to list of imports.



Figure 1-6: Importing com.zerog.ia.api.pub.*


7.Make ChooseInstallDrivePanel a subclass of the CustomCodePanel class instead of
the JPanel class. Change extends JPanel to extends CustomCodePanel.

InstallAnywhere Tips & Tricks
©2002-2007 Macrovision Corporation. All rights reserved.
5 of 10


Figure 1-7: Changing ChooseInstallDrivePanel.


8.From the Source menu, choose Override Methods... The Override and Implement
Methods dialog box opens.



Figure 1-8: Opening the Override and Implement Methods dialog box.


9.On the Override and Implement Methods dialog box, select getTitle, okToContinue,
and setupUI, and click OK. (Other methods are optional.)

InstallAnywhere Tips & Tricks
©2002-2007 Macrovision Corporation. All rights reserved.
6 of 10


Figure 1-9: Choosing methods to override/implement.


10.Move the initComponents() method call to setupUI and change setupUI to return true.




Figure 1-10: Modifying setupUI().


11.Implement getTitle.
InstallAnywhere Tips & Tricks
©2002-2007 Macrovision Corporation. All rights reserved.
7 of 10



Figure 1-11: Implementing getTitle().


12.Implement okToContinue.



Figure 1-12: Implementing okToContinue().


13.Add a Custom Code panel to an InstallAnywhere project.

In InstallAnywhere’s Advanced Designer,

a.Click Choose JAR or ZIP, browse to your JAR, and click Open.

b.In the Class field, enter a fully-qualified class name. In this example, we use
com.macrovision.ia.customcode.panels.ChooseInstallDrivePanel.

Note: On the Custom Code customizer, remember to add swing-
layout-1.0.jar to the Dependencies list. You can find swing-
layout-1.0.jar at \platform6\modules\ext. Choose Add jar or zip,
browse to swing-layout-1.0.jar, and click Open.


InstallAnywhere Tips & Tricks
©2002-2007 Macrovision Corporation. All rights reserved.
8 of 10


Figure 1-13: Adding the Custom Code panel.


14.Package and execute.



InstallAnywhere Tips & Tricks
©2002-2007 Macrovision Corporation. All rights reserved.
9 of 10
Figure 1-14: Testing the Choose Install Drive panel.



Note: A special thanks goes out to the team at BMC Software in Sunnyvale
who helped create this document.

For more information
Additional information about CustomCodePanel methods, such as getTitle, okToContinue,
and setupUI, is available as Javadocs in your InstallAnywhere folder.
Note: You can also open Javadocs from InstallAnywhere by clicking Open
Javadocs on the Custom Code panel customizer.

For more information about using InstallAnywhere, open your local copy of the
InstallAnywhere Help Library or go to http://helpnet.macrovision.com
and click the link for
InstallAnywhere.
InstallAnywhere Tips & Tricks
©2002-2007 Macrovision Corporation. All rights reserved.
10 of 10