this.add(new JScrollPane(table)); this.add(cp, BorderLayout.SOUTH); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setPreferredScrollableViewportSize(new Dimension(250, 175)); boolean result = false; for (int r = 0; r < getRowCount(); r++) { Boolean b = (Boolean) getValueAt(r, CHECK_COL); result |= b; public Class<?> getColumnClass(int col) { if (col == CHECK_COL) { return getValueAt(0, CHECK_COL).getClass(); this.add(new JLabel("Selection:")); this.add(button); JFrame frame = new JFrame("CheckOne"); frame.add(new CheckOne()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
import javax.swing.JOptionPane; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.table.DefaultTableModel; public class TestTableCheck { private static JTable createTable() { Object[][] data = {{true, true, true}, {false, false, false}}; String[] cols = {"Bibitty", "Boppity", "Boo"}; DefaultTableModel model = new DefaultTableModel(data, cols) { @Override public Class getColumnClass(int column) { return getValueAt(0, column).getClass(); } }; JTable table = new JTable(model); return table; } public static void main(String[] args) { JOptionPane.showMessageDialog(null, new JScrollPane(createTable()), "Table", JOptionPane.PLAIN_MESSAGE); } }
public boolean include(Entry<? extends MyTableModel, ? extends Integer> entry) { MyTableModel personModel = entry.getModel(); boolean maleSex = ((Boolean) personModel.getValueAt(entry.getIdentifier(), 2)).booleanValue(); return maleSex; bottomPanel.add(showMalesButton); panel.add(new JScrollPane(table), BorderLayout.CENTER); panel.add(bottomPanel, BorderLayout.PAGE_END);
this.add(new JScrollPane(table)); this.add(new ControlPanel(), BorderLayout.SOUTH); table.setPreferredScrollableViewportSize(new Dimension(250, 175)); selectionModel = (DefaultListSelectionModel) table.getSelectionModel(); public Class<?> getColumnClass(int columnIndex) { if (columnIndex == CHECK_COL) { return getValueAt(0, CHECK_COL).getClass(); this.add(new JLabel("Selection:")); this.add(new JButton(new SelectionAction("Clear", false))); this.add(new JButton(new SelectionAction("Check", true))); JFrame frame = new JFrame("CheckABunch"); frame.add(new CheckABunch()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
return getValueAt(0, column).getClass(); JScrollPane scroll = new JScrollPane(table); scroll.getViewport().setBackground(Color.blue); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(scroll); frame.pack(); frame.setLocation(150, 150); frame.setVisible(true);
return getValueAt(0, column).getClass(); tabbedPane.addTab("Tab1", new JScrollPane(new JTable(model))); tabbedPane.addTab("Tab2", new JScrollPane(new JTable(model))); tabbedPane.addTab("Tab3", new JScrollPane(new JTable(model))); tabbedPane.addTab("Tab4", new JScrollPane(new JTable(model))); tabbedPane.setTabPlacement(JTabbedPane.TOP); tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(tabbedPane, BorderLayout.CENTER); f.pack(); f.setVisible(true);
return getValueAt(0, column).getClass(); table.setRowHeight(20); table.setPreferredScrollableViewportSize(table.getPreferredSize()); JScrollPane scroll = new JScrollPane(table); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(scroll); frame.pack(); frame.setLocation(150, 150); frame.setVisible(true);
return getValueAt(0, column).getClass(); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane); public void run() { RemoveAddRows frame = new RemoveAddRows(); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
public static void main(String args[]) { JFrame frame = new JFrame("Sort Table Demo"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Object rows[][] = { { "J", 23.1 }, { "R", 21.1, }, { "E", 21.2, }, { "B", 27.1, }, { "A", 25.2, }, { "S", 22.9, }, }; Class returnValue; if ((column >= 0) && (column < getColumnCount())) { returnValue = getValueAt(0, column).getClass(); } else { returnValue = Object.class; JScrollPane pane = new JScrollPane(table); frame.add(pane, BorderLayout.CENTER); frame.setVisible(true);
try { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE); DefaultTableModel model = new DefaultTableModel(new Object[][]{ {Boolean.FALSE, "Row 1"}, if (getRowCount() > 0 && getValueAt(0, columnIndex) != null) { return getValueAt(0, columnIndex).getClass(); frame.add(new JScrollPane(table)); frame.pack(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace();
return getValueAt(0, column).getClass(); panel1.add(runButton); tabs.addTab("first tab", panel1); JTable table = new JTable(model); JPanel buttonPanel = new JPanel(); buttonPanel.add(new JButton("A button")); buttonPanel.add(new JLabel("Some description for the awesome table below ")); buttonPanel.add(new JButton("another button")); JScrollPane tablePanel = new JScrollPane(table); JPanel container = new JPanel(); container.setLayout(new BorderLayout()); container.add(tablePanel, BorderLayout.CENTER); tabs.addTab("Preview", container); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(tabs); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
return getValueAt(0, column).getClass(); table.setPreferredScrollableViewportSize(table.getPreferredSize()); table.setFillsViewportHeight(true); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); SimpleTableDemo newContentPane = new SimpleTableDemo(); frame.add(newContentPane); frame.pack(); frame.setVisible(true);
add(new JScrollPane(table)); public Class<?> getColumnClass(int columnIndex) { if (getRowCount() > 0) { Object cell = getValueAt(0, columnIndex); if (cell != null) { return cell.getClass(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(new TabularData()); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
private JScrollPane mainPane = new JScrollPane(table); public Class<?> getColumnClass(int column) { if (getRowCount() > 0) { Object value = getValueAt(0, column); if (value != null) { return getValueAt(0, column).getClass(); table.setRowHeight(((ImageIcon)model.getValueAt(0, 1)).getIconHeight()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(imgColumnTest.getMainComponent()); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true);
return getValueAt(0, column).getClass(); panel1.add(runButton); tabs.addTab("first tab", panel1); JTable table = new JTable(model); JPanel buttonPanel = new JPanel(); buttonPanel.add(new JButton("A button")); buttonPanel.add(new JLabel("Some description for the awesome table below ")); buttonPanel.add(new JButton("another button")); JScrollPane tablePanel = new JScrollPane(table); JPanel container = new JPanel(); container.setLayout(new BorderLayout()); container.add(tablePanel, BorderLayout.CENTER); tabs.addTab("Preview", container); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(tabs); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true);
return getValueAt(0, column).getClass(); table.setRowSorter(sorter); table.setPreferredScrollableViewportSize(table.getPreferredSize()); JScrollPane scrollPane = new JScrollPane(table); add(scrollPane); public void run() { TableBoolean frame = new TableBoolean(); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true);
private JScrollPane mainPane = new JScrollPane(table); public Class<?> getColumnClass(int column) { if (getRowCount() > 0) { return getValueAt(0, column).getClass(); table.setRowHeight(((ImageIcon)model.getValueAt(0, 1)).getIconHeight()); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(imgColumnTest.getMainComponent()); frame.pack(); frame.setLocationByPlatform(true); frame.setVisible(true);
return getValueAt(0, column).getClass(); p.add(new JScrollPane(makeSampleTable())); JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.getContentPane().add(p); frame.setSize(320, 240); frame.setLocationRelativeTo(null); frame.setVisible(true);
panel.add(new JScrollPane(createTable())); JFrame frame = new JFrame("My Table"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.getContentPane().add(panel); frame.setSize(new Dimension(400, 130)); frame.setVisible(true); return getValueAt(0, column).getClass();
return getValueAt(0, column).getClass(); table.setPreferredScrollableViewportSize(table.getPreferredSize()); JScrollPane scrollPane = new JScrollPane( table ); add( scrollPane ); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.add(new TableIcon()); frame.setLocationByPlatform( true ); frame.pack(); frame.setVisible( true );