Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / February 2006

Tip: Looking for answers? Try searching our database.

gridbaglayout & jcomboboxes

Thread view: 
Big Jim - 02 Feb 2006 18:53 GMT
Hi, I've the following components in a 6x6 gridbaglayout using java 1.4 and
windows L&F on win2k:

jlabel    jcombo    jlabel    jcombo    jlabel    jcombo
jlabel    jcombo    jlabel    jtextfield   jlabel    jcombo
jlabel    jcombo    jlabel    jtextfield   jlabel    jcombo
jlabel    jcombo    jlabel    jcombo    jlabel    jcombo
jlabel    jcombo    jlabel    jcombo    jlabel    jcombo
jlabel    jtextarea   jlabel   jtextarea   jlabel    jtextarea

I've used jcombo.setUI(BasicComboBoxUI) on each of the combos so the down
arrow key opens the popup if it's closed and traverses it if opened.

The components in row 0 and row 5 are painted smaller in height than the
other rows. Is there a way to fix this? or, alternatively, a handy way to
use the default ComboBoxUI (whatever that is) but get the arrow down key
behaviour I want? (it was just stepping through the entries before but
wasn't causing the popup, F4 was activating the popup)

Also, selecting an item in the top left combobox changes the items available
in all the others. When I do this all the boxes are repainted different
sizes i.e. the columns all shift slightly even though all the items are much
shorter than the displayed length of the comboboxes. Is there a way to stop
this?

Cheers, Richard.
Roedy Green - 02 Feb 2006 20:55 GMT
>jlabel    jcombo    jlabel    jcombo    jlabel    jcombo

Normally you would make this into a custom Jpanel. Then you can repeat
it as needed.

You problem then is making it align with the last line .

I had a problem like this back in the Java 1.0 days. My rather ugly
solution was to invent a component that added its members individually
to the surrounding GridBagLayout.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Roedy Green - 02 Feb 2006 20:58 GMT
>Also, selecting an item in the top left combobox changes the items available
>in all the others. When I do this all the boxes are repainted different
>sizes i.e. the columns all shift slightly even though all the items are much
>shorter than the displayed length of the comboboxes. Is there a way to stop
>this?

You can use setPreferredSize to pick a standard size.

You can use the GridBagLayout fill features to make each component
grow horizontally to fill its cell.

You can fool with GridBagLayout insets to boost the minimum size.

You can write your own layout manager where you set column widths or
allocate them proportionately.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Vova Reznik - 02 Feb 2006 21:30 GMT
> Hi, I've the following components in a 6x6 gridbaglayout using java 1.4 and
> windows L&F on win2k:
[quoted text clipped - 22 lines]
>
> Cheers, Richard.

If it should look like a table with the same column width - use GridLayout
otherwise you may try SpringLayout
Big Jim - 03 Feb 2006 23:26 GMT
> Hi, I've the following components in a 6x6 gridbaglayout using java 1.4
> and windows L&F on win2k:
[quoted text clipped - 22 lines]
>
> Cheers, Richard.

Cheers for the suggestions Guys,

I solved the "columns all repainting slightly different sizes when contents
are changed" problem by letting it use the default UI (turned out to be
windowsUI) for the comboboxes, I just extended the combobox to and overode
the processKey method to get the "arrow key causes popup" behaviour I
wanted.

So, the remaining problem is the boxes in row 1 and row 5 being slightly
smaller in height. I'll try putting each row in a panel or the gridlayout as
you suggest. Any other ideas are welcome. (I've tried setting preferred
sizes and using fill.BOTH for all the boxes but it doesn't seem to solve
this problem).
Ian Mills - 04 Feb 2006 18:29 GMT
>>Hi, I've the following components in a 6x6 gridbaglayout using java 1.4
>>and windows L&F on win2k:
[quoted text clipped - 36 lines]
> sizes and using fill.BOTH for all the boxes but it doesn't seem to solve
> this problem).

Try setting weighty as this can sometimes help.
Big Jim - 04 Feb 2006 21:13 GMT
>>>Hi, I've the following components in a 6x6 gridbaglayout using java 1.4
>>>and windows L&F on win2k:
[quoted text clipped - 38 lines]
>>
> Try setting weighty as this can sometimes help.

Thanks Ian, I did try that and managed to get everthing the same size on
initial setup but then it all goes a bit weird when the JInternalFrame is
resized. Could be worth playing with it a bit more though.

Cheers, Richard.
Karsten Lentzsch - 04 Feb 2006 19:24 GMT
> Hi, I've the following components in a 6x6 gridbaglayout using java 1.4 and
> windows L&F on win2k:
[quoted text clipped - 3 lines]
> The components in row 0 and row 5 are painted smaller in height than the
> other rows. Is there a way to fix this? or, alternatively, a handy way to

I provide a Windows L&f that addresses a similar issue:
you want to align along the font baseline and want to
use consistent bounds - both at the same time. Besides
that the correct font shall be used consitently for all
dialog components. And typically you want all this in
Java 1.4, Java 5, Java 6, with Windows 95 up to Vista.

The Windows Layout Specifications and Guidelines recommend
to make all components that are arranged in a row
14 Dialog Units tall. That's what I aim to do with the
JGoodies Windows L&f. This project is open source;
the library, tutorial, docs, and a demo are available
at no charge. You may want to test drive the "Looks Demo"
to check the differences between the Sun Windows L&f,
the Winlaf L&f and the JGoodies Windows L&f, here it is:
http://www.jgoodies.com/downloads/index.html

The project home is here:
https://looks.dev.java.net/

Since Java 6 a couple of layout managers can set
components bounds such that the fonts are aligned
along the font baseline. But this may lead to inconsistent
component bounds if the bounds and font baselines
are inconsitent or arbitrary.

Hope this helps.
-Karsten Lentzsch
Roedy Green - 04 Feb 2006 21:08 GMT
On Sat, 04 Feb 2006 20:36:12 +0100, Karsten Lentzsch
<karsten@jgoodies.com> wrote, quoted or indirectly quoted someone who
said :

>http://www.jgoodies.com/downloads/index.html

I ran your looks demo under Java Web Start. The most obvious
difference is that in your JGoodies L&F you add a little white space
to the left of the text in a box rather than cramming it against the
left hand end. I think that is the most important thing in improving
the appearance.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Karsten Lentzsch - 05 Feb 2006 12:56 GMT
> [...] The most obvious
> difference is that in your JGoodies L&F you add a little white space
> to the left of the text in a box rather than cramming it against the
> left hand end. I think that is the most important thing in improving
> the appearance.

First off, I provide four L&fs: the JGoodies Windows L&f,
Plastic, Plastic3D, and PlasticXP. The differences vary
with the Java version (1.4 vs. 1.5 vs. 1.6), OS or OS edition
(Linux, Windows 95/98/.../XP/Vista), and desktop settings
(font, font size, software screen resolution etc.)

For example on Windows Vista the most obvious difference
is that the JGoodies Windows L&f uses Vista's Segoe UI font,
where other Windows L&f use the then outdated Tahoma or even
MS Sans Serif.

If you are on Windows and choose "Large Fonts" or increase
the software resolution to 120dpi, the most obvious difference
may be the font size and the corrected font baseline positions.

Anyway, I should add that I tried and try to move
these improvements and changes to the core. And it seems
that these change can be moved to the Java 7 core L&fs.

-Karsten
Big Jim - 04 Feb 2006 21:10 GMT
Thanks Karsten, I'll try this out.

>> Hi, I've the following components in a 6x6 gridbaglayout using java 1.4
>> and windows L&F on win2k:
[quoted text clipped - 31 lines]
> Hope this helps.
> -Karsten Lentzsch


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.