javax.swing.JTable.setPreferredSize()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(9.1k)|赞(0)|评价(0)|浏览(170)

本文整理了Java中javax.swing.JTable.setPreferredSize()方法的一些代码示例,展示了JTable.setPreferredSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTable.setPreferredSize()方法的具体详情如下:
包路径:javax.swing.JTable
类名称:JTable
方法名:setPreferredSize

JTable.setPreferredSize介绍

暂无

代码示例

代码示例来源:origin: wiztools/rest-client

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();
}

代码示例来源:origin: pentaho/mondrian

relationTable.setPreferredSize(
  new Dimension(
    tableW, tableH));

代码示例来源:origin: stackoverflow.com

chOneTable.setPreferredSize(d);
chTwoTable.setPreferredSize(d);
listTable.setPreferredSize(d);

代码示例来源:origin: com.clearnlp/clearnlp

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();
}

代码示例来源:origin: com.googlecode.clearnlp/clearnlp

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();
}

代码示例来源:origin: clearnlp/clearnlp

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();
}

代码示例来源:origin: stackoverflow.com

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);
}

代码示例来源:origin: robo-code/robocode

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();
  }
}

代码示例来源:origin: robo-code/robocode

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());
}

代码示例来源:origin: robo-code/robocode

/**
 * 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;
}

代码示例来源:origin: robward-scisys/sldeditor

panel.add(scrollPanel);
scrollPanel.setViewportView(table);
table.setPreferredSize(new Dimension(800, 300));

代码示例来源:origin: stackoverflow.com

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);

代码示例来源:origin: igniterealtime/Spark

idTable = new JTable(idControll.getTableModel());
idTable.addMouseListener(this);
idTable.setPreferredSize(new Dimension(50, 50));
idTable.setPreferredScrollableViewportSize(idTable.getPreferredSize());
idTable.setFillsViewportHeight(true);

代码示例来源:origin: uk.org.mygrid.taverna/taverna-contrib

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);

代码示例来源:origin: uk.org.mygrid.taverna/taverna-contrib

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);

代码示例来源:origin: stackoverflow.com

tableHeight = model.getRowCount()
          * 25;
      table.setPreferredSize(new Dimension(
          tableWidth, tableHeight));
table.setPreferredSize(new Dimension(
    tableWidth, tableHeight));

代码示例来源:origin: uk.org.mygrid.taverna.processors/taverna-rserv-processor

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);

代码示例来源:origin: uk.org.mygrid.taverna/taverna-contrib

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);

代码示例来源:origin: stackoverflow.com

table.setPreferredSize(new Dimension(500, 300));

代码示例来源:origin: uk.org.mygrid.taverna.processors/taverna-beanshell-processor

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),

相关文章

JTable类方法