本文整理汇总了Java中sun.swing.table.DefaultTableCellHeaderRenderer类的典型用法代码示例。如果您正苦于以下问题:Java DefaultTableCellHeaderRenderer类的具体用法?Java DefaultTableCellHeaderRenderer怎么用?Java DefaultTableCellHeaderRenderer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DefaultTableCellHeaderRenderer类属于sun.swing.table包,在下文中一共展示了DefaultTableCellHeaderRenderer类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lebarkolom
import sun.swing.table.DefaultTableCellHeaderRenderer; //导入依赖的package包/类
private void lebarkolom(){
TableColumn column;
jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
column = jTable1.getColumnModel().getColumn(0);
column.setPreferredWidth(40);
column = jTable1.getColumnModel().getColumn(1);
column.setPreferredWidth(150);
column = jTable1.getColumnModel().getColumn(2);
column.setPreferredWidth(300);
//rata tengah untuk judul kolom
DefaultTableCellHeaderRenderer tengahRenderer = new DefaultTableCellHeaderRenderer();
tengahRenderer.setHorizontalAlignment(DefaultTableCellHeaderRenderer.CENTER);
jTable1.getColumnModel().getColumn(0).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(1).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(2).setHeaderRenderer(tengahRenderer);
//rata tengah untuk kolom 0 (ID Kategori)
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
centerRenderer.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
jTable1.getColumnModel().getColumn(0).setCellRenderer(centerRenderer);
}
示例2: main
import sun.swing.table.DefaultTableCellHeaderRenderer; //导入依赖的package包/类
public static void main(String[] args) throws Exception {
DefaultTableCellHeaderRenderer.getColumnSortOrder(null, 0);
}
示例3: initTable
import sun.swing.table.DefaultTableCellHeaderRenderer; //导入依赖的package包/类
private void initTable(List<PropTypeBean> paramList){
table = new JBTable();
PropTypesModel model = new PropTypesModel();
String[] columnNames = {
"name",
"type",
"isRequired",
"describe",
"ops"};
Object[][] data = new Object[paramList.size()][5];
for (int i = 0; i < paramList.size(); i++) {
data[i][0] = paramList.get(i).name;
data[i][1] = paramList.get(i).type;
data[i][2] = paramList.get(i).isRequired;
data[i][3] = paramList.get(i).describe;
data[i][4] = false;
}
model.setDataVector(data,columnNames);
table.setModel(model);
final DefaultListSelectionModel defaultListSelectionModel = new DefaultListSelectionModel();
defaultListSelectionModel.setSelectionMode(SINGLE_SELECTION);
table.setSelectionModel(defaultListSelectionModel);
// form header center
DefaultTableCellHeaderRenderer thr = new DefaultTableCellHeaderRenderer();
thr.setHorizontalAlignment(JLabel.CENTER);
table.getTableHeader().setDefaultRenderer(thr);
//render special column
TableColumn nameColumn = table.getColumn("name");
TableColumn typeColumn = table.getColumn("type");
TableColumn isRequireColumn = table.getColumn("isRequired");
TableColumn infoColumn = table.getColumn("describe");
TableColumn operationColumn = table.getColumn("ops");
nameColumn.setCellRenderer(new TextRenderer(true));
nameColumn.setCellEditor(new DefaultCellEditor(new TextRenderer(false)));
typeColumn.setCellEditor(new DefaultCellEditor(new ComboBoxRenderer()));
typeColumn.setCellRenderer(new ComboBoxRenderer());
typeColumn.setMaxWidth(150);
isRequireColumn.setCellEditor(new DefaultCellEditor(new CheckBoxRenderer()));
isRequireColumn.setCellRenderer(new CheckBoxRenderer());
isRequireColumn.setMaxWidth(100);
infoColumn.setCellEditor(new DefaultCellEditor(new JTextField()){
@Override
public boolean isCellEditable(EventObject anEvent) {
return false;
}
});
infoColumn.setMinWidth(120);
infoColumn.setMaxWidth(150);
ButtonEditor buttonEditor = new ButtonEditor();
operationColumn.setCellRenderer(new ButtonRenderer());
operationColumn.setCellEditor(buttonEditor);
operationColumn.setMinWidth(100);
operationColumn.setMaxWidth(100);
sp.setViewportView(table);
}
示例4: lebarkolom
import sun.swing.table.DefaultTableCellHeaderRenderer; //导入依赖的package包/类
private void lebarkolom(){
TableColumn column;
jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
column = jTable1.getColumnModel().getColumn(0);
column.setPreferredWidth(40);
column = jTable1.getColumnModel().getColumn(1);
column.setPreferredWidth(200);
column = jTable1.getColumnModel().getColumn(2);
column.setPreferredWidth(100);
column = jTable1.getColumnModel().getColumn(3);
column.setPreferredWidth(50);
column = jTable1.getColumnModel().getColumn(4);
column.setPreferredWidth(100);
column = jTable1.getColumnModel().getColumn(5);
column.setPreferredWidth(75);
//rata tengah untuk judul kolom
DefaultTableCellHeaderRenderer tengahRenderer = new DefaultTableCellHeaderRenderer();
tengahRenderer.setHorizontalAlignment(DefaultTableCellHeaderRenderer.CENTER);
jTable1.getColumnModel().getColumn(0).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(1).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(2).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(3).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(4).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(5).setHeaderRenderer(tengahRenderer);
//rata tengah untuk kolom 0 (ID Kategori)
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
centerRenderer.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
jTable1.getColumnModel().getColumn(0).setCellRenderer(centerRenderer);
jTable1.getColumnModel().getColumn(2).setCellRenderer(centerRenderer);
jTable1.getColumnModel().getColumn(3).setCellRenderer(centerRenderer);
//jTable1.getColumnModel().getColumn(5).setCellRenderer(centerRenderer);
//rata kanan untuk kolom duit-duitan.
DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
rightRenderer.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT);
jTable1.getColumnModel().getColumn(4).setCellRenderer(rightRenderer);
jTable1.getColumnModel().getColumn(5).setCellRenderer(rightRenderer);
}
示例5: lebarkolom
import sun.swing.table.DefaultTableCellHeaderRenderer; //导入依赖的package包/类
private void lebarkolom(){
TableColumn column;
jTable1.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
column = jTable1.getColumnModel().getColumn(0);
column.setPreferredWidth(50);
column = jTable1.getColumnModel().getColumn(1);
column.setPreferredWidth(150);
column = jTable1.getColumnModel().getColumn(2);
column.setPreferredWidth(250);
column = jTable1.getColumnModel().getColumn(3);
column.setPreferredWidth(150);
column = jTable1.getColumnModel().getColumn(4);
column.setPreferredWidth(75);
column = jTable1.getColumnModel().getColumn(5);
column.setPreferredWidth(150);
//rata tengah untuk judul kolom
DefaultTableCellHeaderRenderer tengahRenderer = new DefaultTableCellHeaderRenderer();
tengahRenderer.setHorizontalAlignment(DefaultTableCellHeaderRenderer.CENTER);
jTable1.getColumnModel().getColumn(0).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(1).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(2).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(3).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(4).setHeaderRenderer(tengahRenderer);
jTable1.getColumnModel().getColumn(5).setHeaderRenderer(tengahRenderer);
//rata tengah untuk kolom 0 (ID Kategori)
DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
centerRenderer.setHorizontalAlignment(DefaultTableCellRenderer.CENTER);
jTable1.getColumnModel().getColumn(0).setCellRenderer(centerRenderer);
// jTable1.getColumnModel().getColumn(2).setCellRenderer(centerRenderer);
// jTable1.getColumnModel().getColumn(3).setCellRenderer(centerRenderer);
// jTable1.getColumnModel().getColumn(5).setCellRenderer(centerRenderer);
//rata kanan untuk kolom duit-duitan.
// DefaultTableCellRenderer rightRenderer = new DefaultTableCellRenderer();
// rightRenderer.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT);
// jTable1.getColumnModel().getColumn(4).setCellRenderer(rightRenderer);
}
示例6: createDefaultRenderer
import sun.swing.table.DefaultTableCellHeaderRenderer; //导入依赖的package包/类
/**
* Returns a default renderer to be used when no header renderer
* is defined by a <code>TableColumn</code>.
*
* @return the default table column renderer
* @since 1.3
*/
protected TableCellRenderer createDefaultRenderer() {
return new DefaultTableCellHeaderRenderer();
}