1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
|
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.event.TableModelListener;
import javax.swing.event.TableModelEvent;
import javax.swing.table.*;
import java.awt.Dimension;
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import java.util.*;
public class doubleTable extends JPanel
{
private JTable tableFix;
private JTable table;
private FixedTableModelSuite modelJTable;
private FixedTableModel modelJTableFix;
private int nbColonneFixe;
private Object [][] data;
private String [] columnNames;
private boolean[][] Edit=null;
private int NbLigne,NbCol;
private boolean emptyTab;
private Color mycolor;
private JScrollPane scrollpane;
public doubleTable(Object[][] data, String[] columnNames, int nbColonneFixe,boolean emptyTab)
{
this.nbColonneFixe = nbColonneFixe;
this.data = data;
this.columnNames = columnNames;
mycolor = new Color(232, 232, 232);
this.modelJTable=new FixedTableModelSuite (data,columnNames,nbColonneFixe,emptyTab);
this.table = new JTable (modelJTable);
this.table.setAutoResizeMode (JTable.AUTO_RESIZE_OFF);
this.table.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
this.table.getTableHeader().setReorderingAllowed(false);
this.table.setSelectionBackground(Color.cyan);
this.table.setSelectionForeground(Color.black);
this.table.setDefaultRenderer(Object.class,new CustomTable());
this.table.setRowSelectionAllowed(emptyTab);
this.table.setColumnSelectionAllowed(emptyTab);
this.modelJTableFix=new FixedTableModel (data,columnNames,nbColonneFixe,emptyTab);
this.tableFix = new JTable (modelJTableFix);
this.tableFix.setAutoResizeMode (JTable.AUTO_RESIZE_OFF);
this.tableFix.setSelectionMode (ListSelectionModel.SINGLE_SELECTION);
this.tableFix.getTableHeader().setReorderingAllowed(false);
this.tableFix.setSelectionBackground(Color.cyan);
this.tableFix.setSelectionForeground(Color.black);
this.tableFix.setDefaultRenderer(Object.class,new CustomTable());
this.tableFix.setRowSelectionAllowed(emptyTab);
this.tableFix.setColumnSelectionAllowed(emptyTab);
this.NbLigne=table.getRowCount();
this.NbCol=table.getColumnCount();
scrollpane=new JScrollPane();
scrollpane.setViewportView (this.table);
JViewport view = new JViewport ();
view.setView (this.tableFix);
view.setPreferredSize (this.tableFix.getPreferredSize ());
scrollpane.setRowHeaderView (view);
scrollpane.setCorner (JScrollPane.UPPER_LEFT_CORNER, this.tableFix.getTableHeader ());
scrollpane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
add(scrollpane);
} |