List of usage examples for javax.swing.table DefaultTableModel addColumn
public void addColumn(Object columnName)
From source file:Main.java
public static void main(String s[]) { DefaultTableModel model = new DefaultTableModel(); model.addColumn("Col1"); model.addColumn("Col2"); model.addRow(new Object[] { "1", "v2" }); model.addRow(new Object[] { "2", "v2" }); List<String> numdata = new ArrayList<String>(); for (int count = 0; count < model.getRowCount(); count++) { numdata.add(model.getValueAt(count, 0).toString()); }//from ww w. ja v a 2 s .c o m System.out.println(numdata); }
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"); }
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[] argv) throws Exception { DefaultTableModel model = new DefaultTableModel(); JTable table = new JTable(model); model.addColumn("Col1"); model.addColumn("Col2"); JFrame f = new JFrame(); f.setSize(300, 300);/* w w w. j av a 2 s. com*/ f.add(new JScrollPane(table)); f.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"); // Create the first row model.insertRow(0, new Object[] { "r1" }); JFrame f = new JFrame(); f.setSize(300, 300);/*from w w w.jav a 2 s . com*/ f.add(new JScrollPane(table)); f.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.addRow(new Object[] { "r1" }); model.addRow(new Object[] { "r2" }); model.addRow(new Object[] { "r3" }); // Remove the first row model.removeRow(0);/*w ww . ja v a 2 s .c om*/ JFrame f = new JFrame(); f.setSize(300, 300); f.add(new JScrollPane(table)); f.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.addRow(new Object[] { "r1" }); model.addRow(new Object[] { "r2" }); model.addRow(new Object[] { "r3" }); // Move the last row to the beginning of the table model.moveRow(model.getRowCount() - 1, model.getRowCount() - 1, 0); JFrame f = new JFrame(); f.setSize(300, 300);//w w w . ja v a 2 s . c om f.add(new JScrollPane(table)); f.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.addRow(new Object[] { "r1" }); model.addRow(new Object[] { "r2" }); model.addRow(new Object[] { "r3" }); // Move the last two rows to the start of the table model.moveRow(model.getRowCount() - 2, model.getRowCount() - 1, 0); JFrame f = new JFrame(); f.setSize(300, 300);/*from w ww . jav a 2s. com*/ f.add(new JScrollPane(table)); f.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.addRow(new Object[] { "r1" }); model.addRow(new Object[] { "r2" }); model.addRow(new Object[] { "r3" }); // Move the first two rows to the end of the table model.moveRow(0, 1, model.getRowCount() - 2); JFrame f = new JFrame(); f.setSize(300, 300);//from www .ja va 2 s . co m f.add(new JScrollPane(table)); f.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.addRow(new Object[] { "r1" }); model.addRow(new Object[] { "r2" }); model.addRow(new Object[] { "r3" }); // Move the first row to the end of the table model.moveRow(0, 0, model.getRowCount() - 1); JFrame f = new JFrame(); f.setSize(300, 300);//ww w . jav a 2s.c o m f.add(new JScrollPane(table)); f.setVisible(true); }