index.html

来自「eclipse插件jigloo」· HTML 代码 · 共 485 行 · 第 1/2 页

HTML
485
字号
and surround by a JPanel and set the JPanel's layout to GroupLayout.
You can resize the panel and move/resize the elements till they look
similar to what is shown below.<br>
<br>
Then edit the JPanel's "Border" property to create a titled border with
some text.<br>
<img src="titled_border.png" title="" alt=""
 style="width: 706px; height: 439px;"><br>
<br>
</small></div>
<small><span style="font-weight: bold;">Surround JPanel by JTabbedPane
then copy and paste the JPanel into the JTabbedPane</span><br>
</small>
<div style="margin-left: 40px;"><small>This just demonstrates copy and
paste - or you could try cutting and pasting multiple components too<br>
<br>
</small></div>
<small><span style="font-weight: bold;">Add JMenuBar with File and Help
menus<br>
<br>
</span></small>
<div style="margin-left: 40px;"><small>Now something a bit more useful
- add a JMenuBar - using the "Menu" palette. <br>
<img src="menu_bar.png" title="" alt=""
 style="width: 466px; height: 412px;"></small><small><br>
<br>
Now double-click on the
"jMenu1" menu and change the text to "File", then add a new "Help"
JMenu to
the menu bar.<br>
<img src="menu2.png" title="" alt="" style="width: 79px; height: 57px;"><br>
</small><small><br>
</small></div>
</div>
<div style="margin-left: 40px; font-family: tahoma;"><small><span
 style="font-weight: bold;">Add an "About" action (and menu item) to
the Help menu</span><br>
</small>
<div style="margin-left: 40px;"><small>Select the "AbstractAction" icon
from the "More components" palette, and then click diretly on the
"Help" menu. Enter "Action" for the action's text property (and call
the action "aboutAction").<br>
<img src="aboutAction1.png" title="" alt=""
 style="width: 773px; height: 266px;"><br>
<br>
If you look at the Outline view you will see that a JMenuItem has been
added to the Help menu and the aboutAction has been associated with it.
The JMenuItem's text will also take on the value of the
AbstractAction's text property.<br>
<img src="aboutAction2.png" title="" alt=""
 style="width: 261px; height: 241px;"><br>
<br>
</small></div>
</div>
<div style="margin-left: 40px; font-family: tahoma;"><small><span
 style="font-weight: bold;">Test out the form using the "Preview" button</span><br>
</small>
<div style="margin-left: 40px;"><small>Hit the "Preview" button in the
Outline view and click on the "Help" menu - the "About" item should
show itself.<br>
You can also resize the form and check out how it behaves.<br>
If an element expands horizontally or vertically but you would rather
it not, then make sure the appropriate "Expands" option is not
selected, and then also try the "Reset to default width/height"
options, which should ensure that an element keeps it's default width
or height.<br>
<img src="preview.png" title="" alt=""
 style="width: 501px; height: 406px;"><br>
<br>
</small></div>
</div>
<small><font face="Helvetica, Arial, sans-serif"
 style="font-family: tahoma;"><span style="font-weight: bold;">Creating
the "About" dialog and linking it to the main frame<br>
<br>
</span></font></small>
<div style="margin-left: 40px; font-family: tahoma;"><small><span
 style="font-weight: bold;">Add JDialog</span><br>
</small>
<div style="margin-left: 40px;"><small>Either right-click on a region
outside of the main JFrame and choose "Add container-&gt;JDialog" or
choose the JDialog icon from the "Containers" menu and click somewhere
outside of the main JFrame.<br>
This will add a totally separate JDialog to the class. <br>
<img src="add_dialog.png" title="" alt=""
 style="width: 232px; height: 91px;"><br>
<br>
Note the JDialog node on the Outline view. The red border indicates
that this element is the "active" root element, and is being shown in
the form editor.<br>
<img src="outline_dlg.png" title="" alt=""
 style="width: 182px; height: 120px;"><br>
<br>
Try clicking on the "this"
node - the main form will appear. Then click on the "jDialog1" node and
get back to the JDialog.<br>
This is how you can use Jigloo to design multiple "root" elements in
the same Java class.<br>
<br>
</small></div>
<small><span style="font-weight: bold;">Set GroupLayout and add label
and OK button</span><br>
</small>
<div style="margin-left: 40px;"><small>...using the techniques used
above.<br>
<img src="aboutDialog.png" title="" alt=""
 style="width: 252px; height: 133px;"><br>
<br>
<br style="font-weight: bold;">
</small></div>
<small><span style="font-weight: bold;">Set horizontalAlignment to
CENTER (and make horizontalAlignment a Basic property)<br>
<br>
</span></small>
<div style="margin-left: 40px;"><small>Select the label, and in the
"GUI Properties" editor,
open the "Expert" node and scroll to "horizontalAlignment". Change this
to "CENTER".<br>
Now, if you think you will be using this property failry often then
right-click on it and choose "Set property category for
horizontalAlignment-&gt;Basic".<br>
<img src="prop_category.png" title="" alt=""
 style="width: 458px; height: 236px;"><br>
<br>
The horizontalAlignment property (for all elements that have it) will
now appear under the "Basic"
property node.<br>
<br>
</small></div>
<small><span style="font-weight: bold;">Add action to dialog's OK
button with code to dispose dialog<br>
<br>
</span></small>
<div style="margin-left: 40px;"><small>Now, add a "Close" action to the
form - again, choose "AbstractAction" from the "More Components"
palette but this time (for a change) click anywhere on the editor
outside of the JDialog. Set
the text to "OK" and the name to closeAboutAction. Then go to
the Outline view and drag the newly-added action (under the "Extra
components" node) to the dialog's "OK" button. <br>
<img src="drag_action.png" title="" alt=""
 style="width: 300px; height: 209px;"><br>
<br>
The action should now
appear twice - once under the "Extra components" node and once under
the dialog's "OK" button. If you wish to disassociate the action with
the OK button, just select the action under the button and hit the
"delete" key. A prompt dialog will ask you if you really want to delete
the action but it will really just remove the action from the button.
If you really want to delete the action, select it first under the
"Extra components" node.<br>
<br>
Now, find the close action under the OK button in the Outline view and
double-click on it. The source code will appear and the close action's
code will be highlighted.<br>
<br>
<img src="action_code1.png" title="" alt=""
 style="width: 690px; height: 225px;"><br>
Edit the code to add <br>
</small>
<pre>getJDialog1().dispose()</pre>
<small>as shown, so that the dialog will close when the OK button is
hit.<br>
<br style="font-weight: bold;">
</small></div>
</div>
<div style="margin-left: 40px; font-family: tahoma;"><small><span
 style="font-weight: bold;">Add code to open dialog from the aboutAction</span><br>
</small></div>
<div style="margin-left: 80px; font-family: tahoma;"><small>But how
will the dialog appear in the first place? We will add code to the
aboutAction, so double-click on the aboutAction in the Outline view.
Then add the code:<br>
</small>
<pre>getJDialog1().pack();</pre>
<pre>getJDialog1().setLocationRelativeTo(null);</pre>
<pre><small><big>getJDialog1().setVisible(true);</big><br></small></pre>
<small></small></div>
<small><font face="Helvetica, Arial, sans-serif"
 style="font-family: tahoma;">
</font></small>
<div style="margin-left: 40px; font-family: tahoma;"><small><span
 style="font-weight: bold;">Add an accelerator for the "About" action</span><br>
</small>
<div style="margin-left: 40px;"><small>We want people to be able to
easily see what this application is about, right? Well, maybe not, but
for the purposes of this demo we will associate an "accelerator" with
the about action.<br>
Select the about action, and in the GUI Properties editor, select the
"accelerator" property - it will be under the "Expert" node, but you
might want to move it to the "Basic" node, as above with the
horizontalAlignment property. Then hold CTRL+SHIFT+A down and you
should should see "ctrl shift A"
appear in the "accelerator" value. <br>
<img src="accelerator.png" title="" alt=""
 style="width: 249px; height: 232px;"></small><small><br>
Then release the keys and hit "return" and the code will be
updated.</small><br>
<small>You can also associate a mnemonic with the action in a similar
way - a
mnemonic allows a user to select a menu item by hitting a key (say, A
in this case), but only when the parent menu is visible.<br>
</small></div>
</div>
<small><span style="font-weight: bold; font-family: tahoma;"><br>
Running the app<br>
<br style="font-family: tahoma;">
</span></small>
<div style="margin-left: 40px; font-family: tahoma;"><small>Congratulations!
You are all done! Hit CTRL+S to save the form. A quick way to run the
main method of the class you
just created is to click the "Run" button in the Outline view.<br>
<img src="run.png" title="" alt="" style="width: 238px; height: 55px;"><br>
<br>
The main frame should appear in the middle of the screen. <br>
<br>
Note: If elements do not appear to be a "comfortable" size when the app
is run, try selecting them in the Jigloo editor and choosing "Reset to
default width/height" from the alignment menu.<br>
<br>
</small><small>Try hitting CTRL+SHIFT+A - the about menu should appear
- woo hoo! <br>
And
when your curiosity has been thoroughly satisfied you can click the
"OK" button,
causing the dialog to disappear.<br>
</small><br>
<small>Note: if you get an "java.lang.UnsupportedClassVersionError: Bad
version number in .class file" message, make sure your compiler
compliance level (set using the properties dialog for your project) is
the same as the version of Java you are running your class with.<br>
<img src="compliance.png" title="" alt=""
 style="width: 637px; height: 221px;">&nbsp;<br>
<br>
<br>
</small></div>
<p style="font-family: tahoma;"><small><br>
<br>
</small></p>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?