Article View: borland.public.jbuilder.java.swing
Article #9377Re: [Q] How to import visual design from Visual Cafe to JBuilder ???
From: Paul Furbacher [TeamB]
Date: Fri, 31 Mar 2000 00:00
Date: Fri, 31 Mar 2000 00:00
88 lines
4089 bytes
4089 bytes
Norbert Ebel wrote:
> I work on a project containing a huge number of visual elements using
> Visual Caf�.
> Now, I tried JBuilder on Linux and it seems to be stable enough to work,
> so
> I would like to port the whole project from Caf� to JBuilder.
>
> I already managed to import the sources and even compile, run and debug
> the project :)
> The problem arises when I try to obtain the visual part of the
> application within the designer.
> In fact, no visual components generated by Cafe are recognized by
> JBuilder.
>
> Did anybody succeed the port of this kind ?
> Any information will be welcome -
There is no automatic way of doing this conversion.
VCafe uses a "you can only put certain code here" approach,
with special markers to tell its visual designer what to do.
JBuilder has never done this -- quite thankfully. The only
requirements are these:
1. You declare and instantiate your member UI elements using
zero-parameter constructors, as in this example:
public class MyFrame extends Frame {
Panel panel1 = new Panel();
Label label1 = new Label();
...
2. Your class must have a public zero-parameter constructor:
public MyFrame() {
...
}
in which it calls the "jbInit()" method.
3. The setting of properties by the JBuilder "Designer" places code in
the "jbInit()" method. You cannot place code which changes UI element
code in other methods, and invoke those methods from "jbInit()". The
Designer introspects your class for its parameter and its jbInit() method
and uses those along to create the "live" instance you see in the
Designer.
So, what do you do to convert the VCafe source to something the JBuilder
Designer can interpret?
0. Try this exercise to get an idea of where JBuilder is placing code:
a. Pick your simplest panel/frame in your VCafe project, and open
it in VCafe's designer.
b. Mock it up in JBuilder.
c. Compare the placement of code in the two files.
After that you should know that you will be doing these steps:
1. Move all the instantiation code to the top of the file where member
variables are usually declared and often instantiated.
2. Make sure all UI elements are instantiated using zero-parameter
constructors. If VCafe instantiated some with parameters, you can
usually remove those parameters from the argument list [e.g.,
" ... = new SuchAndSuch("abcdef") changes to ... = new SuchAndSuch()]
and use a "setWhateverProperty("abcdef")" statement in the
"jbInit()" method.
3. Move all code which sets UI element properties into the "jbInit()"
method. This includes "add...Listener()" code and layout code.
With regard to layout code [ "this.add(..., <layoutConstraints>)" ]
there may be differences. In order to get the original GridBagLayout
to be amenable to a visual designer, the JBuilder team came up with
a better GridBagConstraints class. When you get to this point, go
back to your mockup in #0 above and play with setting your panel
to GridBagLayout, and see how JBuilder writes the code. Go from
there.
Yes, it may be tedious. If you want to move the project to JBuilder,
you don't have much choice. But if you believe that JBuilder is
a better IDE (which I think it is, especially the 100% Java one),
the work will be justified.
Paul Furbacher (TeamB)
Technical Details
Message-ID:
<38E504A5.B03D82AA@home.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<38E4AB9B.83117704@epfl.ch>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 111d45,a10194cf91a96d8d X-Google-Attributes: gid111d45,public From: "Paul Furbacher [TeamB]" <pnf@home.com> Subject: Re: [Q] How to import visual design from Visual Cafe to JBuilder ??? Date: 2000/03/31 Message-ID: <38E504A5.B03D82AA@home.com> X-Deja-AN: 604981432 Content-Transfer-Encoding: 8bit References: <38E4AB9B.83117704@epfl.ch> X-Accept-Language: en,pdf Content-Type: text/plain; charset=iso-8859-1 Organization: Another Netscape Collabra Server User Mime-Version: 1.0 Reply-To: pnf@home.com Newsgroups: borland.public.jbuilder.java.swing