NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
pupeno
Joined: 27 Aug 2008 Posts: 3
|
Posted: Wed Aug 27, 2008 8:48 pm Post subject: Binding with custom objects and classes |
|
|
Hello,
When you right click in a combo box on the GUI editor you have an submenu called binding that allows you to bind different aspects of the combo box. I have an object, member of the dialog where that combo box is with the respective getBlah and setBlah methods. I'm trying to bind it but the dialog for binding only lists the GUI elements and the dialog class. How do I get my own object to be in that list?
Also, can I get my own class to be in that list, getBlahs() is a static method in the class (enum actually) Blah.
Thank you.
PS: I'm including a screenshot of the dialog I'm talking about in case I couldn't explain it good enough.
| Description: |
|
| Filesize: |
29.85 KB |
| Viewed: |
2237 Time(s) |

|
|
|
| Back to top |
|
 |
Jiri Vagner Posted via mailing list.
|
Posted: Wed Aug 27, 2008 10:11 pm Post subject: Binding with custom objects and classes |
|
|
pupeno wrote:
| Quote: | Hello,
When you right click in a combo box on the GUI editor you have an submenu called binding that allows you to bind different aspects of the combo box. I have an object, member of the dialog where that combo box is with the respective getBlah and setBlah methods. I'm trying to bind it but the dialog for binding only lists the GUI elements and the dialog class. How do I get my own object to be in that list?
| Hi!
This list contains all form's java bean components and Form itself. You
can add your own non-visual bean component into form and you will see it
in the list.
Example:
- add new java bean class MyStuff into project
- copy-paste code inside :
public class MyStuff {
private enum Blah{Wii,PS3, PS2,PS1,XBOX,XBOX360};
public List getBlahList() {
return Arrays.asList(Blah.values());
}
}
- compile this file
- drag&drop this file from project tree into form
- Binding Source list will contain myStuff1 bean component
Another solution - access your stuff using new bean property of Form.
Just add bean property into your form class, use Binding Source:Form and
select new property inside Binding Expression Tree.
class MyStuff {
private enum Blah{Wii,PS3, PS2,PS1,XBOX,XBOX360};
public static List getBlahList() {
return Arrays.asList(Blah.values());
}
}
public class NewJFrame extends javax.swing.JFrame {
public List getBlahList() { return MyStuff.getBlahList(); }
...
...
...
Regards,
Jirka Vagner
| Quote: |
Also, can I get my own class to be in that list, getBlahs() is a static method in the class (enum actually) Blah.
Thank you.
PS: I'm including a screenshot of the dialog I'm talking about in case I couldn't explain it good enough.
Attachments:
http://forums.netbeans.org//files/binding_568.png
|
|
|
| Back to top |
|
 |
pupeno
Joined: 27 Aug 2008 Posts: 3
|
Posted: Thu Aug 28, 2008 5:27 am Post subject: Thank you |
|
|
Thank you, that worked! Is there any way to do it using an already existing instance instead of creating one?
Thanks.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|