Package doc.tutorial

Source Code of doc.tutorial.TableDisplayWithConfigure$Factory

package doc.tutorial;

import java.awt.Component;

import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableModel;

import ptolemy.actor.gui.EditorPaneFactory;
import ptolemy.kernel.CompositeEntity;
import ptolemy.kernel.util.IllegalActionException;
import ptolemy.kernel.util.NameDuplicationException;
import ptolemy.kernel.util.NamedObj;

public class TableDisplayWithConfigure extends TableDisplay {
    public TableDisplayWithConfigure(CompositeEntity container, String name)
            throws IllegalActionException, NameDuplicationException {
        super(container, name);
        new Factory(this, "_factory");
    }

    public class Factory extends EditorPaneFactory {
        public Factory(NamedObj container, String name)
                throws IllegalActionException, NameDuplicationException {
            super(container, name);
        }

        public Component createEditorPane() {
            if (_table == null) {
                TableModel dataModel = new AbstractTableModel() {
                    public int getColumnCount() {
                        return 10;
                    }

                    public int getRowCount() {
                        return 10;
                    }

                    public Object getValueAt(int row, int col) {
                        return Integer.valueOf(row * col);
                    }
                };
                _table = new JTable(dataModel);
            }
            return _table;
        }
    }
}
TOP

Related Classes of doc.tutorial.TableDisplayWithConfigure$Factory

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.