本文整理匯總了Java中javax.swing.table.TableColumn.setCellRenderer方法的典型用法代碼示例。如果您正苦於以下問題:Java TableColumn.setCellRenderer方法的具體用法?Java TableColumn.setCellRenderer怎麽用?Java TableColumn.setCellRenderer使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.table.TableColumn
的用法示例。
在下文中一共展示了TableColumn.setCellRenderer方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setupColumns
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private void setupColumns() {
ResourceBundle loc = NbBundle.getBundle(DiffTreeTable.class);
setPropertyColumns(RevisionNode.COLUMN_NAME_PATH, loc.getString("LBL_DiffTree_Column_Path"), //NOI18N
RevisionNode.COLUMN_NAME_DATE, loc.getString("LBL_DiffTree_Column_Time"), //NOI18N
RevisionNode.COLUMN_NAME_USERNAME, loc.getString("LBL_DiffTree_Column_Username"), //NOI18N
RevisionNode.COLUMN_NAME_MESSAGE, loc.getString("LBL_DiffTree_Column_Message")); //NOI18N
setPropertyColumnDescription(RevisionNode.COLUMN_NAME_PATH, loc.getString("LBL_DiffTree_Column_Path_Desc"));
setPropertyColumnDescription(RevisionNode.COLUMN_NAME_DATE, loc.getString("LBL_DiffTree_Column_Time_Desc")); //NOI18N
setPropertyColumnDescription(RevisionNode.COLUMN_NAME_USERNAME, loc.getString("LBL_DiffTree_Column_Username_Desc")); //NOI18N
setPropertyColumnDescription(RevisionNode.COLUMN_NAME_MESSAGE, loc.getString("LBL_DiffTree_Column_Message_Desc")); //NOI18N
TableColumnModel model = getOutline().getColumnModel();
if (model instanceof ETableColumnModel) {
((ETableColumnModel) model).setColumnHidden(model.getColumn(1), true);
}
TableColumn column = getOutline().getColumn(loc.getString("LBL_DiffTree_Column_Message"));
column.setCellRenderer(new MessageRenderer(getOutline().getDefaultRenderer(String.class)));
setDefaultColumnSizes();
}
示例2: setupColumns
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void setupColumns() {
ResourceBundle loc = NbBundle.getBundle(DiffTreeTable.class);
setPropertyColumns(RevisionNode.COLUMN_NAME_PATH, loc.getString("LBL_DiffTree_Column_Path"),
RevisionNode.COLUMN_NAME_DATE, loc.getString("LBL_DiffTree_Column_Time"),
RevisionNode.COLUMN_NAME_USERNAME, loc.getString("LBL_DiffTree_Column_Username"),
RevisionNode.COLUMN_NAME_MESSAGE, loc.getString("LBL_DiffTree_Column_Message"));
setPropertyColumnDescription(RevisionNode.COLUMN_NAME_PATH, loc.getString("LBL_DiffTree_Column_Path_Desc"));
setPropertyColumnDescription(RevisionNode.COLUMN_NAME_DATE, loc.getString("LBL_DiffTree_Column_Time_Desc"));
setPropertyColumnDescription(RevisionNode.COLUMN_NAME_USERNAME, loc.getString("LBL_DiffTree_Column_Username_Desc"));
setPropertyColumnDescription(RevisionNode.COLUMN_NAME_MESSAGE, loc.getString("LBL_DiffTree_Column_Message_Desc"));
TableColumnModel model = getOutline().getColumnModel();
if (model instanceof ETableColumnModel) {
((ETableColumnModel) model).setColumnHidden(model.getColumn(1), true);
}
TableColumn column = getOutline().getColumn(loc.getString("LBL_DiffTree_Column_Message"));
column.setCellRenderer(new MessageRenderer(getOutline().getDefaultRenderer(String.class)));
setDefaultColumnSizes();
}
示例3: updateViewerTable
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private void updateViewerTable() {
// Set the data in the GUI and select the first entry in the table
// Tell the node model which column is the class column
m_classViewerTable.setClassColumn(m_nodeModel.getClassColumnName(),
m_nodeModel.getClassColumnIndex());
m_classViewerTable.updateEntries(m_classMap.keySet(),
m_nodeModel.getRowMap(), m_nodeModel.getColNames());
m_gui.m_hiliteTable.changeSelection(0, 0, false, false); // Select first
// entry
// Set the CellEditor
final int classColumnIndex = m_classViewerTable.getClassColumnIndex();
final TableColumn classColumn = m_gui.m_hiliteTable.getColumnModel()
.getColumn(classColumnIndex); // get the column with
// that index
classColumn.setCellEditor(m_classCellEditor);
classColumn.setCellRenderer(m_classCellRenderer);
}
示例4: RowNumberTable
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
/**
* Constructor to create a new {@link RowNumberTable} instance.
*
* @param contentTable
* the table the {@link RowNumberTable} should be created for
*/
public RowNumberTable(final JTable contentTable) {
this.contentTable = contentTable;
contentTable.addPropertyChangeListener(listener);
setFocusable(false);
setAutoCreateColumnsFromModel(false);
TableColumn column = new TableColumn();
column.setCellRenderer(new RowNumberRenderer());
addColumn(column);
// calculate preferred width dynamically
int rowCount = contentTable.getRowCount();
preferredWidth = 25;
if (rowCount > 0) {
preferredWidth = 15 + 6 * String.valueOf(rowCount).length();
}
getColumnModel().getColumn(0).setPreferredWidth(preferredWidth);
setPreferredScrollableViewportSize(getPreferredSize());
}
示例5: setUpSportColumn
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
public void setUpSportColumn(JTable table, TableColumn sportColumn) {
// Set up the editor for the sport cells.
JComboBox comboBox = new JComboBox();
comboBox.addItem("Snowboarding");
comboBox.addItem("Rowing");
comboBox.addItem("Knitting");
comboBox.addItem("Speed reading");
comboBox.addItem("Pool");
comboBox.addItem("None of the above");
sportColumn.setCellEditor(new DefaultCellEditor(comboBox));
// Set up tool tips for the sport cells.
DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
renderer.setToolTipText("Click for combo box");
sportColumn.setCellRenderer(renderer);
}
示例6: RowHeader
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
/**
* Constructor.
*/
public RowHeader() {
Table.this.addPropertyChangeListener(this);
// row header should not allow to sort.
setSortable(false);
setFocusable(false);
setAutoCreateColumnsFromModel(false);
setModel(Table.this.getModel());
setSelectionModel(Table.this.getSelectionModel());
TableColumn column = new TableColumn();
column.setHeaderValue(" ");
addColumn(column);
column.setCellRenderer(new RowNumberRenderer());
getColumnModel().getColumn(0).setPreferredWidth(50);
setPreferredScrollableViewportSize(getPreferredSize());
}
示例7: initTable
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private void initTable() {
final TableColumn tailleColumn = getColumn(FileTableModel.TAILLE_HEADER);
tailleColumn.setCellRenderer(new IntegerTableCellRenderer());
tailleColumn.setMaxWidth(60);
final TableColumn typeIconColumn = getColumn(FileTableModel.TYPE_ICON_HEADER);
typeIconColumn.setCellRenderer(new IconTableCellRenderer());
typeIconColumn.setMaxWidth(30);
setPreferredScrollableViewportSize(new Dimension(530, 150));
}
示例8: RunPortBindingsVisual
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
/**
* Creates new form RunNetworkVisual
*/
public RunPortBindingsVisual(DockerImageDetail info) {
initComponents();
this.info = info;
addExposedButton.setEnabled(info != null && !info.getExposedPorts().isEmpty());
portMappingTable.setModel(model);
UiUtils.configureRowHeight(portMappingTable);
TableColumn typeColumn = portMappingTable.getColumnModel().getColumn(0);
JComboBox typeCombo = new JComboBox(ExposedPort.Type.values());
typeColumn.setCellEditor(new DefaultCellEditor(typeCombo));
typeColumn.setPreferredWidth(typeColumn.getPreferredWidth() / 2);
TableColumn portColumn = portMappingTable.getColumnModel().getColumn(2);
portColumn.setCellRenderer(new CellRenderer("<random>", false));
TableColumn addressColumn = portMappingTable.getColumnModel().getColumn(3);
JComboBox addressCombo = new JComboBox(UiUtils.getAddresses(false, false).toArray());
addressCombo.setEditable(true);
addressColumn.setCellEditor(new DefaultCellEditor(addressCombo));
addressColumn.setCellRenderer(new CellRenderer("<any>", false));
addressColumn.setPreferredWidth(addressColumn.getPreferredWidth() * 2);
portMappingTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
model.addTableModelListener(new TableModelListener() {
@Override
public void tableChanged(TableModelEvent e) {
changeSupport.fireChange();
}
});
}
示例9: columnStyle
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
protected void columnStyle(TableColumnModel tcm, int column, int min, int mid, int max, TableCellRenderer rend)
{
TableColumn tc = tcm.getColumn(column);
if (tc == null) return;
tc.setMinWidth(min);
tc.setPreferredWidth(mid);
tc.setMaxWidth(max);
tc.setCellRenderer(rend);
}
示例10: setRendererAndEditors
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
/**
* Sets the renderer and editor for the table.
*/
private void setRendererAndEditors() {
// --- Set Renderer, Editors and layout -----------
TableColumn propColumn = this.getColumnModel().getColumn(0);
propColumn.setCellRenderer(new DynTableCellRenderEditor(this.dynForm));
TableColumn valueColumn = this.getColumnModel().getColumn(1);
valueColumn.setCellEditor(new DynTableCellRenderEditor(this.dynForm));
valueColumn.setCellRenderer(new DynTableCellRenderEditor(this.dynForm));
this.getColumnModel().getColumn(0).setPreferredWidth(180);
this.getColumnModel().getColumn(1).setPreferredWidth(80);
}
示例11: SubmissionTable
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
/**
* Default constructor.
*/
public SubmissionTable(final List<Submission> submissions) {
this.submissions = submissions;
this.model = new SubmissionTableModel(this.submissions);
this.setModel(model);
for (int i = 0; i < this.getColumnModel().getColumnCount(); i++) {
final TableColumn column = getColumnModel().getColumn(i);
if (i % 2 == 0) {
column.setCellRenderer(new TextAreaCellRenderer());
column.setCellEditor(new TextAreaCellEditor());
}
}
this.updateRowDimensions();
}
示例12: setupBasicTableProperties
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
/**
* setting up the table.
*
* @param table JTable to store this.correlationTableModel
*/
private void setupBasicTableProperties(JTable table) {
table.clearSelection();
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
TableRenderer cellRenderer = new TableRenderer(new JTextField());
table.setRowSelectionAllowed(true);
table.setColumnSelectionAllowed(false);
table.setVisible(true);
table.setModel(this.variationPerParameterTableModel);
initColumnSizes(table);
for (int i = 0; i < table.getColumnCount(); i++) {
TableColumn column = table.getColumnModel().getColumn(i);
column.setCellRenderer(cellRenderer);
}
TableColumn columnName = table.getColumnModel().getColumn(VariationPerParameterTableModel.COLUMN_NAME);
columnName.setCellEditor(new TextCellEditor());
TableColumn columnBasicValue = table.getColumnModel().getColumn(VariationPerParameterTableModel.COLUMN_BASIC_VALUE);
columnBasicValue.setCellEditor(new TextCellEditor());
setupVariationFunctionComboBoxColumn();
this.variationPerParameterTableModel.fireTableDataChanged();
table.setColumnSelectionAllowed(false);
table.setRowSelectionAllowed(true);
//select first row.
table.getSelectionModel().setSelectionInterval(0, 0);
}
示例13: setupBasicTableProperties
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
/**
* setting up the table.
*
* @param table JTable to store this.correlationTableModel
*/
private void setupBasicTableProperties(JTable table) {
table.clearSelection();
table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
TableRenderer cellRenderer = new TableRenderer(new JTextField());
table.setRowSelectionAllowed(true);
table.setColumnSelectionAllowed(false);
table.setVisible(true);
table.setModel(this.resultsTableModel);
initColumnSizes(table);
for (int i = 0; i < table.getColumnCount(); i++) {
TableColumn column = table.getColumnModel().getColumn(i);
column.setCellRenderer(cellRenderer);
}
TableColumn columnName = table.getColumnModel().getColumn(ResultSelectionModel.COLUMN_NAME);
columnName.setCellEditor(new TextCellEditor());
TableColumn columnDescription = table.getColumnModel().getColumn(ResultSelectionModel.COLUMN_DESCRIPTION);
columnDescription.setCellEditor(new TextCellEditor());
this.resultsTableModel.fireTableDataChanged();
table.setColumnSelectionAllowed(false);
table.setRowSelectionAllowed(true);
//select first row.
table.getSelectionModel().setSelectionInterval(0, 0);
}
示例14: setRenderer
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private static void setRenderer(TableColumn column) {
if (!(column.getCellRenderer() instanceof TableClassNameRenderer)) {
column.setCellRenderer(new TableClassNameRenderer());
}
}
示例15: setUpColumn
import javax.swing.table.TableColumn; //導入方法依賴的package包/類
private void setUpColumn(TableColumn column) {
column.setCellRenderer(cellEditor);
column.setCellEditor(cellEditor);
}