本文整理汇总了Java中javax.swing.table.TableColumn.setIdentifier方法的典型用法代码示例。如果您正苦于以下问题:Java TableColumn.setIdentifier方法的具体用法?Java TableColumn.setIdentifier怎么用?Java TableColumn.setIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.TableColumn
的用法示例。
在下文中一共展示了TableColumn.setIdentifier方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: DataTable
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public DataTable(TableModel model) {
super(model);
setSurrendersFocusOnKeystroke(true);
TableColumnModel cmodel = getColumnModel();
int i;
int ccount = model.getColumnCount();
int columnWidth;
int preferredWidth;
String columnName;
int width = 0;
for (i = 0; i < ccount; i++) {
TableColumn col = cmodel.getColumn(i);
Map cmap = ColumnItem.getColumnProperty(i);
col.setIdentifier(cmap.get("name")); //NOI18N
columnName = NbBundle.getMessage (CreateTableDialog.class, "CreateTable_" + i); //NOI18N
columnWidth = (new Double(getFontMetrics(getFont()).getStringBounds(columnName, getGraphics()).getWidth())).intValue() + 20;
if (cmap.containsKey("width")) { // NOI18N
if (((Integer)cmap.get("width")).intValue() < columnWidth)
col.setPreferredWidth(columnWidth);
else
col.setPreferredWidth(((Integer)cmap.get("width")).intValue()); // NOI18N
preferredWidth = col.getPreferredWidth();
}
if (cmap.containsKey("minwidth")) // NOI18N
if (((Integer)cmap.get("minwidth")).intValue() < columnWidth)
col.setMinWidth(columnWidth);
else
col.setMinWidth(((Integer)cmap.get("minwidth")).intValue()); // NOI18N
// if (cmap.containsKey("alignment")) {}
// if (cmap.containsKey("tip")) ((JComponent)col.getCellRenderer()).setToolTipText((String)cmap.get("tip"));
if (i < 7) { // the first 7 columns should be visible
width += col.getPreferredWidth();
}
}
width = Math.min(Math.max(width, 380), Toolkit.getDefaultToolkit().getScreenSize().width - 100);
setPreferredScrollableViewportSize(new Dimension(width, 150));
}
示例2: DataJTable
import javax.swing.table.TableColumn; //导入方法依赖的package包/类
public DataJTable( ControlJFrame objPcontrolJFrame,
DataJFrame objPdataJFrame,
int intProwsNumber,
int intPcolumnsNumber,
int intPcoloredIdentifier,
Object objPdefaultValueObject,
int[] intPheaderLanguageIndexA,
int[] intPheaderToolTipLanguageIndexA) {
super(intProwsNumber, intPcolumnsNumber);
// this.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
this.objGcontrolJFrame = objPcontrolJFrame;
this.objGdataJFrame = objPdataJFrame;
this.intGcoloredIdentifier = intPcoloredIdentifier;
this.intGheaderLanguageIndexA = intPheaderLanguageIndexA;
this.intGidentifierColumnWidthA = new int[intPcolumnsNumber];
Arrays.fill(this.intGidentifierColumnWidthA, DataJTable.intS_MINIMUM_COLUMN_WIDTH);
this.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
((DefaultTableCellRenderer) this.getTableHeader().getDefaultRenderer()).setHorizontalAlignment(SwingConstants.CENTER);
this.setCellSelectionEnabled(true);
this.setOpaque(true);
this.setFocusable(false);
this.setBorder(Constants.objS_GRAPHICS_JUGGLE_BORDER);
this.objGcolumnFitAdapter = new ColumnFitAdapter(this.objGdataJFrame, this);
final ToolTipedJTableHeader objLtoolTipedJTableHeader =
new ToolTipedJTableHeader( objPcontrolJFrame,
this.getColumnModel(),
intPheaderToolTipLanguageIndexA);
objLtoolTipedJTableHeader.setFont(this.objGcontrolJFrame.getFont());
objLtoolTipedJTableHeader.addMouseListener(this.objGcolumnFitAdapter);
this.setTableHeader(objLtoolTipedJTableHeader);
// this.getTableHeader().setFont(this.objGcontrolJFrame.getFont());
// this.getTableHeader().addMouseListener(this.objGcolumnFitAdapter);
this.getColumnModel().addColumnModelListener(this.objGcolumnFitAdapter);
// Set the headers :
final TableColumnModel objLtableColumnModel = this.getColumnModel();
for (int intLcolumnIndex = 0; intLcolumnIndex < intPcolumnsNumber; ++intLcolumnIndex) {
final TableColumn objLtableColumn = objLtableColumnModel.getColumn(intLcolumnIndex);
objLtableColumn.setIdentifier(new Integer(intLcolumnIndex));
// objLtableColumn.setHeaderValue(strPheaderA[intLcolumnIndex]);
}
// Set default values :
for (int intLrowIndex = 0; intLrowIndex < intProwsNumber; ++intLrowIndex) {
for (int intLcolumnIndex = 0; intLcolumnIndex < intPcolumnsNumber; ++intLcolumnIndex) {
this.setValueAt(objPdefaultValueObject, intLrowIndex, intLcolumnIndex);
}
}
}