List of usage examples for javax.swing JTable JTable
public JTable(final Object[][] rowData, final Object[] columnNames)
JTable
to display the values in the two dimensional array, rowData
, with column names, columnNames
. From source file:Main.java
public Main() { String[] colNames = { "Subject", "Value" }; String[][] rowDatas = { { "Java", "Jon" }, { "C++", "Hard" }, { "Math", "Mike" }, { "Database", "Sql" } }; table = new JTable(rowDatas, colNames); button = new JButton("Show Last Record"); button.addActionListener(this); this.add(table); this.add(button); this.setVisible(true); this.setSize(300, 200); this.setDefaultCloseOperation(3); this.setLayout(new FlowLayout()); }
From source file:Main.java
public Test() { setSize(500, 210);/*from w ww .j av a 2 s . co m*/ setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JTable tabell = new JTable(cells, name); Container c = getContentPane(); c.setLayout(new FlowLayout()); c.add(new JScrollPane(tabell), BorderLayout.CENTER); }
From source file:SimpleTable.java
public SimpleTable() { super("Simple JTable Test"); setSize(300, 200);//from w w w . j a v a 2 s .c o m setDefaultCloseOperation(EXIT_ON_CLOSE); JTable jt = new JTable(new String[][] { { "This", "is" }, { "a", "Test" } }, new String[] { "Column", "Header" }); JScrollPane jsp = new JScrollPane(jt); getContentPane().add(jsp, BorderLayout.CENTER); }
From source file:MainClass.java
public MainClass() { super("Simple JTable Test"); setSize(300, 200);//from ww w. j ava 2 s. com setDefaultCloseOperation(EXIT_ON_CLOSE); File pwd = new File("."); Object[][] stats = getFileStats(pwd); JTable jt = new JTable(stats, titles); jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jt.setColumnSelectionAllowed(true); JScrollPane jsp = new JScrollPane(jt); getContentPane().add(jsp, BorderLayout.CENTER); }
From source file:Main.java
public Main() { setSize(300, 200);//from w ww. ja v a2 s . c o m setDefaultCloseOperation(EXIT_ON_CLOSE); DefaultTableModel dtm = new DefaultTableModel(new String[][] { { "1", "2", "3" }, { "4", "5", "6" } }, new String[] { "Names", "In", "Order" }); SortingColumnModel scm = new SortingColumnModel(); JTable jt = new JTable(dtm, scm); jt.createDefaultColumnsFromModel(); JScrollPane jsp = new JScrollPane(jt); getContentPane().add(jsp, BorderLayout.CENTER); }
From source file:MainClass.java
public MainClass() { super("Abstract Model JTable Test"); setSize(300, 200);/*from ww w . jav a 2 s.com*/ setDefaultCloseOperation(EXIT_ON_CLOSE); DefaultTableModel dtm = new DefaultTableModel(new String[][] { { "1", "2", "3" }, { "4", "5", "6" } }, new String[] { "Names", "In", "Order" }); SortingColumnModel scm = new SortingColumnModel(); JTable jt = new JTable(dtm, scm); jt.createDefaultColumnsFromModel(); JScrollPane jsp = new JScrollPane(jt); getContentPane().add(jsp, BorderLayout.CENTER); }
From source file:ColumnExample.java
public ColumnExample() { super("Abstract Model JTable Test"); setSize(300, 200);/*from www . ja va 2 s . c om*/ setDefaultCloseOperation(EXIT_ON_CLOSE); DefaultTableModel dtm = new DefaultTableModel(new String[][] { { "1", "2", "3" }, { "4", "5", "6" } }, new String[] { "Names", "In", "Order" }); SortingColumnModel scm = new SortingColumnModel(); JTable jt = new JTable(dtm, scm); jt.createDefaultColumnsFromModel(); JScrollPane jsp = new JScrollPane(jt); getContentPane().add(jsp, BorderLayout.CENTER); }
From source file:TableFeature.java
public TableFeature() { super("Simple JTable Test"); setSize(300, 200);/*from w w w .j a v a 2s .c o m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); File pwd = new File("."); Object[][] stats = getFileStats(pwd); JTable jt = new JTable(stats, titles); jt.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); jt.setColumnSelectionAllowed(true); JScrollPane jsp = new JScrollPane(jt); getContentPane().add(jsp, BorderLayout.CENTER); }
From source file:JTable2Pdf.java
private void createTable() { Object[][] data = { { "a", "b", "e", 4, false } }; String[] columnNames = { "A", "B", "C", "D", "E" }; table = new JTable(data, columnNames); JPanel tPanel = new JPanel(new BorderLayout()); tPanel.add(table.getTableHeader(), BorderLayout.NORTH); tPanel.add(table, BorderLayout.CENTER); getContentPane().add(tPanel, BorderLayout.CENTER); }
From source file:MainClass.java
public MainClass() throws Exception { getContentPane().setLayout(new BorderLayout()); Object[][] data = { { "A", "B", "C", new Integer(5), new Boolean(false) }, { "D", "E", "F", new Integer(3), new Boolean(true) } }; String[] columnNames = { "First Name", "Last Name", "Sport", "# of Years", "Vegetarian" }; table = new JTable(data, columnNames); JPanel tPanel = new JPanel(new BorderLayout()); tPanel.add(table.getTableHeader(), BorderLayout.NORTH); tPanel.add(table, BorderLayout.CENTER); getContentPane().add(tPanel, BorderLayout.CENTER); Document document = new Document(); PdfWriter writer;/* w ww . j a v a2s . co m*/ writer = PdfWriter.getInstance(document, new FileOutputStream("my_jtable_shapes.pdf")); // writer = PdfWriter.getInstance(document, new // FileOutputStream("my_jtable_fonts.pdf")); document.open(); PdfContentByte cb = writer.getDirectContent(); PdfTemplate tp = cb.createTemplate(500, 500); Graphics2D g2; g2 = tp.createGraphicsShapes(500, 500); // g2 = tp.createGraphics(500, 500); table.print(g2); g2.dispose(); cb.addTemplate(tp, 30, 300); // step 5: we close the document document.close(); }