Skip to main content

Why org.jdesktop.swing.form.BindingBorder is not public?

4 replies [Last post]
mceccarellitnx
Offline
Joined: 2004-06-30
Points: 0

I want to build swing application without xml script, i see the example TableFormDemo and i want to make similar application but i need to layout manually each components.
So i see the code from org.jdesktop.swing.form.* and when i need to use BindingBorder i have to copy in my project because it is private.
This is my fisrt approach to jdnc and excuse for my english.

my example code:
DataSourceModelTest customer = new DataSourceModelTest();
TextBinding tb1 = new TextBinding(jTextField1, customer, "codice");
TextBinding tb2 = new TextBinding(jTextField2, customer, "nome");
BooleanBinding bb1 = new BooleanBinding(jCheckBox1, customer, "flag");

int iconPosition = javax.swing.SwingConstants.EAST;
BindingBorder bborder = new BindingBorder(tb1, iconPosition);
Insets insets = bborder.getBorderInsets(jTextField1);
Dimension prefSize = jTextField1.getPreferredSize();
prefSize.width += (insets.left + insets.right);
jTextField1.setPreferredSize(prefSize);
jTextField1.setBorder(new CompoundBorder(jTextField1.getBorder(),bborder));

tb1.pull();
tb2.pull();
bb1.pull();

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Kleopatra

jdnc-interest@javadesktop.org wrote:

> So i see the code from org.jdesktop.swing.form.* and
> when i need to use BindingBorder i have to copy
> in my project because it is private.

it's public since Friday :-)

> This is my fisrt approach to jdnc and excuse for my english.

no problem.

>
> my example code:
> DataSourceModelTest customer = new DataSourceModelTest();
> TextBinding tb1 = new TextBinding(jTextField1, customer, "codice");
> TextBinding tb2 = new TextBinding(jTextField2, customer, "nome");
> BooleanBinding bb1 = new BooleanBinding(jCheckBox1, customer, "flag");
>

allow me a note: that's not the main avenue to go (though possible) -
which components/bindings to create should be left to a JForm most of
the time, something like (assuming the DataSourceModel is a DataModel):

JForm myForm = new JForm();
myForm.setAutoLayout(false);
// let the form create an appropriate component and bind it
Binding tb1 = myForm.bind(customer, "codice");
// do whatever you need to do to the created component
// and then add it to the form
doConfigue(tb1.getComponent());
addToForm(tb1.getComponent());
// ..
form.pull();

(that's from the top of my head, after all, it's Sunday )

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

mceccarellitnx
Offline
Joined: 2004-06-30
Points: 0

> allow me a note: that's not the main avenue to go
> (though possible) -
> which components/bindings to create should be left to
> a JForm most of
> the time, something like (assuming the
> DataSourceModel is a DataModel):
>
> JForm myForm = new JForm();
> myForm.setAutoLayout(false);
> // let the form create an appropriate component and
> bind it
> Binding tb1 = myForm.bind(customer, "codice");
> // do whatever you need to do to the created
> component
> // and then add it to the form
> doConfigue(tb1.getComponent());
> addToForm(tb1.getComponent());
> // ..
> form.pull();
>
> (that's from the top of my head, after all, it's
> Sunday )
>
> Jeanette
>

Thank you, i don't know about myForm.setAutoLayout(false);
now i try...

another question?
reading the code and trying it i saw this line 445 (ver 0.6 inside isFormValid()) in JForm.java i think theres is an error

for(int j = 0; i < validators.length; j++) {...

the i must be j ?

and i'm not sure but i have errors by AbstractDataModel when getting validators:
public Validator[] getValidators() {
if (validators != null) {
return (Validator[]) validators.toArray();
}
return new Validator[0];
}

i've changed in:
public Validator[] getValidators() {
Validator[] validatorsArray = new Validator[validators.size()];
for (int i = 0; i < validators.size(); i++) {
validatorsArray[i] = (Validator)validators.get(i);
}
return validatorsArray;
}

Kleopatra

jdnc-interest@javadesktop.org wrote:
>
> another question?
> reading the code and trying it i saw this line 445 (ver 0.6 inside isFormValid()) in JForm.java i think theres is an error
>
> for(int j = 0; i < validators.length; j++) {...
>
> the i must be j ?
>

yes I think so...

> and i'm not sure but i have errors by AbstractDataModel when getting validators:
> public Validator[] getValidators() {
> if (validators != null) {
> return (Validator[]) validators.toArray();
> }
> return new Validator[0];
> }

... again yes.

I added both as bugs to the issue tracker. For the future, may I suggest
that you do it - preferably complete with test cases exposing the
misbehaviour and suggestions how to fix it (yeah, I'm lazy :-).

Thanks.

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

mceccarellitnx
Offline
Joined: 2004-06-30
Points: 0

> I added both as bugs to the issue tracker. For the
> future, may I suggest
> that you do it - preferably complete with test cases
> exposing the
> misbehaviour and suggestions how to fix it (yeah, I'm
> lazy :-).
>

uh..
i've seen now the Issue tracker.
for the next time i'm ready :-)

thank you, bye.