Package gui

Source Code of gui.DataTablePanel

package gui;


import java.awt.LayoutManager;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.table.AbstractTableModel;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import dao.IViewport;
import dao.RObject;
import dao.RObjectViewportTable;
import gui.DataTableModel;
import helper.Helper;


public class DataTablePanel extends JPanel {

    private RObjectViewportTable content;
 
    public DataTablePanel(RObjectViewportTable _content) {
        super(new GridLayout(1, 0));

        this.content = _content;

        JTable table = new JTable(new DataTableModel(content));

        // table.setPreferredScrollableViewportSize(new Dimension(500, 70));
        table.setFillsViewportHeight(true);
        table.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION);
        table.setCellSelectionEnabled(true);
        // Create the scroll pane and add the table to it.
        JScrollPane scrollPane = new JScrollPane(table);

        JTable rowHeader = new JTable(new RowHeaderTableModel(content.getAttachedRObject().getRVarName()));

        rowHeader.setIntercellSpacing(new Dimension(0, 0));
        Dimension d = rowHeader.getPreferredScrollableViewportSize();
        d.width = rowHeader.getPreferredSize().width;
        rowHeader.setPreferredScrollableViewportSize(d);
        rowHeader.setRowHeight(table.getRowHeight());
        rowHeader.setDefaultRenderer(Object.class, new RowHeaderRenderer());
        scrollPane.setRowHeaderView(rowHeader);

        // JTableHeader corner = rowHeader.getTableHeader();
        // corner.setReorderingAllowed(false);
       
        // Add the scroll pane to this panel.
        add(scrollPane);

    }

    public IViewport getContent() {
        return content;
    }

    public void setContent(RObjectViewportTable content) {
        this.content = content;
    }

}
TOP

Related Classes of gui.DataTablePanel

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.