NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Binding with custom objects and classes

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
pupeno



Joined: 27 Aug 2008
Posts: 3

PostPosted: Wed Aug 27, 2008 8:48 pm    Post subject: Binding with custom objects and classes Reply with 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?

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.



binding.png
 Description:
 Filesize:  29.85 KB
 Viewed:  3270 Time(s)

binding.png


Back to top
Jiri Vagner
Posted via mailing list.





PostPosted: Wed Aug 27, 2008 10:11 pm    Post subject: Binding with custom objects and classes Reply with quote

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

PostPosted: Thu Aug 28, 2008 5:27 am    Post subject: Thank you Reply with quote

Thank you, that worked! Is there any way to do it using an already existing instance instead of creating one?
Thanks.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
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 cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo