1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
3
* Copyright (c) 2007 Sun Microsystems, Inc. All rights reserved.
4
* Use is subject to license terms.
9
<title>Modifying GUI Source Code</title>
10
<link rel="StyleSheet" href="nbdocs://org.netbeans.modules.usersguide/org/netbeans/modules/usersguide/ide.css" type="text/css">
13
<h2>Modifying GUI Source Code</h2>
14
<p><small><a href="#seealso">See Also</a></small></p>
15
<p> The IDE automatically generates blue guarded blocks of code as you create
16
your GUI form in the GUI Builder. However, you can modify the way initialization
18
and even write custom code to be placed
19
within the initialization code. </p>
21
<h3>Modifying Code Generation for Form Components</h3>
22
<p>You can modify the way initialization code is generated for a component,
23
form, or component property by editing its Code properties in the Properties
24
window. In addition, you can write custom code and specify where it should be
25
placed within the initialization code. </p>
26
<p><b>To modify a form component's guarded block:</b></p>
28
<li>In the Inspector window, select the component whose initialization code
30
<li>Click the Code button at the top of the Properties window to view the Code
33
the property you wish to edit and enter the desired value.<p>The IDE updates
34
the selected component's guarded code block with the new value.
38
<h3>Modifying Code Generation for a Property</h3>
39
<p> The IDE enables form component properties to be initialized in more ways
40
than simply setting static values. </p>
41
<p>The IDE enables you to initialize property values from: </p>
43
<li>A static value you define</li>
44
<li>A component written to the JavaBeans architecture</li>
45
<li>A property of another component on the form</li>
46
<li>A call to a method of the form or one of its components. You can choose
47
from a list of methods that return the appropriate data type.</li>
48
<li>Code you define, which will be included in the generated code</li>
51
<p><b>To modify the initialization code generated for a component's property:</b></p>
53
<li> Select the component in the Inspector window.</li>
54
<li>Click the Properties button at the top of the Properties window. </li>
55
<li> Select the property for which you would like to modify the initialization
57
<li> Click the ellipsis (...) button to bring up the Property Editor dialog
59
<li> Select Form Connection from the Select Mode combo box. </li>
60
<li> In the Property Editor, select the type of initialization code you would
61
like to add (Value, Bean, Property, Method Call, or User Code).
63
<li> If you select Value or User Code, you must add a static value or your
64
custom initialization code in the field provided.
65
<li> If you select Bean, Property, or Method Call, you can select from
66
a list of valid options.
68
The IDE adds the new code to the selected component's guarded block.
69
<!--<p> These options (Value, Bean, and so on) are the same options used in Step
70
3 of the Connection Wizard. The options are described in more detail on
71
the corresponding help page for the Connection Wizard, <a href="">Connection Wizard: Enter Parameters</a>.-->
75
<li> You can also place custom code before or after
76
a property's initializer. To do this, follow steps 1 through 4 above, and then
77
click the Advanced button to bring up the Advanced Initialization Code
78
dialog box. Type your custom pre-initialization code, post-initialization
79
code, or both in the fields provided. </li>
82
<h3>Modifying GUI Form Code Outside of the IDE</h3>
83
<p>In the IDE each form is comprised of two files:</p>
85
<li> A <tt>.java</tt> file, which contains the form's Java source code. </li>
87
A <tt>.form</tt> file, which stores the information that is used to generate the
88
<tt>.java</tt> file when you make changes to the form in the GUI Builder.
89
This file does not need to be distributed with your application. If you delete
90
this file, you can no longer use the GUI Builder to change the form.
93
<p>You can edit the <tt>.java</tt> files using external editors (not
94
while the form is being edited in the IDE), with the following exceptions:</p>
96
<li>Do not modify the content of the <tt>initComponents()</tt> method. The body of
97
this method is always regenerated when the form is opened in the IDE.</li>
99
Do not remove or modify any of the special comments placed in the source by the IDE's
100
GUI Builder (<tt>// GEN-...</tt>). They are required for the form to open
101
correctly. These comments are not visible inside the IDE's Source Editor.</li>
102
<li>Do not modify the headers or footers of event handlers.</li>
106
<dt><a name="seealso">See Also</a></dt>
107
<dd><a href="gui_editcomponentprops.html">Editing Component Properties</a> </dd>
108
<dd><a href="gui_configuring.html">Configuring the GUI Builder</a> </dd>
109
<dd><a href="gui_about.html">About Java GUIs</a> </dd>
113
<small><a href="../credits.html">Legal Notices</a></small>
114
<table border="0" cellpadding="50">