Tips And
FAQs
Installation
Opening files with
Jigloo
Performance
Code
Parsing
Coding Tips
Productivity
Tips
Custom components
Miscellaneous
Problems
Installation
Why does Eclipse not recognize that Jigloo (or the latest version
of Jigloo) is installed?
Eclipse 3 has problems with it's plugin cache and sometimes does
not recognize that a plugin has been installed or upgraded. You can force
Eclipse to re-load all the plugin definitions by either:
- deleting or moving the eclipse/configuration
folder or
- starting eclipse by opening a command-line
console in the eclipse folder and executing "eclipse -clean -vmargs
-Xmx300m"
Opening
files with Jigloo
I have a Java class written with a different IDE/GUI builder -
how can I open it with Jigloo?
Locate your class in Eclipse's Package Explorer view, then
right-click on it and choose "Open with->Form Editor". Jigloo should open the
class.
I created a java class
with Jigloo, but now when I open it it opens just like a regular java class in
the java editor - how can I open it with
Jigloo?
Sometimes Eclipse does
not remember which editor it used previously to open a file, so you need to make
sure that your class is not opened in any editor in eclipse, then right-click on
the file and choose "Open with->Form
Editor".
Performance
Why does eclipse go really slowly with Jigloo
open?
By default, Eclipse does
not start with a large allocation of memory, and using Jigloo inside Eclipse to
open a large file can require 20-100MB of memory, so it is a good idea to allow
Eclipse to use about 200-400MB. One way to do this is to start Eclipse using a
script or batch file in the eclipse folder which executes the
command:
java -Xmx300m -cp startup.jar
org.eclipse.core.launcher.Main
or alternatively
executing the eclipse executable with these arguments:
eclipse -vmargs
-Xmx300m
Code
Parsing
Which methods will Jigloo
parse in my code?
Jigloo starts by parsing the constructors
of your class. If it finds a call to other class methods (eg, if
"createComponents" is a method of your class, and it is called from your
constructor), then those methods will be parsed by jigloo as it encounters the
method calls. Similarly, if those methods call other methods then those
methods will be parsed and so on. If, in the course of parsing the
constructors and all the methods called by the constructors etc, one of the
"GUI initialization" methods is parsed, then jigloo will stop parsing your
code.
The "GUI initialization" methods are by default {initGUI,
initComponents, initialize, open, createPartControl, createContents,
createControl and createDialogArea} but this list can be changed in the Jigloo Preferences
Page.
If, however, none of the "GUI initialization" methods
have been parsed then Jigloo will search the code for one of these methods (in
the order in which they appear in the list) and will parse the first one it
finds. Eg, if a class has methods "open" and "initialize", then "initialize"
will be parsed because it appears first in the "GUI
initialization" list. If none of the "GUI
initialization" methods appear in a class, then every method in the class will
be parsed.
Therefore if you always use a method "initializeGUI", say,
to create your code then you would add "initializeGUI" to the start of the
"GUI initialization"
list.
Which classes will Jigloo instantiate as it
parses my code?
As jigloo tries to render your GUI in
it's Form Editor, it needs to instantiate the visual classes used and also any
classes which are used as properties of these visual classes. Also, if a
method is called on a visual class then Jigloo will try and instantiate the
classes passed as parameters for this method. However, Jigloo will not
instantiate any other classes. If you find that Jigloo is instantiating a
class that you do not want it to instantiate, add this class to the "Forbidden
superclasses" list in the "Class creation" tab of the
Jigloo
Preferences Page.
Hiding code from
Jigloo.
Surround a block of code with a
//$hide>>$ and a //$hide<<$ comment and Jigloo will not parse that
block. Useful for designing a GUI which only appears if a condition is true or
false - hide the part of the conditional block which you don't want to design
with Jigloo just yet. Or for making sure that Jigloo doesn't try and
instantiate classes that you don't want to be instantiated (perhaps if they
try and make a DB connection or write to a file when
instantiated).
Coding tips
Use Jigloo's visual inheritance.
Instead of designing a lot of separate
but similar visual classes, design a base class with publically-accessible
buttons, panels etc, and use Jigloo to build extensions of this class. The
"Flowershop" examples which
Jigloo can create for you demonstrate visual
inheritance.
Re-formatting the
source code
Jigloo allows you to define how you want
GUI elements to be coded - either using getter methods for Swing elements (as
produced by JBuilder, the Eclipse VE project, etc) or as blocks separated by
braces, tagged comments or blank lines. Elements created by Jigloo will be
added to the code using the defined style, but to re-format the entire source
using the current style, right-click anywhere in the Form Editor and choose
"Source->Reformat code to current coding style". For more details,
refer to this
section.
Productivity
tips
Here are some tips, mainly involving key strokes,
which will increase your productivity.
Stopping
& starting code parsing.
Since Jigloo will automatically parse any
changes you make to your code, after a given delay, if you are making a lot of
code changes, you will save time by turning parsing off, and on again when you
have finished. Just hit Ctrl+Alt+P in the source
editor to toggle code parsing on and
off.
Multi-selecting elements (by CTRL and selection
marquee).

You can hold CTRL down when selecting
elements in the form editor and this will multi-select the elements.
In addition, you can hold SHIFT down while dragging the mouse and a
red rectangle (a selection marquee) will appear which you can drag around all
the elements you wish to select (see figures). Note that to select an
element you only need to intersect it with the marquee. Then any
properties you change, or any resizing or moving or copy/cut/pasting you do
will apply to all selected elements.
Select a component in the Outline by holding
Alt down while clicking in the source editor.
Normally, clicking or moving the cursor
over a piece of code (eg a property setter) selects the relevant component in
the form editor, but shows the java outline in the Outline view - holding Alt
down while clicking on the mouse shows the component tree in the Outline view
instead. This may not work on Linux systems where Alt may have a pre-defined
function.
Moving elements

Depending on the layout used
by a container, components can be rearranged inside a container by dragging
with the mouse.
Copying & pasting elements
You can hold CTRL down when dragging one
or more elements in the form editor and this will paste copies of the
elements.
Changing preferred sizes in GridBag and Form
Layouts
When using a GridBag or JGoodies Form
layout, normally resizing a component will change it's gridx/y/width/height values. However, by
holding SHIFT down when resizing an element you will change the preferredSize
property of an element, rather than it's gridx/y/width/height
values.
Changing an element's text property quickly.
Double-click on a button, label, group,
etc in the Form Editor and a text field will appear, allowing you to edit it's
text. This applies to any component which has a "text"
property.
Custom
components
How can I give my custom component an icon that will show up in
Jigloo's "Custom" palette, instead of the default java-bean
icon?
You need to create a
BeanInfo class for your custom class, and define the getIcon method. For an
example of how to do this, look at the Swing FlowerShop
example which you can create by hitting CTRL+N, then in the "New" wizard, select
"GUI Forms->Examples->Swing Inheritance/JavaBean (FlowerShop)
example".
Why doesn't my BeanInfo icon show up in
Jigloo?
Eclipse 3.0+ sets a
ContentHandlerFactory for URLConnections which doesn't seem capable of handling
gif images, and so the url.getContent() method in the SimpleBeanInfo loadImage
method does *not* return an ImageProducer, and hence the method does not return
an image. The method below, however, does work in Eclipse 3.0+ because it does
not depend on the url.getContent(), so to see your icon in Jigloo, simply add
this method to your BeanInfo, which will over-ride SimpleBeanInfo's loadImage
method.
public Image loadImage(String imgUrl)
{
try {
super.loadImage(imgUrl);
URL url =
getClass().getClassLoader().getResource(imgUrl);
if(url != null)
return new
ImageIcon(url).getImage();
} catch
(Exception e) {
e.printStackTrace();
}
return null;
}
Miscellaneous
Maximize the main editor by double-clicking on it's name
tag.
Fills Eclipse with the parts of Jigloo
essential for designing forms.
How to move
a component that is behind another component.
Say you have a JPanel inside a
JScrollPane and you want to move the JScrollPane - first select the
JScrollPane in the Outline view, then click and drag a blue
region of the selection border (which is made up of alternating black and blue
regions.
Working with SWT
classes not initially created by Jigloo
Many Java GUIs built by hand or by other
GUI builders can be modified succesfully by Jigloo, but for SWT GUIs you might
want to use some Jigloo tools to migrate the code to a more Jigloo-friendly
form:
- Migrate to using the SWTResourceManager to
manage fonts, colors and images - do this by right-clicking anywhere on the
Form Editor and choosing "Source->Convert to using
SWTResourceManager"
- Insert a new showGUI method which will display
the SWT Composite inside a Shell, using the size of the Composite (if it is
defined) to set the size of the Shell.
For more details, read
this.
Problems
Why can't I
change the location/size of my GUI
elements?
This is probably because of the layout
manager you are using. For example, if you have a JPanel which uses a
FlowLayout and you keep adding JButtons to it, then the JButtons will assume
their most natural sizes - you will be able to change their sizes and re-order
them but you will not be able to set their absolute position in the JPanel,
since that is determined by the JPanel's layout manager. If you want to set
the absolute position as well as size, then try using the Anchor or Absolute
layouts (for Swing), or Form or Absolute layouts (for SWT).
But reading
up a bit about the other layouts - the GridBag or JGoodies Form layouts for
Swing, or the Grid layout for SWT can be particularly useful - will allow you
to benefit from these layout managers.
Errors with properties or fields not being
recognized
<>If say
Java 1.5 is used to run Eclipse, then the properties of Swing components
generated by Jigloo will be those for Java 1.5, but if you use a Java 1.4 JRE
inside Eclipse to build and run programs then some properties added by the
Java 1.5 version will cause a compile error. The same goes for the SWT library
- if SWT version 3 is used to run Eclipse, but SWT 2 is used to run and build
programs inside Eclipse then you might get compile errors. The solution is to
use the same Java or SWT libraries to run Eclipse as to run programs inside
Eclipse.
Problems on Linux
If you have problems on Linux/GTK (such
as the "+" signs not expanding in the GUI Properties editor) then make sure
you have version 2.1.1 of GTK and it's accompanying packages (pango, glib,
atk) - a useful article, with download links is here: http://developer.gnome.org/doc/API/2.4/gtk/gtk-building.html