What am I missing ?

Hi,

I have a little problem with the UI designer : I created a "host" class for
bindings. Then I designed my form thanks to the UI, and bound it to my host
class.

Then how do I "spawn" the created form ? I am missing a step for showing the
form. Sure it isn't hard to find, but really don't know how.

Should my host class inherit from JFrame ?

...

Thanks !





8 comments
Comment actions Permalink

Actually you are not showing a form. You have to bind entire form to
some JComponent (or part of the form) and insert this JComponent into
the content pane of the JFrame or JDialog.

With best wishes,
Vladimir Kondratyev
_____________________
JetBrains

Cédric Champeau wrote:

Hi,

I have a little problem with the UI designer : I created a "host" class for
bindings. Then I designed my form thanks to the UI, and bound it to my host
class.

Then how do I "spawn" the created form ? I am missing a step for showing the
form. Sure it isn't hard to find, but really don't know how.

Should my host class inherit from JFrame ?

...

Thanks !




0
Comment actions Permalink

Hello,

Sorry, i'm not clearly understand you... But i try to explain:
The Form mapped to any class, no matter dirived or not from JFrame.

Follow your mapped class must have Swing components fields to map it to root
pane etc.
After you create this class you must add it on content pane to JFrame:

JFrame jFrame = new JFrame();
jFrame.getContentPane().add(new MyDesignedPanel());

jFrame.pack();
jFrame.show();

Thanks!
--
Alexey Efimov, Software Engineer
Sputnik Labs,
http://www.spklabs.com
"Cédric Champeau" <cchampeau@e-manation.com> wrote in message
news:bi2gj8$lj4$1@is.intellij.net...

Hi,

>

I have a little problem with the UI designer : I created a "host" class

for

bindings. Then I designed my form thanks to the UI, and bound it to my

host

class.

>

Then how do I "spawn" the created form ? I am missing a step for showing

the

form. Sure it isn't hard to find, but really don't know how.

>

Should my host class inherit from JFrame ?

>

...

>

Thanks !

>
>
>
>


0
Comment actions Permalink

well, thanks for your answer.

This wasn't that clear for me : I had created a mapped class which inherited
from JPanel, and tried to show it directly. This was my mistake.

Now it works, thanks !

"Alexey Efimov" <aefimov@spklabs.com> a écrit dans le message de
news:bi2hit$uad$1@is.intellij.net...

Hello,

>

Sorry, i'm not clearly understand you... But i try to explain:
The Form mapped to any class, no matter dirived or not from JFrame.

>

Follow your mapped class must have Swing components fields to map it to

root

pane etc.
After you create this class you must add it on content pane to JFrame:

>

JFrame jFrame = new JFrame();
jFrame.getContentPane().add(new MyDesignedPanel());

>

jFrame.pack();
jFrame.show();

>

Thanks
--
Alexey Efimov, Software Engineer
Sputnik Labs,
http://www.spklabs.com
"Cédric Champeau" <cchampeau@e-manation.com> wrote in message
news:bi2gj8$lj4$1@is.intellij.net...

Hi,

>

I have a little problem with the UI designer : I created a "host" class

for

bindings. Then I designed my form thanks to the UI, and bound it to my

host

class.

>

Then how do I "spawn" the created form ? I am missing a step for showing

the

form. Sure it isn't hard to find, but really don't know how.

>

Should my host class inherit from JFrame ?

>

...

>

Thanks !

>
>
>
>

>
>


0
Comment actions Permalink

I am newby to Swing development and I am looking for a good UI Designer.
I took a look to UICompiler, which uses the .ui files created by QtDesigner
to create a .java class that replaces the qt widgets with JComponents. It
also creates an instance variable for every widget in the form and methods
for event handling for widgets like buttons, check boxes, etc.... This
methods have a predefined name, derived from the name of the component and
the action to be performed.
UICompiler creates this BaseClass (subclass of JPanel) that you have to
subclass to write only the event handling methods.
I think this is really a nice idea, because my hand coded class has only the
necessary code: the fields are accessed using the instance variables defined
in the Base class and if you write a method with the right name, it is bound
to an event. If you change the design, only the BaseClass is modified and
all the event handling code is safe.

Perhaps also UIDesigner should follow this approach.

Bye,
Marco."Alexey Efimov" <aefimov@spklabs.com> ha scritto nel messaggio
news:bi2hit$uad$1@is.intellij.net...

Hello,

>

Sorry, i'm not clearly understand you... But i try to explain:
The Form mapped to any class, no matter dirived or not from JFrame.

>

Follow your mapped class must have Swing components fields to map it to

root

pane etc.
After you create this class you must add it on content pane to JFrame:

>

JFrame jFrame = new JFrame();
jFrame.getContentPane().add(new MyDesignedPanel());

>

jFrame.pack();
jFrame.show();

>

Thanks!
--
Alexey Efimov, Software Engineer
Sputnik Labs,
http://www.spklabs.com
"Cédric Champeau" <cchampeau@e-manation.com> wrote in message
news:bi2gj8$lj4$1@is.intellij.net...

Hi,

>

I have a little problem with the UI designer : I created a "host" class

for

bindings. Then I designed my form thanks to the UI, and bound it to my

host

class.

>

Then how do I "spawn" the created form ? I am missing a step for showing

the

form. Sure it isn't hard to find, but really don't know how.

>

Should my host class inherit from JFrame ?

>

...

>

Thanks !

>
>
>
>

>
>


0
Comment actions Permalink

This is hidded "bad template". Mixing UI with event handlers and entire logic of program. I'll be very pleasent if JetBrains will not follow by Visual Studio.

I think UI designer will create only UI look. And i use it and find it very good.

For example if i would create JDialog implementation, I always follow by model:
1. Create empty package view class "MyDialogUI" (it simple bean, what have binded fields to UI form and getters for it fields), look like:

2. I create UI form, UIDesigner will create all nesary fiels in MyDialogUI class automaticaly.
3. Open MyDialogUI class and generate getters for all fields.
4. Add additional "paintings" into MyDialogUI constructor
5. Create MyDialog class extends JDialog, like:


I think UIDesigner is good as UI only designer, without any "smart" event handler implementation and so.

Maybe i'm wrong, please, correct me :)
Thanks!

0
Comment actions Permalink

How does this work? By default MyDesignedPanel() would not extend from JPanel. I tried adding this myself in the code but then nothing was visible in my JFrame. Could you explain this some more please?

I got things working by adding a method to MyDesignedPanel that returned the top-level JPanel, but I rather not do that!

0
Comment actions Permalink

Hello Wim,

Now i use follow methodic for using UI designer in IDEA:

For example you need to design JFrame.


Follow, create "UI bean" - it's basic bean for UI design binding (make it package-view accessed from MyFrame class):

class MyFrame {
private JPanel root;
// ...
public JPanel getRoot() {
return root;
}
}

Every UI designer Form must have root panel - and other controls, that you need to control from your class (then you need for additional binding in UI class and getter method).

Then i create MyFrame.form (as usual in uiDesigner subfolder) UI form in UI designer, and bind it to MyFrameUI class. Then all UI will be constructed, i bind all my required controls to MyFrameUi fields. After bindings go in MyFrameUI and generate expected getter methods for fields if needed.

Continue with MyFrame class:


The same model using in my plugins and work fine. You can look in source of Wizard and APIComparator.

Good luck!

0
Comment actions Permalink

OK. I understand now, it was the way I got it working too (although you typed a mistake, the class with the getRoot() method should be called MyFrameUI), but I don't like the construct much. Maybe that just because I'm not used to using it like that. Come to think of it, this might lead to a better seperation of ui and other logic.

0

Please sign in to leave a comment.