Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 package org.apache.cayenne.swing;
 import java.util.List;
A builder for a JTable binding.

Andrei Adamchik
 public class TableBindingBuilder {
     protected BindingBuilder helper;
     protected List columns;
     public TableBindingBuilder(BindingFactory factoryObject context) {
         this(new BindingBuilder(factorycontext));
     public TableBindingBuilder(BindingBuilder helper) {
         this. = helper;

Creates a binding using preconfigured parameters.
     public ObjectBinding bindToTable(JTable tableString listBinding) {
         int width = ( != null) ? .size() : 0;
         String[] headers = new String[width];
         BindingExpression[] expressions = new BindingExpression[width];
         Class[] classes = new Class[width];
         boolean[] editableState = new boolean[width];
         Object[] sampleLongValues = new Object[width];
         for (int i = 0; i < widthi++) {
             ColumnDescriptor descriptor = (ColumnDescriptor.get(i);
             headers[i] = descriptor.header;
             expressions[i] = descriptor.expression;
             classes[i] = descriptor.columnClass;
             editableState[i] = descriptor.editable;
             sampleLongValues[i] = descriptor.sampleLongValue;
         ObjectBinding binding = .getFactory().bindToTable(
         return .initBinding(binding.getDelegate());

Adds a column to the table description.
     public void addColumn(
             String header,
             String expression,
             Class columnClass,
             boolean editable) {

Adds a column to the table description.

sampleLongValue if not null, this value rendered size is used to size the column.
     public void addColumn(
             String header,
             String expression,
             Class columnClass,
            boolean editable,
            Object sampleLongValue) {
        if ( == null) {
             = new ArrayList();
        .add(new ColumnDescriptor(
                new BindingExpression(expression),
    final class ColumnDescriptor {
        String header;
        boolean editable;
        Class columnClass;
        Object sampleLongValue;
        ColumnDescriptor(String headerBindingExpression expressionClass columnClass,
                boolean editableObject sampleLongValue) {
            this. = header;
            this. = expression;
            this. = editable;
            this. = columnClass;
            this. = sampleLongValue;
New to GrepCode? Check out our FAQ X