Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Some questions on Swing forms

0 views
Skip to first unread message

Ian Semmel

unread,
Jul 24, 2008, 3:40:47 PM7/24/08
to
I am just getting started on this (and java), and have some seemingly basic questions

1. When you want to add your own code to a form, do you just add it to the form class file (ie this is for my own functions which
are not related to the code that you enter into framework-generated events etc).

2. Where do you actually put the code to display the initial values in text fields etc (ie is there some particular event exit). I
am actually using panels in a tabbed form.

Roedy Green

unread,
Jul 24, 2008, 3:53:13 PM7/24/08
to
On Thu, 24 Jul 2008 19:40:47 GMT, Ian Semmel
<isemme...@NOJUNKrocketcomp.com.au> wrote, quoted or indirectly
quoted someone who said :

>1. When you want to add your own code to a form, do you just add it to the form class file (ie this is for my own functions which
>are not related to the code that you enter into framework-generated events etc).

There is no Form class file I am aware of. You build JPanels and
arrange them into JFrames. The JPanels have various JComponents
arrayed on them with a layout mananger. Perhaps you are confusing
Swing with HTML forms.

There are quite different ways of operationg. HTML Forms are a
primitive data input method available in browsers. Swing is a
technique used with Applets, Java Webstart or stand alone Java apps.

--

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com

Ian Semmel

unread,
Jul 24, 2008, 7:43:45 PM7/24/08
to

It's my terminology that's confusing.

What I mean is eg a javax.swing.JDialog source file created when you create a Matisse form in say eclipse.

What I want to know is how do you know when all the fields have been created so that you can then use them.

Roedy Green

unread,
Jul 25, 2008, 2:40:30 AM7/25/08
to
On Thu, 24 Jul 2008 23:43:45 GMT, Ian Semmel

<isemme...@NOJUNKrocketcomp.com.au> wrote, quoted or indirectly
quoted someone who said :

>


>What I mean is eg a javax.swing.JDialog source file created when you create a Matisse form in say eclipse.
>
>What I want to know is how do you know when all the fields have been created so that you can then use them.

I have never used Matisse, so I don't know what sort of code it
generates. I presume you can look at it.

I would expect all the Components to be created and hooked up with
listeners in the constructor, so all should be ready to go. They might
use the addnotify mechanism.

See http://mindprod.com/jgloss/addnotify.html


see http://mindprod.com/jgloss/jdialog.html
for some background.

Ian Semmel

unread,
Jul 25, 2008, 3:01:36 AM7/25/08
to

Yes, those links seem to be about the trouble I was having (not that I fully understand them).

I moved things around in my program and now they seem to work. Previously, I had a null parent on the dialog, now I have a hidden
JFrame which I think is the answer.

Thanks for your help.

Karsten Lentzsch

unread,
Jul 25, 2008, 6:00:30 AM7/25/08
to
Ian Semmel wrote:

I recommend to read Fowler's "Organizing Presentation Logic".
It describes the basic approaches for where to put what.

I provide a presentation at www.jgoodies.com/articles/
"Desktop Patterns & Data Binding" that adds some Java/Swing
related diagrams to Fowler's text.

You may also consider studying some of the tutorial sources
from my open source JGoodies Binding. There you can see how
a (stupid) view class is associated with a presentation logic
class that contains all the meat. The "EditorCopyingExample"
does not really use an automatic data binding, and so is the
simplest example, which may be good for a starting point. See
http://www.jgoodies.com/downloads/libraries.html
Get the Binding, extract it, look at "src/tutorial".

-Karsten

0 new messages