[jaxx-interest] new blog entry: "Reinventing GridBagLayout"
Ethan Nicholas
ethan at ethannicholas.com
Thu Apr 20 18:18:04 EDT 2006
Ok, making a bit more sense now. First things first -- Table is very
much designed around GridBagLayout, and I'm not (yet, at least) going to
develop a completely new layout manager, so I'm fairly constrained here.
That said, I do want to understand your suggestion. Suppose we draw the
table with labels much narrower than the text fields, as it would be in
a typical view:
+--------+---------------------------------+
|Label 1:|Text field |
+--------+---------------------------------+
|Label 2:|Text field |
+--------+---------------------------------+
| +------+ +------+ |
| | OK | |Cancel| |
| +------+ +------+ |
+------------------------------------------+
That's the logical structure of my example, and it's important that the
vertical divide between the OK and Cancel buttons not need to match up
with the vertical divide between the labels and text fields. That's why
the third row uses a subpanel, to avoid that problem.
In your example all three rows are set up exactly the same, which has me
assuming that either A) the vertical divides will line up between all
three rows, or B) the vertical divides will not line up in any of the
rows. Either way, it doesn't match what I'm doing with my example,
unless I'm badly misreading something (which is entirely possible).
Ethan
Anderson, Kelly wrote:
> If I can try text art... :-)
>
> +------------------------------------------+
> |+----------------------------------------+|
> ||+-------------------++-----------------+||
> ||| Label 1 || Text 1 |||
> ||+-------------------++-----------------+||
> |+----------------------------------------+|
> |+----------------------------------------+|
> ||+-------------------++-----------------+||
> ||| Label 2 || Text 2 |||
> ||+-------------------++-----------------+||
> |+----------------------------------------+|
> | +--------------------+ |
> | |+--------++--------+| |
> | || OK || Cancel || |
> | |+--------++--------+| |
> | +--------------------+ |
> +------------------------------------------+
>
> The outside column says that everything inside of me is to be arranged
> vertically. The three things inside of it are the three horizontal boxes
> (rows). The first row contains two items, Label 1 and Text 1, the second
> box contains Label 2 and Text 2, the third box contains ok and cancel.
> Because the maximum horizontal size of the box containing ok and cancel
> is less than the overall width of the column, it refers to the column
> attribute "Center" to establish whether it's left justified, right
> justified, or in this case Centered...
>
> This is hard to describe in email.. :-) But I have some working code in
> C#, and a working program that I could send you.
>
> -Kelly
>
>
>> -----Original Message-----
>> From: Ethan Nicholas [mailto:ethan at ethannicholas.com]
>> Sent: Thursday, April 20, 2006 3:31 PM
>> To: Anderson, Kelly
>> Cc: jaxx-interest at jaxxframework.org
>> Subject: Re: [jaxx-interest] new blog entry: "Reinventing
>> GridBagLayout"
>>
>> It isn't a coincidence that the labels end up the same width
>> -- they are each in the first column of their row, so the
>> first column is wide enough to contain both of them. JAXX's
>> tables work essentially the same as HTML tables (quite
>> intentionally), other than my use of <row> and <cell> instead
>> of <tr> and <td>. As for why the <cell> tag is necessary,
>> it's primarily because it can (and often does) have a lot of
>> different layout attributes assigned to it.
>>
>> I'm not really sure what the alternative approach you suggest is doing
>> -- it has a single <column> tag for a table which is supposed
>> to contain two columns, and then each row contains two
>> components. How should it be interpreted? Why is there only
>> one <column> tag, and what does it do?
>>
>> Ethan
>>
>>
>> Anderson, Kelly wrote:
>>
>>> >From your blog on Table...
>>>
>>> <Table>
>>> <row>
>>> <cell><JLabel text='Username:'/></cell>
>>> <cell><JTextField id='username'/></cell>
>>> </row>
>>>
>>> <row>
>>> <cell><JLabel text='Password:'/></cell>
>>> <cell><JPasswordField id='password'/></cell>
>>> </row>
>>>
>>> <row>
>>> <cell columns='2'>
>>> <JPanel layout='{new GridLayout(1, 2, 6, 6)}'>
>>> <JButton text='OK'/>
>>> <JButton text='Cancel'/>
>>> </JPanel>
>>> </cell>
>>> </row>
>>> </Table>
>>>
>>> I don't know much about your Table XML, or GridBagLayout for that
>>> matter but I wonder why you wouldn't just do something like this to
>>> layout that
>>> dialog:
>>>
>>> <Table>
>>> <column layout='Center'>
>>> <row layout='Center'> // meaning centered up and down.
>>> <JLabel text='Username:'/>
>>> <JTextField id='username'/>
>>> </row>
>>>
>>> <row layout='Center'>
>>> <JLabel text='Password:'/>
>>> <JPasswordField id='password'/>
>>> </row>
>>>
>>> <row layout='Center'>
>>> <JButton text='OK'/>
>>> <JButton text='Cancel'/>
>>> </row>
>>> </column>
>>> </Table>
>>>
>>> Isn't that conceptually simpler? This uses the boxes and
>>>
>> glue method
>>
>>> Donald Knuth pioneered in TeX for layout of mathematical formulas.
>>> I've used it for dialog layout before, and it works very well
>>> (especially once you add a 2D grid). I'm not certain of the
>>>
>> reason for
>>
>>> the <cell> tag, but you could add it back in to such a
>>>
>> scheme if you need it.
>>
>>> It also seems just to be good luck that the text boxes
>>>
>> ended up being
>>
>>> the same width, how does that work?
>>>
>>> -Kelly
>>>
>>>
>>>
>>>
>>>> -----Original Message-----
>>>> From: jaxx-interest-bounces at jaxxframework.org
>>>> [mailto:jaxx-interest-bounces at jaxxframework.org] On Behalf
>>>>
>> Of Ethan
>>
>>>> Nicholas
>>>> Sent: Thursday, April 20, 2006 2:24 PM
>>>> To: jaxx-interest at jaxxframework.org
>>>> Subject: [jaxx-interest] new blog entry: "Reinventing
>>>>
>> GridBagLayout"
>>
>>>> Hi all,
>>>>
>>>> I've just posted a new blog entry which you may be
>>>>
>> interested in --
>>
>>>> it's about JAXX's <Table> tag. Take a look at
>>>> http://weblogs.java.net/blog/enicholas/archive/2006/04/reinven
>>>> ting_gri.html
>>>>
>>>> Also there's a post in the forum which details the steps JAXX is
>>>> going through to reach a 1.0 release:
>>>> http://www.jaxxframework.org/forum/viewtopic.php?t=36
>>>>
>>>> Ethan
>>>>
>>>> _______________________________________________
>>>> jaxx-interest mailing list
>>>> jaxx-interest at jaxxframework.org
>>>> http://jaxxframework.org/mailman/listinfo/jaxx-interest_jaxxfr
>>>> amework.org
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>> E-Mail messages may contain viruses, worms, or other
>>>
>> malicious code. By reading the message and opening any
>> attachments, the recipient accepts full responsibility for
>> taking protective action against such code. Sender is not
>> liable for any loss or damage arising from this message.
>>
>>> The information in this e-mail is confidential and may be
>>>
>> legally privileged. It is intended solely for the
>> addressee(s). Access to this e-mail by anyone else is unauthorized.
>>
>>> _______________________________________________
>>> jaxx-interest mailing list
>>> jaxx-interest at jaxxframework.org
>>>
>>>
>> http://jaxxframework.org/mailman/listinfo/jaxx-interest_jaxxframework.
>>
>>> org
>>>
>>>
>>>
>>
>>
>
>
>
>
>
> E-Mail messages may contain viruses, worms, or other malicious code. By reading the message and opening any attachments, the recipient accepts full responsibility for taking protective action against such code. Sender is not liable for any loss or damage arising from this message.
>
> The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee(s). Access to this e-mail by anyone else is unauthorized.
>
>
> _______________________________________________
> jaxx-interest mailing list
> jaxx-interest at jaxxframework.org
> http://jaxxframework.org/mailman/listinfo/jaxx-interest_jaxxframework.org
>
>
More information about the jaxx-interest
mailing list