Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
334 views
in Technique[技术] by (71.8m points)

java - BeansBinding a JTable in NetBeans

I want map a List of beans to a JTable. The idea is that each column will be a preselected field in the bean and each row will be a bean in the List. Slide #32 here looks very promising: http://swinglabs.org/docs/presentations/2007/DesktopMatters/beans-binding-talk.pdf

However, NetBeans is not very friendly in letting me assign a bean field to a column. I can right-click the JTable and click Bind->Elements and bind it to my List of beans. However, it will not let me specify what goes in each column. The only option is to create the binding myself which pretty much makes NetBeans useless for this type of thing.

Is there a detail I'm missing? It appears that JTable BeansBinding in NetBeans is just broken.

Thanks

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have it working. You can't really use the "Bind" menu option for JTables. Here's how to get it to work:

  1. Right-Click the JTable.
  2. Click "Table Contents".
    1. Binding Source: Form
    2. Binding expression: ${var} (where var is the name of the list of beans).
  3. Click the "Columns" tab.
  4. Map the column to the expression. It should look something like ${id} not ${var.id}.

Note: Each field mapped to a column must have a getter.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...