Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Layout question

Reply
Thread Tools

Layout question

 
 
nukleus
Guest
Posts: n/a
 
      01-17-2007
I am having a lil problem here with someone else old code.
It uses Frames (all AWT code, no javax stuff).
and it does not use Layouts.
When i tried to add a menu, i noticed that it behaves differently
on different compilers. In some cases some text fields get obscured
by the menu and things like that.

Question: can i get away with not using layouts?
There is a lot of code to rewrite as there are hundreds
of various user entries setting various parameters.

Thanx in advance.
 
Reply With Quote
 
 
 
 
Andrew Thompson
Guest
Posts: n/a
 
      01-17-2007
nukleus wrote:
> I am having a lil problem here with someone else old code.
> It uses Frames (all AWT code, no javax stuff).
> and it does not use Layouts.


The person that made that decision, should
be soundly flogged.

> When i tried to add a menu, i noticed that it behaves differently
> on different compilers. In some cases some text fields get obscured
> by the menu and things like that.


Null layouts can be broken by being dsiplayed
on a different OS, or with a VM where the default
text size is configured larger, or smaller, or
many other reasons. The code is fundamentally
flawed and 'fragile'.

> Question: can i get away with not using layouts?


...hmm. Can you afford to lock your end users into
a particalur VM, with particular font sizes*, on one
specific OS?

* Which might cause accessibility problems for
anyone that requires (e.g.) 'large text'.

> There is a lot of code to rewrite as there are hundreds
> of various user entries setting various parameters.


Yes, but then, as you have already noted - any change to
this fragile code causes problems, further developement
of the existing application will cost a great deal more,
in trying to get the altered code to work 'correctly'.

Given the complexity of the GUI, it might be better
to look to a system that generates the GUI 'on-the-fly',
but uses layouts to achieve the result.

Andrew T.

 
Reply With Quote
 
 
 
 
nukleus
Guest
Posts: n/a
 
      01-18-2007
In article <(E-Mail Removed) om>, "Andrew
Thompson" <(E-Mail Removed)> wrote:
>nukleus wrote:
>> I am having a lil problem here with someone else old code.
>> It uses Frames (all AWT code, no javax stuff).
>> and it does not use Layouts.

>
> The person that made that decision, should
>be soundly flogged.
>
>> When i tried to add a menu, i noticed that it behaves differently
>> on different compilers. In some cases some text fields get obscured
>> by the menu and things like that.

>
>Null layouts can be broken by being dsiplayed
>on a different OS, or with a VM where the default
>text size is configured larger, or smaller, or
>many other reasons. The code is fundamentally
>flawed and 'fragile'.
>
>> Question: can i get away with not using layouts?

>
>...hmm. Can you afford to lock your end users into
>a particalur VM, with particular font sizes*, on one
>specific OS?
>
>* Which might cause accessibility problems for
>anyone that requires (e.g.) 'large text'.
>
>> There is a lot of code to rewrite as there are hundreds
>> of various user entries setting various parameters.

>
>Yes, but then, as you have already noted - any change to
>this fragile code causes problems, further developement
>of the existing application will cost a great deal more,
>in trying to get the altered code to work 'correctly'.


That is what i was thinking of.

>Given the complexity of the GUI, it might be better
>to look to a system that generates the GUI 'on-the-fly',
>but uses layouts to achieve the result.
>
>Andrew T.


Thanks for reply.
I tried to prototype the grid bag layout version and it seems ok.
One thing i noticed is that the title and menu Y size are not
accounted for. So, when i layout the gui elements, i have
to move them all to account for it. Otherwise, in run time
they get obscured by menu and title.

The previous code was using addNotify() on the whole frame
object, which is not allowed, and then using inserts to figure
out where to start laying things out in run time by adding
Y offset to all gui elements.

Do you have any suggestions on what is the best way
of doing it without wiring in some code that will not be
recognized by the gui layout designer, such as borland j++?

Thanks

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      01-18-2007
nukleus wrote:
> In article <(E-Mail Removed) om>, "Andrew
> Thompson" <(E-Mail Removed)> wrote:
> >nukleus wrote:
> >> I am having a lil problem here with someone else old code.
> >> It uses Frames (all AWT code, no javax stuff).
> >> and it does not use Layouts.

....
> Do you have any suggestions on what is the best way
> of doing it without wiring in some code that will not be
> recognized by the gui layout designer, such as borland j++?


I neither know, nor care, what can be don with some IDE
(Take that, as an 'Attitude').

On the other hand, past experience suggests to me
that the makers of IDE's are smart enough, usually,
to allow you ways to do what 'needs to be done'.

The specific 'for instance' I am thinking of, is that
I know of a comonent* that was designed in
NetBeans (in the NetBeans *form* *editor*, which
is the NB 'make a GUI' wizard), that itself actively
generates GUI's based on XML descriptions
(which were from a legacy source).

So, even though a GUI is being actively generated,
it still might be possible to use the usual 'GUI design'
tools that the IDE offers.

* The SaverBeans SettingsDialog's are generated
from XSS based (XML format), settings descriptors.
The SettingsDialog was designed in the NetBeans
'form editor'.

Andrew T.

 
Reply With Quote
 
Ian Wilson
Guest
Posts: n/a
 
      01-18-2007
nukleus wrote:
> I tried to prototype the grid bag layout version and it seems ok.
> One thing i noticed is that the title and menu Y size are not
> accounted for. So, when i layout the gui elements, i have
> to move them all to account for it. Otherwise, in run time
> they get obscured by menu and title.


Can you post a small compilable example (an SSCCE) that shows this problem?
 
Reply With Quote
 
nukleus
Guest
Posts: n/a
 
      01-18-2007
In article <(E-Mail Removed). com>, "Andrew
Thompson" <(E-Mail Removed)> wrote:
>nukleus wrote:
>> In article <(E-Mail Removed) om>, "Andrew
>> Thompson" <(E-Mail Removed)> wrote:
>> >nukleus wrote:
>> >> I am having a lil problem here with someone else old code.
>> >> It uses Frames (all AWT code, no javax stuff).
>> >> and it does not use Layouts.

>....
>> Do you have any suggestions on what is the best way
>> of doing it without wiring in some code that will not be
>> recognized by the gui layout designer, such as borland j++?

>
>I neither know, nor care, what can be don with some IDE
>(Take that, as an 'Attitude').


Interesting. But what do you do in that case?
Generate it all on the fly?
That is what the code i started with was doing,
using null layout and generating gui elements on the fly.
But it was just a hack, as even within windows, different
compilers and versions would produce totally different
results and that addNotify() trick, used to get the insets
on a frame object, before it was shown, which is impossible,
was just a dirty trick, not supported by Sun explicitly.
But if you have a complex enough layout,
such as you can create with grid bag, how do you design
your gui graphically?

>On the other hand, past experience suggests to me
>that the makers of IDE's are smart enough, usually,
>to allow you ways to do what 'needs to be done'.


True. Actually, what i found out is that the call to
setLayout was done too late. When i moved it to
the very beginning of frame initialization code,
it all seems to work. Not tested it on other compilers yet.
I don't quite understand all the intricacies of it,
as this is not the main thing by any means.
There is so much real stuff to take care of,
that gui, even though i take a very careful and cautious
approach in designing, is not the main thing in my case.

>The specific 'for instance' I am thinking of, is that
>I know of a comonent* that was designed in
>NetBeans (in the NetBeans *form* *editor*, which
>is the NB 'make a GUI' wizard), that itself actively
>generates GUI's based on XML descriptions
>(which were from a legacy source).


I like that.
Where can i see it? Do you have a reference on it
by any chance?

>So, even though a GUI is being actively generated,
>it still might be possible to use the usual 'GUI design'
>tools that the IDE offers.


Good. Seems to be the best compromise between
both words.
I kinda like borland layout designer, works fine for me
even for grid bag layout, but i wouln't want to be tied
up to code it generates, even though it generates
a perfectly valid code for events, Constraints, etc.
One thing it does is to to use J... components,
and ms vj 2003 version does not support javax classes.
Btw, do you, by any chance, know if i can add javax
libraries to it? I could not figure out where their classes
are. There are not configuration parameters i see,
and i don't even know how to find it. All this "proprietary"
stuff is simply sickening. It drains so much energy
and wastes so much stuff on worrying about not getting
trapped into spider nets they forever weave, it is hard
to believe.

Anyway...

>* The SaverBeans SettingsDialog's are generated
>from XSS based (XML format), settings descriptors.
>The SettingsDialog was designed in the NetBeans
>'form editor'.


Oh... You got me excited. Thanks.
I am looking at XML stuff and wrote some code
to convert the usenet articles into nice looking HTML
pages or generate an XML code, but i haven't done
much with XML so far, even though it seems to be
something worth considering. These standard
newsreaders seem to be a stone age in terms of gui.

Where can i see this stuff and how big it is to download?
Can you tell me?

Unfortunately, i do not like to get tied up into any
software manufacturer's proprietary approach and i am
not looking at netbeans at the moment. Don't even know
what it is. It is just strictly java stand alone approach.
Not even meant to be run in any kind of browser or
whatever those "beans" may want.

I like the code to work on just about any operating system
and with just about any compiler out there, going back
to year 2000 and i am crosschecking my code constantly
on different compilers and versions to make sure i don't get
trapped into their proprietary designs and architectures.
Thats the way i like it. Take it as an attitude :---}

I have no need to use the javax, which i consider to be
a booboo on the first place.
How can you call something extension, if it has exactly the
same components as the stanard AWT, only slightly improved upon?
You just fix the bugs and add more functionality to AWT libraries
instead of creating extensions that are not extensions on the
first place. And now, with all this arm wresting between
the ms and sun, on some versions of compilers, javax is
supported, such as msjv++ 6, and on 2003 version, they are
abscent altogether. I am not even sure what is the latest version
of ms java and what does it include and what not.
When you look at borland compiler, so far, i haven't seen
a notion of stand alone executable, which means...

which means that you are going to force your user
to download gigabytes of stuff from sun or borland
before they can even run your program. This stuff is
simply sickening. Sun is also doing its number on screwing
things up and making it as "proprietary" as impossible.
So...
You are kinda walking on a mine field with all their
"business strategies" of sucking people into their own traps.
I am simply sick of it all. Looks like, 70% of time you spend not
on designing and coding, but on worrying what kind of trap
you may fall into.

This whole jvm stuff is simply insane, thanks to sun.
They want it to look like that all the roads to heaven lie
thru their proprietary trips and, instead of simply making
a stand alone executable, just like any program out there,
you have to worry about virtual machines and all that jazz,
no mortal user would even be interested in hearing about.

I am running under windows primarily, there is too much
stuff i have working under it, so i am tied up to it.
Would love to switch to linux, well,kinda, but some code
i wrote i device drivers and the linux and window worlds
are universes appart. Secondly, i am happy with windows
GUI overall. The last time i looked at linux and all that
X-stuff, it was kinda stone age level, cludge as it gets.
Looks kinda ok, but only on the first look.
But i haven't looked at it lately.

Anyway, thanks for your feedback.

>Andrew T.

 
Reply With Quote
 
nukleus
Guest
Posts: n/a
 
      01-18-2007
In article <(E-Mail Removed)>, Ian Wilson
<(E-Mail Removed)> wrote:
>nukleus wrote:
>> I tried to prototype the grid bag layout version and it seems ok.
>> One thing i noticed is that the title and menu Y size are not
>> accounted for. So, when i layout the gui elements, i have
>> to move them all to account for it. Otherwise, in run time
>> they get obscured by menu and title.

>
>Can you post a small compilable example (an SSCCE) that shows this problem?


Well, unfortunately, the original code is gone, but what i did,
is to move setLayout() from after call to this.setResizable(false);
to the very top of init routine. Here is what i have now, and it
seems to be ok. Hopefully that was the problem.

private void jbInit() throws Exception {

this.setLayout(gridBagLayout_Frame);

this.setForeground(new Color(255, 255, 144));
this.setBackground(new Color(39, 20, 15);
this.setSize(new Dimension(400, 259));
this.setTitle(" Set Files");
this.setResizable(false);

// Old place of setLayout(
// this.setLayout(gridBagLayout_Frame);

this.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentResized(ComponentEvent e) {
this_componentResized(e);
}
});
this.addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(WindowEvent e) {
this_windowClosing(e);
}
});
// panel1.setBackground(new Color(210, 255, 255));
MainPanel.setFont(new java.awt.Font("Dialog", 1, 12));
MainPanel.setLayout(gridBagLayout_MainPanel);

ArchiveLabel.setText("Archive");
AttachmentLabel.setText("Attachment");
RulesFileLabel.setText("Dictionary");
QuotesLabel.setText("Quotes");
AssociationsLabel.setText("Associations");
IntroLabel.setText("Intro");
ReminderLabel.setText("Reminder");

/*
* the rest of frame init code
..................................
*/
}
 
Reply With Quote
 
ali
Guest
Posts: n/a
 
      01-18-2007


On Jan 17, 10:28 am, (E-Mail Removed) (nukleus) wrote:
> I am having a lil problem here with someone else old code.
> It uses Frames (all AWT code, no javax stuff).
> and it does not use Layouts.
> When i tried to add a menu, i noticed that it behaves differently
> on different compilers. In some cases some text fields get obscured
> by the menu and things like that.
>
> Question: can i get away with not using layouts?
> There is a lot of code to rewrite as there are hundreds
> of various user entries setting various parameters.
>
> Thanx in advance.



ummm i am not sure but i think the visual editor in Eclipse can help a
bit

i read somewhere it can easily convert between null layout to any other
layout just by simple click

hope there is some one that have tried it so s/he can support my
arrgument

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      01-18-2007
nukleus wrote:
> In article <(E-Mail Removed). com>, "Andrew
> Thompson" <(E-Mail Removed)> wrote:

....
> >The specific 'for instance' I am thinking of, is that
> >I know of a comonent* that was designed in
> >NetBeans (in the NetBeans *form* *editor*, which
> >is the NB 'make a GUI' wizard), that itself actively
> >generates GUI's based on XML descriptions
> >(which were from a legacy source).

>
> I like that.
> Where can i see it? Do you have a reference on it
> by any chance?


The entire SaverBeans project is open source, you
can see the latest version of the SettingsDialog.java here..
<https://jdic.dev.java.net/source/browse/jdic/src/incubator/screensaver/src/api/org/jdesktop/jdic/screensaver/SettingsDialog.java?rev=1.5&view=auto&content-type=text/vnd.viewcvs-markup>
...and the NetBeans based SettingsDialog.form here..
<https://jdic.dev.java.net/source/browse/jdic/src/incubator/screensaver/src/api/org/jdesktop/jdic/screensaver/SettingsDialog.form?rev=1.3&view=markup>
The XML files they use to describe the GUI, are detailed here..
<https://screensavers.dev.java.net/config/>

HTH

Andrew T.

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      01-18-2007
ali wrote:
....
> i read somewhere it can easily convert between null layout to any other
> layout just by simple click


Probably by converting it to an 'absolute layout' or
'xy layout' or such, which simply 'locks' components
into a specific size and position.

This is probably worse even than a null layout, since
it might give the (false) impression that the GUI was
now 'fixed' - whereas it simply had the weaknesses of
the null layout, combined with the exact positioning
of the IDE's layout.

Andrew T.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Choosing Layout: Css-Layout or Table-Layout hpourfard@gmail.com ASP .Net 1 06-19-2006 10:06 AM
CSS Layout question - how to duplicate a table layout with CSS Eric ASP .Net 4 12-24-2004 04:54 PM
Oppinion regarding grid layout vs flow layout NWx ASP .Net 4 02-19-2004 08:56 PM
Converting from grid layout to flow layout. RobertH ASP .Net 1 11-04-2003 12:43 AM
DataList inside a Grid Layout Panel (<DIV>) item layout problem Rick Spiewak ASP .Net 3 08-26-2003 04:22 AM



Advertisments