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

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

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

JTable.getRowHeight介绍

暂无

代码示例

代码示例来源:origin: alibaba/druid

public RowHeaderRenderer(ArrayList<String> headerList, JTable refTable, JTable tableShow, int rowSpan){
  this.headerList = headerList;
  this.refTable = refTable;
  this.tableShow = tableShow;
  // 增加监听器,实现当在refTable中选择行时,RowHeader会发生颜色变化
  ListSelectionModel listModel = refTable.getSelectionModel();
  listModel.addListSelectionListener(this);
  rowHeightNow = refTable.getRowCount() * refTable.getRowHeight();
  this.rowSpan = rowSpan;
  if (rowSpan > 1) {
    rowHeightNow = rowSpan * refTable.getRowHeight();
  }
}

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

/**
 * Selects a the specified row in the specified JTable and scrolls
 * the specified JScrollpane to the newly selected row. More importantly,
 * the call to repaint() delayed long enough to have the table
 * properly paint the newly selected row which may be offscre
 * @param table should belong to the specified JScrollPane
 */
public static void selectRow(int row, JTable table, JScrollPane pane) {
 if (table == null || pane == null) {
  return;
 }
 if (contains(row, table.getModel()) == false) {
  return;
 }
 moveAdjustable(row * table.getRowHeight(), pane.getVerticalScrollBar());
 selectRow(row, table.getSelectionModel());
 // repaint must be done later because moveAdjustable
 // posts requests to the swing thread which must execute before
 // the repaint logic gets executed.
 repaintLater(table);
}

代码示例来源:origin: com.alibaba/druid

public RowHeaderRenderer(ArrayList<String> headerList, JTable refTable, JTable tableShow, int rowSpan){
  this.headerList = headerList;
  this.refTable = refTable;
  this.tableShow = tableShow;
  // 增加监听器,实现当在refTable中选择行时,RowHeader会发生颜色变化
  ListSelectionModel listModel = refTable.getSelectionModel();
  listModel.addListSelectionListener(this);
  rowHeightNow = refTable.getRowCount() * refTable.getRowHeight();
  this.rowSpan = rowSpan;
  if (rowSpan > 1) {
    rowHeightNow = rowSpan * refTable.getRowHeight();
  }
}

代码示例来源:origin: magefree/mage

@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
  if (this.table == null) {
    this.table = table;
  }
  currentOriginalHeigh = table.getRowHeight(row);
  currentRow = row;
  
  if (!valueSet) {
    spinner.setValue(value);
  }
  SwingUtilities.invokeLater(() -> textField.requestFocus());
  return spinner;
}

代码示例来源:origin: camunda/camunda-bpm-platform

/**
 * Selects a the specified row in the specified JTable and scrolls
 * the specified JScrollpane to the newly selected row. More importantly,
 * the call to repaint() delayed long enough to have the table
 * properly paint the newly selected row which may be offscre
 * @param table should belong to the specified JScrollPane
 */
public static void selectRow(int row, JTable table, JScrollPane pane) {
 if (table == null || pane == null) {
  return;
 }
 if (contains(row, table.getModel()) == false) {
  return;
 }
 moveAdjustable(row * table.getRowHeight(), pane.getVerticalScrollBar());
 selectRow(row, table.getSelectionModel());
 // repaint must be done later because moveAdjustable
 // posts requests to the swing thread which must execute before
 // the repaint logic gets executed.
 repaintLater(table);
}

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

Dimension d = table.getPreferredSize();
scrollPane.setPreferredSize(
  new Dimension(d.width,table.getRowHeight()*rows));
next.addActionListener( new ActionListener(){
  public void actionPerformed(ActionEvent ae) {
    int height = table.getRowHeight()*(rows-1);
    JScrollBar bar = scrollPane.getVerticalScrollBar();
    bar.setValue( bar.getValue()+height );
previous.addActionListener( new ActionListener(){
  public void actionPerformed(ActionEvent ae) {
    int height = table.getRowHeight()*(rows-1);
    JScrollBar bar = scrollPane.getVerticalScrollBar();
    bar.setValue( bar.getValue()-height );

代码示例来源:origin: org.geotools/gt2-widgets-swing

/** Returns the row height, making sure it is identical to the main table. */
  public int getRowHeight(final int row) {
    return table.getRowHeight(row);
  }
}

代码示例来源:origin: abc9070410/JComicDownloader

private void showRecordPopup(MouseEvent event) {
  recordTablePopupRow = event.getY() / recordTable.getRowHeight();
  if (recordTablePopupRow < Common.recordCount && recordTablePopupRow >= 0) {
    if (event.isPopupTrigger()) {
      recordTablePopup.show(event.getComponent(), event.getX(), event.getY());
    }
  }
}

代码示例来源:origin: abc9070410/JComicDownloader

private void showDownloadPopup(MouseEvent event) {
  downloadTablePopupRow = event.getY() / downTable.getRowHeight();
  if (downloadTablePopupRow < Common.missionCount && downloadTablePopupRow >= 0) {
    if (event.isPopupTrigger()) {
      downloadTablePopup.show(event.getComponent(), event.getX(), event.getY());
    }
  }
}

代码示例来源:origin: abc9070410/JComicDownloader

private void showBookmarkPopup(MouseEvent event) {
  bookmarkTablePopupRow = event.getY() / bookmarkTable.getRowHeight();
  if (bookmarkTablePopupRow < Common.bookmarkCount && bookmarkTablePopupRow >= 0) {
    if (event.isPopupTrigger()) {
      bookmarkTablePopup.show(event.getComponent(), event.getX(), event.getY());
    }
  }
}

代码示例来源:origin: abc9070410/JComicDownloader

@Override
public void mouseMoved(MouseEvent event) {
  JTable table = (JTable) event.getSource();
  // 現在滑鼠所在的列
  CommonGUI.nowMouseAtRow = event.getY() / table.getRowHeight();
  table.repaint(); // 給目前滑鼠所在列改變字體顏色
}

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

static public void setTableHeight(JTable table, int rows)
{
  int width = table.getPreferredSize().width; 
  int height = rows * table.getRowHeight(); 
  table.setPreferredScrollableViewportSize(new Dimension(width, height));
}

代码示例来源:origin: net.sf.jga/jga

protected void paintComponent(Graphics g) {
  // TODO: this is naive: we should take the clipping region into account and
  // only paint the visible rows
  
  Rectangle cellRect = new Rectangle(0,0,getWidth(),_table.getRowHeight(0));
  int rowMargin = _header.getColumnModel().getColumnMargin() - 1;
  for (int i = 0; i < _table.getRowCount(); ++i) {
    int rowHeight = _table.getRowHeight(i);
    cellRect.height = rowHeight - rowMargin;
    paintCell(g, cellRect, i);
    cellRect.y += rowHeight;
  }
}

代码示例来源:origin: protegeproject/protege

private void handleScrollpaneViewportChanged() {
  Rectangle tableVisibleRect = resultsTable.getVisibleRect();
  TableColumn categoryColumn = resultsTable.getColumnModel().getColumn(0);
  int columnWidth = categoryColumn.getWidth();
  int rowHeight = resultsTable.getRowHeight() * 2;
  scrollPane.repaint(new Rectangle(tableVisibleRect.x, tableVisibleRect.y, columnWidth, rowHeight));
}

代码示例来源:origin: otros-systems/otroslogviewer

private void updateRowHeights() {
 for (int row = 0; row < jTable.getRowCount(); row++) {
  int rowHeight = jTable.getRowHeight();
  for (int column = 0; column < jTable.getColumnCount(); column++) {
   Component comp = jTable.prepareRenderer(jTable.getCellRenderer(row, column), row, column);
   comp.setSize(jTable.getColumnModel().getColumn(column).getWidth(), comp.getPreferredSize().height);
   rowHeight = Math.max(rowHeight, comp.getPreferredSize().height);
  }
  jTable.setRowHeight(row, rowHeight + jTable.getRowMargin());
 }
}

代码示例来源:origin: org.appdapter/org.appdapter.lib.gui

@Override public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
  int width = table.getColumnModel().getColumn(column).getWidth();
  int height = table.getRowHeight(row);
  this.render_col = column;
  this.render_row = row;
  return renderComponent(table, value, row, column, isSelected, width, table.getSelectionBackground(), table.getSelectionForeground());
}

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

public Component getTableCellRendererComponent(JTable jTable, Object obj, boolean isSelected, boolean hasFocus,
                          int row, int column) {
    // set color & border here
    setText(obj == null ? "" : obj.toString());
    setSize(jTable.getColumnModel().getColumn(column).getWidth(),
        getPreferredSize().height);
    if (jTable.getRowHeight(row) != getPreferredSize().height) {
      jTable.setRowHeight(row, getPreferredSize().height);
    }
    return this;
  }
}

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

public Component getTableCellRendererComponent(JTable jTable, Object obj, boolean isSelected, boolean hasFocus,
                          int row, int column) {
    // set color & border here
    setText(obj == null ? "" : obj.toString());
    setSize(jTable.getColumnModel().getColumn(column).getWidth(),
        getPreferredSize().height);
    if (jTable.getRowHeight(row) != getPreferredSize().height) {
      jTable.setRowHeight(row, getPreferredSize().height);
    }
    return this;
  }
}

代码示例来源:origin: org.orbisgis/orbisgis-view

@Override
public void updateUI() {
    super.updateUI();
    if(table!=null) {
        setFixedCellHeight(table.getRowHeight());
        computeCellWidth();
    }
}

代码示例来源: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());
}

相关文章

JTable类方法