當前位置: 首頁>>代碼示例>>Java>>正文


Java TableColumn.setIdentifier方法代碼示例

本文整理匯總了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));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:38,代碼來源:CreateTableDialog.java

示例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);
		}
	}
}
 
開發者ID:jugglemaster,項目名稱:JuggleMasterPro,代碼行數:51,代碼來源:DataJTable.java


注:本文中的javax.swing.table.TableColumn.setIdentifier方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。