public SessionFrame(String title){ super(title); me = this; Container c = this.getContentPane(); c.setLayout(new BorderLayout()); jt.setPreferredSize(new Dimension(200, 300)); c.add(new JScrollPane(jt), BorderLayout.CENTER); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); this.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent we){ int confirmValue = JOptionPane.showConfirmDialog(me, "You will loose any unsaved session data if you\n" + " close the Session Window. Do you want to close?", "Close Session Window?", JOptionPane.YES_NO_OPTION); if(confirmValue == JOptionPane.YES_OPTION){ stm.clear(); me.setVisible(false); } } }); pack(); }
relationTable.setPreferredSize( new Dimension( tableW, tableH));
chOneTable.setPreferredSize(d); chTwoTable.setPreferredSize(d); listTable.setPreferredSize(d);
public void init(DEPTree tree) { d_tree = tree; removeAll(); add(tree); int rowCount = j_table.getModel().getRowCount(); if (rowCount < 20) rowCount = 20; j_table.setPreferredSize(new Dimension(50, (rowCount+3) * t_height)); revalidate(); }
public void init(DEPTree tree) { d_tree = tree; removeAll(); add(tree); int rowCount = j_table.getModel().getRowCount(); if (rowCount < 20) rowCount = 20; j_table.setPreferredSize(new Dimension(50, (rowCount+3) * t_height)); revalidate(); }
public void init(DEPTree tree) { d_tree = tree; removeAll(); add(tree); int rowCount = j_table.getModel().getRowCount(); if (rowCount < 20) rowCount = 20; j_table.setPreferredSize(new Dimension(50, (rowCount+3) * t_height)); revalidate(); }
public static void main(String[] args) throws Exception { String[][] transactions = new String[][] { { "0", "Check", "50.00" }, { "1", "svc.chrg.", "0.15" } }; JDialog f = new JDialog(); JTable table = new JTable(transactions, new String[] { "Id", "Type", "Amount" }); f.add(new JLabel("List all transactions:", JLabel.CENTER), BorderLayout.NORTH); f.add(new JScrollPane(table)); f.setTitle("Dialog Display"); table.setPreferredSize(new Dimension(table.getPreferredSize().width, table.getRowHeight() * transactions.length)); f.pack(); f.setSize(470, 120); f.setLocationRelativeTo(null); // Center on screen f.setVisible(true); f.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); }
private void update() { final ITurnSnapshot current = snapshot.get(); if (lastSnapshot != current) { setResultsData(); lastSnapshot = current; tableModel.updateSource(lastSnapshot); if (table.getModel().getRowCount() != lastRows) { lastRows = table.getModel().getRowCount(); table.setPreferredSize( new Dimension(table.getColumnModel().getTotalColumnWidth(), table.getModel().getRowCount() * table.getRowHeight())); table.setPreferredScrollableViewportSize(table.getPreferredSize()); pack(); } repaint(); } }
public void setup(BattleResults[] results, int numRounds) { tableModel = new BattleResultsTableModel(results, numRounds); setTitle(((BattleResultsTableModel) getTableModel()).getTitle()); setResultsData(); table.setPreferredSize( new Dimension(table.getColumnModel().getTotalColumnWidth(), table.getModel().getRowCount() * table.getRowHeight())); table.setPreferredScrollableViewportSize(table.getPreferredSize()); }
/** * Return the scroll pane * * @return JScrollPane */ protected JScrollPane getScrollPane() { if (scrollPane == null) { scrollPane = new JScrollPane(); scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); scrollPane.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); scrollPane.setViewportView(getTable()); scrollPane.setColumnHeaderView(table.getTableHeader()); scrollPane.addComponentListener(eventHandler); tableSize = new Dimension(getTable().getColumnModel().getTotalColumnWidth(), getTable().getModel().getRowCount() * (getTable().getRowHeight())); table.setPreferredScrollableViewportSize(tableSize); table.setPreferredSize(tableSize); table.setMinimumSize(tableSize); } return scrollPane; }
panel.add(scrollPanel); scrollPanel.setViewportView(table); table.setPreferredSize(new Dimension(800, 300));
jScrollPane1 = new JScrollPane(); TableModel jTable1Model = new DefaultTableModel(...); JTable jTable1 = new JHorizontalFriendlyTable(); jScrollPane1.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); jScrollPane1.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); jScrollPane1.setViewPortView(jTable1); jTable1.setModel(jTable1Model); jTable1.setPreferredSize(new java.awt.Dimension(1051,518)); jTable1.setPreferredScrollableViewPortSize(new java.awt.Dimension(1000,528)); jTable1.getSize(new java.awt.Dimension(1051, 528)); if (jTable1.getPreferredScrollableViewPortSize().getWidth() > ((JViewPort) jTable1.getParent()).getPreferredSize().getWidth()) { jTable1.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS); jTable1.doLayout(); } jTable1.setDragEnabled(false); jTable1.setColumnSelectionAllowed(false); jTable1.getTableHeader().setReorderingAllowed(false);
idTable = new JTable(idControll.getTableModel()); idTable.addMouseListener(this); idTable.setPreferredSize(new Dimension(50, 50)); idTable.setPreferredScrollableViewportSize(idTable.getPreferredSize()); idTable.setFillsViewportHeight(true);
inputPortsTable.getActionMap().put("DELETE_PORT", deletePortAction); inputPortsTable.addMouseListener(new TableMouseListener()); inputPortsTable.setPreferredSize(new Dimension(0, 0)); inputPortsTable.getTableHeader().setPreferredSize(new Dimension(0, 0)); inputPortsTable.setRowHeight(inputPortsTable.getRowHeight() + 2); outputPortsTable.getActionMap().put("DELETE_PORT", deletePortAction); outputPortsTable.addMouseListener(new TableMouseListener()); outputPortsTable.setPreferredSize(new Dimension(0, 0)); outputPortsTable.getTableHeader().setPreferredSize(new Dimension(0, 0)); outputPortsTable.setRowHeight(outputPortsTable.getRowHeight() + 2);
inputPortsTable.getActionMap().put("DELETE_PORT", deletePortAction); inputPortsTable.addMouseListener(new TableMouseListener()); inputPortsTable.setPreferredSize(new Dimension(0, 0)); inputPortsTable.getTableHeader().setPreferredSize(new Dimension(0, 0)); inputPortsTable.setRowHeight(inputPortsTable.getRowHeight() + 2); outputPortsTable.getActionMap().put("DELETE_PORT", deletePortAction); outputPortsTable.addMouseListener(new TableMouseListener()); outputPortsTable.setPreferredSize(new Dimension(0, 0)); outputPortsTable.getTableHeader().setPreferredSize(new Dimension(0, 0)); outputPortsTable.setRowHeight(outputPortsTable.getRowHeight() + 2);
tableHeight = model.getRowCount() * 25; table.setPreferredSize(new Dimension( tableWidth, tableHeight)); table.setPreferredSize(new Dimension( tableWidth, tableHeight));
inputTable.getActionMap().put("DELETE_PORT", deletePortAction); inputTable.addMouseListener(tableMouseListener); inputTable.setPreferredSize(new Dimension(0, 0)); inputTable.getTableHeader().setPreferredSize(new Dimension(0, 0)); inputTable.setRowHeight(inputTable.getRowHeight() + 2);
inputTable.getActionMap().put("DELETE_PORT", deletePortAction); inputTable.addMouseListener(tableMouseListener); inputTable.setPreferredSize(new Dimension(0, 0)); inputTable.getTableHeader().setPreferredSize(new Dimension(0, 0)); inputTable.setRowHeight(inputTable.getRowHeight() + 2); outputTable.getColumnModel().getColumn(1).setMinWidth(10); outputTable.getColumnModel().getColumn(2).setMinWidth(10); outputTable.setPreferredSize(new Dimension(0, 0)); outputTable.getInputMap().put((KeyStroke) deletePortAction.getValue(Action.ACCELERATOR_KEY), "DELETE_PORT"); outputTable.getActionMap().put("DELETE_PORT", deletePortAction);
table.setPreferredSize(new Dimension(500, 300));
inputTable.getActionMap().put("DELETE_PORT", deletePortAction); inputTable.addMouseListener(tableMouseListener); inputTable.setPreferredSize(new Dimension(0, 0)); inputTable.getTableHeader().setPreferredSize(new Dimension(0, 0)); inputTable.setRowHeight(inputTable.getRowHeight() + 2); outputTable.getColumnModel().getColumn(1).setMinWidth(10); outputTable.getColumnModel().getColumn(2).setMinWidth(10); outputTable.setPreferredSize(new Dimension(0, 0)); outputTable.getInputMap().put( (KeyStroke) deletePortAction.getValue(Action.ACCELERATOR_KEY),