List of usage examples for javax.swing JTable getColumn
public TableColumn getColumn(Object identifier)
TableColumn object for the column in the table whose identifier is equal to identifier, when compared using equals. From source file:Main.java
public static void main(String[] argv) throws Exception { JTable table = new JTable(); TableColumn col = table.getColumnModel().getColumn(0); col.setCellEditor(new MyTableCellEditor()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { int rows = 3; int cols = 3; JTable table = new JTable(rows, cols); TableColumn col = table.getColumnModel().getColumn(0); col.setMinWidth(100);/*from www .j av a 2s. c o m*/ col.setMaxWidth(100); col.setPreferredWidth(100); }
From source file:Main.java
public static void main(String args[]) { JFrame frame = new JFrame(); frame.setSize(450, 250);/*w ww . ja va 2 s . c om*/ JTable table = new JTable(5, 5); TableColumn testColumn = table.getColumnModel().getColumn(0); JComboBox<String> comboBox = new JComboBox<>(); comboBox.addItem("This"); comboBox.addItem("is"); comboBox.addItem("a"); comboBox.addItem("Sample program"); testColumn.setCellEditor(new DefaultCellEditor(comboBox)); frame.add(table); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTable table = new JTable(); int vColIndex = 0; TableColumn col = table.getColumnModel().getColumn(vColIndex); col.setCellRenderer(new MyTableCellRenderer()); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JTable table = new JTable(); int vColIndex = 0; TableColumn col = table.getColumnModel().getColumn(vColIndex); col.setHeaderRenderer(new MyTableHeaderRenderer()); }
From source file:MainClass.java
public static void main(String args[]) { String rows[][] = { { "A", "a" }, { "B", "b" }, { "E", "e" } }; String headers[] = { "Upper", "Lower" }; JComboBox comboBox = new JComboBox(rows[0]); comboBox.setMaximumRowCount(4);/* w w w. java 2 s .co m*/ TableCellEditor editor = new DefaultCellEditor(comboBox); JFrame frame = new JFrame("JTable Anatomy"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable table = new JTable(new DefaultTableModel(rows, headers)); table.getColumnModel().getColumn(1).setCellEditor(editor); JScrollPane scrollPane = new JScrollPane(table); frame.add(scrollPane, BorderLayout.CENTER); frame.setSize(300, 150); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); model.addColumn("Col1"); model.addColumn("Col2"); table.getColumnModel().getColumn(0).setHeaderValue("New Name"); table.getTableHeader().resizeAndRepaint(); }
From source file:Main.java
public static void main(String[] args) { JFrame frame = new JFrame(); frame.getContentPane().setLayout(new BorderLayout()); MyTableModel model = new MyTableModel(); JTable table = new JTable(model); table.setRowHeight(80);/*from w w w . j a va2 s. c o m*/ table.getColumnModel().getColumn(0).setCellRenderer(new ImageRenderer()); JScrollPane pane = new JScrollPane(table); frame.getContentPane().add(BorderLayout.CENTER, pane); frame.setSize(500, 400); frame.setVisible(true); }
From source file:Main.java
public static void main(String[] argv) { int rows = 3; int cols = 3; JTable table = new JTable(rows, cols); // // ww w. j av a 2 s. co m table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); TableColumn col = table.getColumnModel().getColumn(0); int width = 100; col.setPreferredWidth(width); }
From source file:Main.java
public static void main(String[] argv) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); model.addColumn("Col1"); model.addColumn("Icon Here"); table.getColumnModel().getColumn(0).setHeaderValue(new ImageIcon("image.gif")); table.getColumnModel().getColumn(0).setHeaderRenderer(new IconHeaderRenderer()); }