Beans Binding List Jtable

Posted on 2007-07-27
Last Modified: 2008-01-09
I'm trying to use Beans Binding with an JTable. It seams to work as long as I don't add any new objects to my List.
I'm not shure of where my problem starts, so I've added a simplified code of both my object, and my GUI class.
The error is pasted below the code.
The List in the object test is a result in testing. It might be a Vector or an ArrayList instead. I've tried all three.
Any one who Can see what I do wrong?

public class Prosjekter implements Serializable {
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static Reference ref = null;
    private List<Prosjekt> prosjektListe;
    public void addPropertyChangeListener(PropertyChangeListener listener) {

    public void removePropertyChangeListener(PropertyChangeListener listener) {

    public List<Prosjekt> getProsjektListe() {
        return prosjektListe;
    public void setProsjektListe(List<Prosjekt> prosjektListe) {
        List<Prosjekt> ol = this.prosjektListe;
        this.prosjektListe = prosjektListe;
        changeSupport.firePropertyChange("prosjektListe", ol, prosjektListe);
    public void addProsjekt(Prosjekt p) {
        if (this.prosjektListe == null) {
            this.prosjektListe = new Vector<Prosjekt>();
        List<Prosjekt> pl = this.prosjektListe;


Gui {
private Prosjekter prosjekter1;
private javax.beans.binding.BindingContext bindingContext;
private javax.swing.JTable Tabeller;
public Gui() {
prosjekter1 = prosjekter.getDefault();
private void initComponents() {
        Tabeller = new javax.swing.JTable();
        bindingContext = new javax.beans.binding.BindingContext();
        javax.beans.binding.Binding binding = new javax.beans.binding.Binding(prosjekter1, "${prosjektListe}", Tabeller, "elements");
        javax.beans.binding.Binding childBinding = binding.addChildBinding("${navn}", null);
        childBinding.putParameter(javax.swing.binding.ParameterKeys.COLUMN, 0);
        childBinding.putParameter(javax.swing.binding.ParameterKeys.COLUMN_CLASS, String.class);
        childBinding = binding.addChildBinding("${sistEndret}", null);
        childBinding.putParameter(javax.swing.binding.ParameterKeys.COLUMN, 1);
        childBinding.putParameter(javax.swing.binding.ParameterKeys.COLUMN_CLASS, java.util.Date.class);
private void NyttActionPerformed(java.awt.event.ActionEvent evt) {                                    
    Prosjekt p = new Prosjekt();


java.lang.IndexOutOfBoundsException: Index: 12, Size: 12
        at java.util.ArrayList.RangeCheck(
        at java.util.ArrayList.get(
        at javax.swing.JTable.getValueAt(
        at javax.swing.JTable.prepareRenderer(
        at javax.swing.plaf.basic.BasicTableUI.paintCell(
        at javax.swing.plaf.basic.BasicTableUI.paintCells(
        at javax.swing.plaf.basic.BasicTableUI.paint(
        at javax.swing.plaf.ComponentUI.update(
        at javax.swing.JComponent.paintComponent(
        at javax.swing.JComponent.paint(
        at javax.swing.JComponent.paintChildren(
        at javax.swing.JComponent.paint(
        at javax.swing.JViewport.paint(
        at javax.swing.JComponent.paintChildren(
        at javax.swing.JComponent.paint(
        at javax.swing.JComponent.paintToOffscreen(
        at javax.swing.BufferStrategyPaintManager.paint(
        at javax.swing.RepaintManager.paint(
        at javax.swing.JComponent._paintImmediately(
        at javax.swing.JComponent.paintImmediately(
        at javax.swing.RepaintManager.paintDirtyRegions(
        at javax.swing.RepaintManager.paintDirtyRegions(
        at javax.swing.RepaintManager.seqPaintDirtyRegions(
        at javax.swing.SystemEventQueueUtilities$
        at java.awt.event.InvocationEvent.dispatch(
        at java.awt.EventQueue.dispatchEvent(
[catch] at java.awt.EventDispatchThread.pumpOneEventForFilters(
        at java.awt.EventDispatchThread.pumpEventsForFilter(
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(
        at java.awt.EventDispatchThread.pumpEvents(
        at java.awt.EventDispatchThread.pumpEvents(
SEVERE [global]
Question by:kristian_gr
    1 Comment
    LVL 3

    Accepted Solution

    I think you need to add a PropertyChangeListener to prosjekter1 so that the size of the list is updated.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    Suggested Solutions

    Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
    Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
    Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
    This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now