How to use a GUI Form?

Ok! I have clicked here and there and have now some kind of form in the UI designer, but how do I now use it from other classes?
If I right-click on the form-file, there is no "compile" and compiling the whole package won't generate a class from the form.
And how do I add other controls to the palette?

41 comments

A little tutorial would be cool !
I can't figure out how to make that work :(

Guillaume

"Robert F. Beeger" <jiveadmin@jetbrains.com> a ?crit dans le message de
news:7285446.1055227323936.JavaMail.itn@is.intellij.net...

Ok I have clicked here and there and have now some kind of form in the UI

designer, but how do I now use it from other classes?

If I right-click on the form-file, there is no "compile" and compiling the

whole package won't generate a class from the form.

And how do I add other controls to the palette?



0

That's what I need, also. :)

Daniel Moldovan


"Guillaume Laforge" <glaforge@reflexe.fr> wrote in message
news:bc426g$5ql$1@is.intellij.net...

A little tutorial would be cool !
I can't figure out how to make that work :(

>

Guillaume

>

"Robert F. Beeger" <jiveadmin@jetbrains.com> a ?crit dans le message de
news:7285446.1055227323936.JavaMail.itn@is.intellij.net...

Ok I have clicked here and there and have now some kind of form in the

UI

designer, but how do I now use it from other classes?

If I right-click on the form-file, there is no "compile" and compiling

the

whole package won't generate a class from the form.

And how do I add other controls to the palette?

>
>


0

I can't figure out how to make that work :(


I created a binding between a form and a class.
I created a text field bound to a field of my class.
And what else should I do ???

Just for the fun, I refactored the name of my class... and it also
refactored the ui form :-D
Goood... good... good...

If only I knew how to make this bloody form to show up !!!!!

Guillaume


0

I had to also put a JPanel in the class I had bound the UI form to.
For example


I then had to bind the JPanel at the top of the tree in the ui builder to my panel field and it all worked fine.

0

1. Create a form, put there some components.
2. Bind form to some class. (Root of the tree has property 'bind to class')
3. Bind components you want access from you code to instance variables (each
component has property 'binding').

At this moment you can compile the class and the code (form initialization)
will be added just after super() call in constructor. (Code will be added to
.class file so you will not see it in editor).

4. To see the form put all your controls to some JPanel and bind it to some
variable. Then from code put this JPanel to e.g. JFrame and you should see
it.

--
Best regards,
Dmitry Peshehonov
JetBrains, Inc, http://www.intellij.com



0

Am I getting this right: You have to create those instance variables yourself to make it work. There is no way to say in the UI Designer : "Create this variable for me", or is there?

I don't really want to create those 20 variables by hand after I have layed them out in the UI designer. The UI designer should have enough information to generate them on request (name and class.).

0

I looks like all the GUI designer does is the layout of the form. This is fine by me as it means it does not interfere with any of my code.

Not all of the controls in the GUI designer need corresponding fields in the class. Only the ones that you need to access in your own code. So for example if you have lots of labels that you do not do anything with you do not need corresponding fields.

I would like to know how to put my own controls in the panel though and not just the swing ones.

0

hmmm, I always get the following compiler-message:

Error: C:\wrk\test\src\ui_form1.form: There are panels with XY layout


Best regards,
Tom Schreiber


0

Am I dumb or what... GRggrgrr...

Let's recap :
1) I create a new form, called TestUI.fom
2) I put the "bind to class" property at the value "MainApp"
3) I add to the tree a JPanel
4) I put its binding property : "panel"
5) I then add a JLabel bound to "label"

Then, here is my MainApp class :

import javax.swing.*;
import java.awt.*;

public class MainApp extends JPanel
{
JPanel panel;
JLabel label;

public MainApp()
{
super(new BorderLayout());
this.add(panel, BorderLayout.CENTER);
}

public static void main(String[] args) throws InterruptedException
{
MainApp mainApp = new MainApp();
}
}

I compile the whole stuff. Ok.
But then nothing shows up.
Event if I had some mainApp.setVisible(true) or mainApp.setEnabled(true)

What am I doing wrong ?

Guillaume


0

Have you added idea.jar to your libs?

0

Have you added idea.jar to your libs?


Yes I did.


0

Robert F. Beeger wrote:

Have you added idea.jar to your libs?


Yes, I have added idea.jar to my libs, but I still get the same
error-message...

0

Well, ok, but when I add a binding to a control, this means "This is not just one of those labels, but some control I want to do something in my code with".
So I would like IDEA to notice that there is no corresponding field in the bound class and propose to create it for me - no voodoo here, no magic in the background.

0

I have added this to the tracker now. Anyone who shares my opinion can vote for it at http://www.intellij.net/tracker/idea/viewSCR?publicId=13182

0


"Guillaume Laforge" <glaforge@reflexe.fr> a ?crit dans le message de
news:bc46oe$iv9$1@is.intellij.net...

Am I dumb or what... GRggrgrr...


I was certainly dumb I guess :)
I changed my main class so that it extends a JFrame.
And it worked.

TestUI.form :

1) form bound to MainApp
2) added a JPanel to the form bound to panel
3) added a label to the panel bound to label

Source code :

import javax.swing.*;
import java.awt.*;

public class MainApp extends JFrame
{
JPanel panel;
JLabel label;

public MainApp()
{
super("Main App for testing UI Builder");

this.getContentPane().add(panel, BorderLayout.CENTER);
this.setEnabled(true);
this.setVisible(true);
}


public static void main(String[] args) throws InterruptedException
{
MainApp mainApp = new MainApp();
}
}


0

You have to assign a layout to your form, if you select form and then click on one of the layouts it should work.

0

Ok, I have reproduced it now. It's because you have one or more panels that don't have one of the four LayoutManagers the UI Designer proposes.
Select the panel and choose one of the four buttons on the right side of the trash can. This should fix it.

0

Alexander wrote:

You have to assign a layout to your form, if you select form and then click on one of the layouts it should work.

Ok, that's it, very thanks!

0

Robert F. Beeger wrote:

Ok, I have reproduced it now. It's because you have one or more panels that don't have one of the four LayoutManagers the UI Designer proposes.
Select the panel and choose one of the four buttons on the right side of the trash can. This should fix it.

Ok, very thanks!

0

Try:

public class MainApp {
JPanel panel;
JLabel label;

MainApp() {
// You can access panel and label.
}

JPanel getPanel() { return panel; }

void setText(String text) {
label.setText(text);
}

public static void main(String[] args) {
JFrame frame = new JFrame();
MainApp form = new MainApp();
frame.getContentPane().add(form.getPanel());
frame.show();
form.setText('Hello world');
}
}

--
Best regards,
Dmitry Peshehonov
JetBrains, Inc, http://www.intellij.com


"Guillaume Laforge" <glaforge@reflexe.fr> wrote in message
news:bc46oe$iv9$1@is.intellij.net...

Am I dumb or what... GRggrgrr...

>

Let's recap :
1) I create a new form, called TestUI.fom
2) I put the "bind to class" property at the value "MainApp"
3) I add to the tree a JPanel
4) I put its binding property : "panel"
5) I then add a JLabel bound to "label"

>

Then, here is my MainApp class :

>

import javax.swing.*;
import java.awt.*;

>

public class MainApp extends JPanel
{
JPanel panel;
JLabel label;

>

public MainApp()
{
super(new BorderLayout());
this.add(panel, BorderLayout.CENTER);
}

>

public static void main(String[] args) throws InterruptedException
{
MainApp mainApp = new MainApp();
}
}

>

I compile the whole stuff. Ok.
But then nothing shows up.
Event if I had some mainApp.setVisible(true) or mainApp.setEnabled(true)

>

What am I doing wrong ?

>

Guillaume

>
>


0

UIDesigner is in "work in progress" state. It is not integrated with other
code-editting tools which IDEA has (there was much to do just to make it
work as plugin).
To avoid confusions please remember that rename refactoring is not supported
for fields (so you should rename binded fields by hand in forms) and rename
class works only when 'Search in non-java files' is on.

--
Best regards,
Dmitry Peshehonov
JetBrains, Inc, http://www.intellij.com


"Jonathan Knight" <jiveadmin@jetbrains.com> wrote in message
news:6953343.1055234782927.JavaMail.itn@is.intellij.net...

I looks like all the GUI designer does is the layout of the form. This is

fine by me as it means it does not interfere with any of my code.
>

Not all of the controls in the GUI designer need corresponding fields in

the class. Only the ones that you need to access in your own code. So for
example if you have lots of labels that you do not do anything with you do
not need corresponding fields.
>

I would like to know how to put my own controls in the panel though and

not just the swing ones.


0

All JPanels should have layout set.
To create a form add there some components placing them as you'd like to see
them (not very precisely). Then select them all and press 'Lay Out In a
Grid' button. This will create a JPanel with layouted componets.

--
Best regards,
Dmitry Peshehonov
JetBrains, Inc, http://www.intellij.com

"Develop with pleasure!"
"Tom Schreiber" <fftmc@gmx.net> wrote in message
news:bc46br$hu6$1@is.intellij.net...

hmmm, I always get the following compiler-message:

>

Error: C:\wrk\test\src\ui_form1.form: There are panels with XY layout

>
>

Best regards,
Tom Schreiber

>
>


0

On Tue, 10 Jun 2003 08:41:41 +0000, Robert F. Beeger wrote:

Am I getting this right: You have to create those instance variables
yourself to make it work. There is no way to say in the UI Designer :
"Create this variable for me", or is there?

I don't really want to create those 20 variables by hand after I have
layed them out in the UI designer. The UI designer should have enough
information to generate them on request (name and class.).


Hopefully these will eventually be automatically added.

--
...turn to the light - don't be frightened by the shadows it creates,
...turn to the light - turning away could be a terrible mistake
...dream theater - the great debate


0

It will be implemented a bit later.

--
Best regards,
Dmitry Peshehonov
JetBrains, Inc, http://www.intellij.com


"Mark Derricutt" <pinhead@satinism.org> wrote in message
news:pan.2003.06.10.10.51.49.254937@satinism.org...

On Tue, 10 Jun 2003 08:41:41 +0000, Robert F. Beeger wrote:

>

Am I getting this right: You have to create those instance variables
yourself to make it work. There is no way to say in the UI Designer :
"Create this variable for me", or is there?

>

I don't really want to create those 20 variables by hand after I have
layed them out in the UI designer. The UI designer should have enough
information to generate them on request (name and class.).

>

Hopefully these will eventually be automatically added.

>

--
...turn to the light - don't be frightened by the shadows it creates,
...turn to the light - turning away could be a terrible mistake
...dream theater - the great debate

>


0

"Dmitry Peshehonov" <dyoma@intellij.com> wrote in message
news:bc4alv$odl$1@is.intellij.net...

To avoid confusions please remember that rename refactoring is not

supported

for fields (so you should rename binded fields by hand in forms) and

rename

class works only when 'Search in non-java files' is on.


Are we going to get
http://www.intellij.net/tracker/idea/viewSCR?publicId=12113 for free with
it? ;)

Hopeful eap member...


0

On Tue, 10 Jun 2003 13:58:34 +0400, Dmitry Peshehonov wrote:

Try:

public class MainApp {
JPanel panel;
JLabel label;


Current issues I've found:

1. Hitting "run" on the tool bar after an edit causes a null pointer
exception when running, but doing a rebuild, then run, works.

2. JTables don't get added with JScrollPane's around them, so column
headings don't show. Could be nice to automatically add the JScrollPane.



--
...turn to the light - don't be frightened by the shadows it creates,
...turn to the light - turning away could be a terrible mistake
...dream theater - the great debate


0

"Mark Derricutt" <pinhead@satinism.org> wrote in message
news:pan.2003.06.10.11.49.02.64270@satinism.org...

On Tue, 10 Jun 2003 13:58:34 +0400, Dmitry Peshehonov wrote:

>

Try:

>

public class MainApp {
JPanel panel;
JLabel label;

>

Current issues I've found:

>

1. Hitting "run" on the tool bar after an edit causes a null pointer
exception when running, but doing a rebuild, then run, works.

>
Yes, it is a bug in recompiling forms. Please post bug report.

2. JTables don't get added with JScrollPane's around them, so column
headings don't show. Could be nice to automatically add the JScrollPane.

>
There is component JScrollPane in the palette. Just drop JScrollPane and
then drop your table into it.

--
Best regards,
Dmitry Peshehonov
JetBrains, Inc, http://www.intellij.com


0

I spent 30 minutes having intimate relationship with the GUI designer, and to be honest I?ve never seen anything more cumbersome then this. Why to have all this complexity such as binding unbinding etc. instead of simply generating readonly (to keep it simple) java class which extends JPanel or whatever (Container) with getters and setters for each field. Then this class can be treated as regular JPanel. In my opinion Jbuilder, Jdeveloper, NetBeans or what ever do much better job so far in the GUI building business.

0

Vladimir Goncharov wrote:

I spent 30 minutes having intimate relationship with the GUI designer, and to be honest I?ve never seen anything more cumbersome then this. Why to have all this complexity such as binding unbinding etc. instead of simply generating readonly (to keep it simple) java class which extends JPanel or whatever (Container) with getters and setters for each field. Then this class can be treated as regular JPanel. In my opinion Jbuilder, Jdeveloper, NetBeans or what ever do much better job so far in the GUI building business.

Are you kidding, right? Please, don't tell us jbuilder and netbeans have
a good guibuilder. Besides, I guess the binding of ui elements and
events is still work in progress. Let's wait a little.

/kesh

0

On Tue, 10 Jun 2003 15:36:17 -0400, kesh wrote:

Vladimir Goncharov wrote:

>> I spent 30 minutes having intimate relationship with the GUI designer, and to be honest I?ve never seen anything more cumbersome then this. Why to have all this complexity such as binding unbinding etc. instead of simply generating readonly (to keep it simple) java class which extends JPanel or whatever (Container) with getters and setters for each field. Then this class can be treated as regular JPanel. In my opinion Jbuilder, Jdeveloper, NetBeans or what ever do much better job so far in the GUI building business.

Are you kidding, right? Please, don't tell us jbuilder and netbeans have
a good guibuilder. Besides, I guess the binding of ui elements and
events is still work in progress. Let's wait a little.


Heh you said it right. I was just commenting to my co workers how cool it
was to be able to drag things around so easily, and not have the whole
thing feel so clunky. I was able to throw a GUI together very quickly, no
pains, my way of doing it (i.e. the way I think) and it works (well what
ever is there)!

I'm sure once we can compile and run it will be more interesting. :)
(Unless we can do that now without the ant script???)

R

0

Please sign in to leave a comment.