本文整理了Java中javax.swing.JTable.prepareRenderer()
方法的一些代码示例,展示了JTable.prepareRenderer()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JTable.prepareRenderer()
方法的具体详情如下:
包路径:javax.swing.JTable
类名称:JTable
方法名:prepareRenderer
暂无
代码示例来源:origin: stackoverflow.com
public void resizeColumnWidth(JTable table) {
final TableColumnModel columnModel = table.getColumnModel();
for (int column = 0; column < table.getColumnCount(); column++) {
int width = 15; // Min width
for (int row = 0; row < table.getRowCount(); row++) {
TableCellRenderer renderer = table.getCellRenderer(row, column);
Component comp = table.prepareRenderer(renderer, row, column);
width = Math.max(comp.getPreferredSize().width +1 , width);
}
if(width > 300)
width=300;
columnModel.getColumn(column).setPreferredWidth(width);
}
}
代码示例来源:origin: ron190/jsql-injection
/**
* Get the preferred width for the specified cell
*/
private int getCellDataWidth(int row, int column) {
// Inovke the renderer for the cell to calculate the preferred width
TableCellRenderer cellRenderer = this.tableAdjust.getCellRenderer(row, column);
Component c = this.tableAdjust.prepareRenderer(cellRenderer, row, column);
return c.getPreferredSize().width + this.tableAdjust.getIntercellSpacing().width;
}
代码示例来源:origin: stackoverflow.com
JTable table = new JTable( ... );
table.setAutoResizeMode( JTable.AUTO_RESIZE_OFF );
for (int column = 0; column < table.getColumnCount(); column++)
{
TableColumn tableColumn = table.getColumnModel().getColumn(column);
int preferredWidth = tableColumn.getMinWidth();
int maxWidth = tableColumn.getMaxWidth();
for (int row = 0; row < table.getRowCount(); row++)
{
TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
Component c = table.prepareRenderer(cellRenderer, row, column);
int width = c.getPreferredSize().width + table.getIntercellSpacing().width;
preferredWidth = Math.max(preferredWidth, width);
// We've exceeded the maximum width, no need to check other rows
if (preferredWidth >= maxWidth)
{
preferredWidth = maxWidth;
break;
}
}
tableColumn.setPreferredWidth( preferredWidth );
}
代码示例来源:origin: protegeproject/protege
public Component prepareRenderer(TableCellRenderer tableCellRenderer, int i, int i1) {
Component c = super.prepareRenderer(tableCellRenderer, i, i1);
if (c instanceof AbstractButton){
((AbstractButton)c).setVerticalAlignment(SwingConstants.TOP);
}
return c;
}
代码示例来源:origin: edu.stanford.protege/org.protege.editor.core.application
public Component prepareRenderer(TableCellRenderer tableCellRenderer, int i, int i1) {
Component c = super.prepareRenderer(tableCellRenderer, i, i1);
if (c instanceof AbstractButton){
((AbstractButton)c).setVerticalAlignment(SwingConstants.TOP);
}
return c;
}
代码示例来源:origin: org.nuiton/nuiton-widgets
public Component getRendererComponent() {
TableCellRenderer cellRenderer = table.getCellRenderer(rowIndex, columnIndex);
Component component = table.prepareRenderer(cellRenderer, rowIndex, columnIndex);
return component;
}
代码示例来源:origin: org.protege/protege-editor-core-application
public Component prepareRenderer(TableCellRenderer tableCellRenderer, int i, int i1) {
Component c = super.prepareRenderer(tableCellRenderer, i, i1);
if (c instanceof AbstractButton){
((AbstractButton)c).setVerticalAlignment(SwingConstants.TOP);
}
return c;
}
代码示例来源:origin: com.fifesoft.rtext/fife.common
/**
* Overridden so that, if this component is disabled, the table
* also appears disabled (why doesn't this happen by default???).
*/
@Override
public Component prepareRenderer(TableCellRenderer renderer,
int row, int column) {
Component comp = super.prepareRenderer(renderer, row, column);
comp.setEnabled(isEnabled()); // Enable/disable renderer same as table.
return comp;
}
@Override
代码示例来源:origin: org.databene/databene-commons
public static void autoSizeTableColumns(JTable table) {
for (int column = 0; column < table.getColumnCount(); column++) {
int columnWidth = 0;
for (int row = 0; row < table.getRowCount(); row++) {
TableCellRenderer renderer = table.getCellRenderer(row, column);
Component comp = table.prepareRenderer(renderer, row, column);
columnWidth = Math.max(comp.getPreferredSize().width, columnWidth);
}
table.getColumnModel().getColumn(column).setPreferredWidth(columnWidth);
}
}
代码示例来源:origin: chatty/chatty
/**
* Adjust the width of the time column to fit the current times.
*/
private void adjustColumnSize() {
int width = 0;
for (int row = 0; row < table.getRowCount(); row++) {
TableCellRenderer renderer = table.getCellRenderer(row, 1);
Component comp = table.prepareRenderer(renderer, row, 1);
width = Math.max(comp.getPreferredSize().width, width);
}
setColumnWidth(1, width, width, width);
}
代码示例来源:origin: kaikramer/keystore-explorer
private int getCellDataWidth(int row, int column) {
// Inovke the renderer for the cell to calculate the preferred width
TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
Component c = table.prepareRenderer(cellRenderer, row, column);
return c.getPreferredSize().width + table.getIntercellSpacing().width;
}
代码示例来源:origin: SKCraft/Launcher
private int getCellDataWidth(int row, int column) {
// Inovke the renderer for the cell to calculate the preferred width
TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
Component c = table.prepareRenderer(cellRenderer, row, column);
int width = c.getPreferredSize().width + table.getIntercellSpacing().width;
return width;
}
代码示例来源:origin: net.sf.kerner-utils/kerner-utils
private int getCellDataWidth(final int row, final int column) {
// Inovke the renderer for the cell to calculate the preferred width
final TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
final Component c = table.prepareRenderer(cellRenderer, row, column);
final int width = c.getPreferredSize().width + table.getIntercellSpacing().width;
return width;
}
代码示例来源:origin: bspkrs/MCPMappingViewer
private int getCellDataWidth(int row, int column)
{
// Inovke the renderer for the cell to calculate the preferred width
TableCellRenderer cellRenderer = table.getCellRenderer(row, column);
Component c = table.prepareRenderer(cellRenderer, row, column);
int width = c.getPreferredSize().width + table.getIntercellSpacing().width;
return width;
}
代码示例来源:origin: stackoverflow.com
public Color getTableCellBackground(JTable table, int row, int col) {
TableCellRenderer renderer = table.getCellRenderer(row, col);
Component component = table.prepareRenderer(renderer, row, col);
return component.getBackground();
}
代码示例来源:origin: org.quickfixj/quickfixj-examples-banzai
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
//Execution execution = (Execution) ((ExecutionTableModel) dataModel).getExecution(row);
DefaultTableCellRenderer r = (DefaultTableCellRenderer) renderer;
r.setForeground(Color.black);
r.setBackground(row % 2 == 0 ? Color.white : Color.lightGray);
return super.prepareRenderer(renderer, row, column);
}
}
代码示例来源: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: Multibit-Legacy/multibit-hd
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
// Only called if there are rows present
JComponent c = (JComponent) super.prepareRenderer(renderer, row, column);
// Use custom rendering to overcome background color bug in Nimbus
if (!isRowSelected(row)) {
c.setBackground(row % 2 != 0 ? alternateColor : rowColor);
c.setOpaque(true);
}
return c;
}
代码示例来源:origin: tinyMediaManager/tinyMediaManager
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
Component component = super.prepareRenderer(renderer, row, column);
// if the rendere is a JComponent and the given row isn't part of a
// selection, make the renderer non-opaque so that striped rows show
// through.
if (component instanceof JComponent) {
((JComponent) component).setOpaque(getSelectionModel().isSelectedIndex(row));
}
return component;
}
代码示例来源:origin: triplea-game/triplea
@Override
public Component prepareRenderer(final TableCellRenderer renderer, final int rowIndex, final int colIndex) {
final Component component = super.prepareRenderer(renderer, rowIndex, colIndex);
final LobbyGameTableModel lobbyGameTableModel = (LobbyGameTableModel) getModel();
final GameDescription gameDescription = lobbyGameTableModel.get(convertRowIndexToModel(rowIndex));
component.setFont(gameDescription.isBot() ? ITALIC_FONT : DEFAULT_FONT);
return component;
}
}
内容来源于网络,如有侵权,请联系作者删除!