当前位置: 首页>>代码示例>>Java>>正文


Java DefaultTableCellRenderer.setHorizontalAlignment方法代码示例

本文整理汇总了Java中javax.swing.table.DefaultTableCellRenderer.setHorizontalAlignment方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTableCellRenderer.setHorizontalAlignment方法的具体用法?Java DefaultTableCellRenderer.setHorizontalAlignment怎么用?Java DefaultTableCellRenderer.setHorizontalAlignment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.table.DefaultTableCellRenderer的用法示例。


在下文中一共展示了DefaultTableCellRenderer.setHorizontalAlignment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TelaBuscarVeiculo

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public TelaBuscarVeiculo() {
    initComponents();
    
    jtb_Veiculos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    
    ButtonGroup group = new ButtonGroup();
    group.add(jrb_Marca);
    group.add(jrb_Modelo);
    group.add(jrb_Ano);
    group.add(jrb_MenorPreco);
    group.add(jrb_MaiorPreco);
    
    DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
    centerRenderer.setHorizontalAlignment( JLabel.CENTER );
    jtb_Veiculos.setDefaultRenderer(Object.class, centerRenderer);
    
}
 
开发者ID:Mentz,项目名称:PPRCarTrade,代码行数:18,代码来源:TelaBuscarVeiculo.java

示例2: atualizaTela

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public void atualizaTela(){
    meusVeiculos = new ArrayList<>();
    
    DefaultTableCellRenderer centerRenderer = new DefaultTableCellRenderer();
    centerRenderer.setHorizontalAlignment( JLabel.CENTER );
    jtb_Veiculos.setDefaultRenderer(Object.class, centerRenderer);        
    
    jtb_Veiculos.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    DefaultTableModel model = (DefaultTableModel)jtb_Veiculos.getModel();
    model.setRowCount(0);
    ArrayList<VendaVeiculo> aux = NegocioFacade.listaVeiculos();
    Usuario logado = NegocioFacade.getUsuarioLogado();
    for(VendaVeiculo a : aux){
        if(a.getProprietario().getCpf().equals(logado.getCpf())){
            model.addRow(new Object[]{ a.getVeiculo().getMarca(), a.getVeiculo().getModelo(), 
                                       a.getVeiculo().getCor(), a.getVeiculo().getAno(), a.getPreco()});
            meusVeiculos.add(a);
        }
    }
    jtb_Veiculos.setModel(model);
}
 
开发者ID:Mentz,项目名称:PPRCarTrade,代码行数:22,代码来源:TelaUsuarioVendas.java

示例3: buildTable

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
/**
 * Construye la JTable donde se almacenan los datos
 */
private void buildTable() {
    if (!tableFlag) {
        table = new JTable();

        String[] headerTitles = new String[variableList.size()];
        Object[][] tableContent = new Object[mainBuffer.get(0).size()][variableList.size()];

        for (int i = 0; i < variableList.size(); i++) {
            headerTitles[i] = variableList.get(i);
            for (int j = 0; j < mainBuffer.get(i).size(); j++) {
                tableContent[j][i] = mainBuffer.get(i).get(j);
            }
        }
        table.setModel(new DefaultTableModel(tableContent, headerTitles));
        DefaultTableCellRenderer renderer = (DefaultTableCellRenderer) table.getTableHeader().getDefaultRenderer();
        renderer.setHorizontalAlignment(0);
        table.getTableHeader().setReorderingAllowed(false);
        ((DefaultTableModel) table.getModel()).addTableModelListener(tableModelListener);
    }
}
 
开发者ID:PanamaHitek,项目名称:PanamaHitek_Arduino,代码行数:24,代码来源:PanamaHitek_DataBuffer.java

示例4: updateRunsTableModel

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
/**
 * Updates the table model.
 */
public void updateRunsTableModel() {
	DataSheet dataSheet = this.mainWindow.getCurrentSession().getCurrentDataSheet();
	if (dataSheet != null) {
		DataSheetTableColumnModel cm = new DataSheetTableColumnModel(this.mainWindow, dataSheet);
		DefaultTableCellRenderer cellRenderer = new DefaultTableCellRenderer();
		cellRenderer.setHorizontalAlignment(SwingConstants.CENTER);
		TableColumn idCol = new TableColumn(0, 30, cellRenderer, new DefaultCellEditor(new JTextField()));
		idCol.setHeaderValue("#");
		idCol.setResizable(true);
		cm.addColumn(idCol);

		TableColumn[] cols = new TableColumn[dataSheet.getParameterCount() + 1];
		for (int colIndex = 1; colIndex <= dataSheet.getParameterCount(); colIndex++) {
			cols[colIndex] = new TableColumn(colIndex, 100, cellRenderer, new DefaultCellEditor(new JTextField()));
			cols[colIndex].setHeaderValue(dataSheet.getParameterName(colIndex - 1));
			cols[colIndex].setResizable(true);
			cm.addColumn(cols[colIndex]);
		}

		this.dataTable.setColumnModel(cm);
	}
}
 
开发者ID:enguerrand,项目名称:xdat,代码行数:26,代码来源:DataSheetTablePanel.java

示例5: createInformationModelIdListPane

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
/**
 * Create a pane that displays Information Model ID list.
 * 
 * @param portList Ports
 * @return The pane that displays Information Model ID list
 */
private JScrollPane createInformationModelIdListPane(List<Port> portList) {
  Collections.sort(portList, new PortComparator());

  Object[] columnNames = INFORMATION_MODEL_ID_COLNAME_LIST.toArray();
  DefaultTableModel tableModel = new DefaultTableModel(columnNames, 0);
  for (Port port : portList) {
    Port[] column = { port, port };
    tableModel.addRow(column);
  }

  JTable informationModeldTable = new JTable(tableModel);
  informationModeldTable.getTableHeader().setBackground(Color.WHITE);

  DefaultTableCellRenderer renderer = new InformationModelIdRenderer();
  renderer.setHorizontalAlignment(SwingConstants.CENTER);
  informationModeldTable.setDefaultRenderer(Object.class, renderer);

  JScrollPane informationModelIdPane = new JScrollPane();
  informationModelIdPane.getViewport().setView(informationModeldTable);
  informationModelIdPane.setPreferredSize(new Dimension(
      informationModelIdPane.getPreferredSize().width, TABLE_HEIGHT));

  return informationModelIdPane;
}
 
开发者ID:o3project,项目名称:dummyOptNode,代码行数:31,代码来源:NeFrame.java

示例6: setupColumns

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public static void setupColumns(JTable table) {
    for (int i = 0; i < table.getColumnCount(); i++) {
        DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
        TableColumn column = table.getColumnModel().getColumn(i);
        Class columnClass = table.getColumnClass(i);
        String columnName = table.getColumnName(i);
        renderer.setToolTipText(columnName);

        if (columnClass.getSuperclass().equals(Number.class)) {
            renderer.setHorizontalAlignment(DefaultTableCellRenderer.RIGHT);
        }

        if (table.isEnabled()) {
            if (columnName.equals("Currency")) {
                //addComboCell(column, Product.CURRENCIES);
            } else if (columnName.equals("Holidays")) {
                //column.setCellEditor(new FileChooserCellEditor());
            }
        }

        column.setCellRenderer(renderer);
    }
}
 
开发者ID:AnyObject,项目名称:OAT,代码行数:24,代码来源:UiUtil.java

示例7: lebarkolom

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的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);
    }
 
开发者ID:ahmadx,项目名称:Borneo-Bengkel,代码行数:25,代码来源:fKategori.java

示例8: lebarkolom

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的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);
}
 
开发者ID:ahmadx,项目名称:Borneo-Bengkel,代码行数:24,代码来源:fSatuan.java

示例9: setTableColumnWidths

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public void setTableColumnWidths()
{
  for( int j = 0; j < soloTableModel.getColumnCount(); j++ )
    {
      soloTable.getColumnModel().getColumn(j).
              setPreferredWidth(soloTableModel.getColumnWidths(j));
    }


  for( int j = 0; j < soloTableModel.getColumnCount(); j++ )
    {
      DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
      renderer.setHorizontalAlignment(soloTableModel.getColumnAdjustments(j));
      soloTable.getColumnModel().getColumn(j).setCellRenderer(renderer);
    }
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:17,代码来源:ThemeWeaver.java

示例10: setTableColumnWidths

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public void setTableColumnWidths()
{
  for( int j = 0; j < sectionTableModel.getColumnCount(); j++ )
    {
      sectionTable.getColumnModel().getColumn(j).
              setPreferredWidth(sectionTableModel.getColumnWidths(j));
    }

  DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();

  for( int j = 1; j < sectionTableModel.getColumnCount(); j++ )
    {
      renderer.setHorizontalAlignment(sectionTableModel.getColumnAdjustments(j));
      sectionTable.getColumnModel().getColumn(j).setCellRenderer(renderer);
    }
  //sectionTable.getColumnModel().getColumn(0).setCellRenderer( sectionCellRenderer );
}
 
开发者ID:Impro-Visor,项目名称:Impro-Visor,代码行数:18,代码来源:Notate.java

示例11: show

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public void show(int dif) {

			ArrayList<record> rec = new ArrayList<record>();

			String content = FileHelper.readFromFile("ranking.ini");
			if (content != null ) {
				if(!content.equals("")) {
					String[] sp = content.split(",");
					for (int i = 0; i < sp.length; i = i + 3) {
						if (dif == Integer.parseInt(sp[i])) {
							rec.add(new record(sp[i + 2], Integer.parseInt(sp[i + 1])));
						}
					}
				}
				Collections.sort(rec);
				rank = new Object[rec.size()][COL];
				for (int i = 0; i < rec.size(); i++) {
					record temp = rec.get(i);
					rank[i][0] = i + 1;
					rank[i][2] = temp.date;
					rank[i][1] = temp.score;
				}

				table = new JTable(rank, title);
				centerPanel.removeAll();
				centerPanel.setLayout(new BorderLayout());
				centerPanel.add(new JScrollPane(table), BorderLayout.CENTER);
				DefaultTableCellRenderer r = new DefaultTableCellRenderer();
				r.setHorizontalAlignment(JLabel.CENTER);
				table.setDefaultRenderer(Object.class, r);
				table.setRowHeight(20);
				table.setFont(new Font("微软雅黑", 0, 14));
				table.setGridColor(Color.BLUE);
				table.setSize(centerPanel.getWidth(), centerPanel.getHeight());
				table.setRowSelectionAllowed(false);

			}
			setVisible(true);
		}
 
开发者ID:zhangjikai,项目名称:LinkGame,代码行数:40,代码来源:Ranking.java

示例12: aplicarEstiloTabelas

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
private void aplicarEstiloTabelas(){
               
       /*Bloco de código responsável por centralizar as células */
       DefaultTableCellRenderer centralizado = new DefaultTableCellRenderer();
       centralizado.setHorizontalAlignment(SwingConstants.CENTER);
       
       gui.getTblRescisao().getColumnModel().getColumn(1).setCellRenderer(centralizado);
       gui.getTblRescisao().getColumnModel().getColumn(2).setCellRenderer(centralizado);
       gui.getTblFGTS().getColumnModel().getColumn(1).setCellRenderer(centralizado);
       /*Fim do bloco*/
	
}
 
开发者ID:tglima,项目名称:CRS,代码行数:13,代码来源:ControllerPrincipal.java

示例13: erzeugeMedienTable

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
/**
 * Erzeugt die Tabelle für die Anzeige der Medien.
 */
private void erzeugeMedienTable()
{
    JScrollPane medienAuflisterScrollPane = new JScrollPane();
    medienAuflisterScrollPane.setBorder(BorderFactory.createTitledBorder(
            null, "Medien", TitledBorder.LEADING,
            TitledBorder.DEFAULT_POSITION, UIConstants.HEADER_FONT));
    medienAuflisterScrollPane.setBackground(UIConstants.BACKGROUND_COLOR);
    medienAuflisterScrollPane.getVerticalScrollBar()
        .setBackground(UIConstants.BACKGROUND_COLOR);
    medienAuflisterScrollPane.getHorizontalScrollBar()
        .setBackground(UIConstants.BACKGROUND_COLOR);

    _ausleiheMedienTableModel = new AusleiheMedienTableModel();
    _medienTable = new JTable();
    medienAuflisterScrollPane.setViewportView(_medienTable);
    _medienTable.setModel(_ausleiheMedienTableModel);
    JTableHeader tableHeader = _medienTable.getTableHeader();
    tableHeader.setFont(UIConstants.HEADER_FONT);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(false);
    _medienTable.setFont(UIConstants.TEXT_FONT);
    // Text in der 3. Spalte mittig ausrichten
    DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
    renderer.setHorizontalAlignment(JLabel.CENTER);
    String columnName = _medienTable.getColumnName(2);
    TableColumn column = _medienTable.getColumn(columnName);
    column.setCellRenderer(renderer);

    _hauptPanel.add(medienAuflisterScrollPane, BorderLayout.CENTER);
}
 
开发者ID:polemonium,项目名称:SE2Project,代码行数:34,代码来源:AusleiheMedienauflisterUI.java

示例14: initialiseRenderer

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
private void initialiseRenderer(int modelColumnIndex, Color color) {
 if (modelColumnIndex < 0) {
     return;
 }

 int viewColumnIndex = table.convertColumnIndexToView(modelColumnIndex);
 DefaultTableCellRenderer renderer = new DefaultTableCellRenderer();
 renderer.setHorizontalAlignment(JLabel.CENTER);
 if (color != null) {
     renderer.setForeground(color);
 }
 table.getColumnModel().getColumn(viewColumnIndex).setCellRenderer(renderer);;
}
 
开发者ID:kddart,项目名称:kdxplore,代码行数:14,代码来源:AddTraitsDialog.java

示例15: renderTableData

import javax.swing.table.DefaultTableCellRenderer; //导入方法依赖的package包/类
public void renderTableData(Vector<Vector<Object>> data, Vector<Object> columns) {
    model = new DefaultTableModel(data, columns);
    dataTable.setModel(model);
    DefaultTableCellRenderer r = new DefaultTableCellRenderer();
    r.setHorizontalAlignment(JLabel.CENTER);
    // setDefaultRenderer(Object.class, r);
}
 
开发者ID:yisin2015,项目名称:codefactory,代码行数:8,代码来源:TableDataPanel.java


注:本文中的javax.swing.table.DefaultTableCellRenderer.setHorizontalAlignment方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。