[ale] OT another Java question
Geoffrey
esoteric at 3times25.net
Tue Nov 26 11:53:34 EST 2002
I appreciate your insights. I've got a working solution now, but will
be looking into your suggestions. Thanks muchly.
Denny Chambers wrote:
> To find this add method, look in java.awt.Container.add(String,
> Component). However I would not use this method. Even the Java docs
> recommend not using this. If you want to use this type of layout, then
> try something like this:
>
> MyPanel p1;
>
> p1 = new MyPanel(10,3,rowHeading, colHeading);
> p1.setBounds(new Rectangle(3,270,388,320));
> this.add(p1);
> initNewPanel(p1);
>
> // adds a text field
> FieldA.setBounds(new Rectangle(145,40.120,30));
> p1.add(FieldA);
>
> This may work better for you. I have to warn you though, this type of
> layout does not resize very well at all. As far as the layout goes, you
> should really look at the GridBagLayout as you layout manager. It is the
> most flexible of the layout managers, however it is also one of the more
> complex. Done properly, is looks very professional, and can resize much
> better than the other layout managers.
>
> HTH,
> Denny
>
> Geoffrey wrote:
>
>> Okay folks this one's been driving me crazy. Here's the poop. Got some
>> code that has a class:
>>
>> public class MyPanel extends Panel {}
>>
>> Basically builds a panel that has a table, look multiple cells.
>>
>> Existing code does the following to create a panel and place items in
>> the cells:
>>
>> MyPanel p1;
>>
>> p1 = new MyPanel(10,3,rowHeading, colHeading);
>> this.add("3,270,388,320", p1);
>> initNewPanel(p1);
>>
>> // adds a text field
>>
>> p1.add("145,40.120,30", FieldA);
>>
>>
>> First I can't find this 'variation' of add() anywhere.
>>
>> Further, I retain this code with the exception of removing the
>> 'initNewPanel()' which just sets up the foreground/background color. I
>> omit it because initNewPanel() is in a class we are no longer using.
>>
>> Anyway, the same code produces the FieldA in the wrong place on the
>> panel, and further, it appears that no mather what values I pass to
>> the add() the field always shows up in the same place, and same size
>> (which is wrong as well.
>>
>>
>> The main problem is I need to use MyPanel because of the way it builds
>> the table.
>>
>> Any assistance would be appreciated.
>>
>
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale
>
>
--
Until later: Geoffrey esoteric at 3times25.net
I didn't have to buy my radio from a specific company to listen
to FM, why doesn't that apply to the Internet (anymore...)?
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale
More information about the Ale
mailing list