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


Java JTable.setModel方法代码示例

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


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

示例1: populatetable

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Loads the Data Array into the tmodel
 *
 * @param table to be populated
 * @param header column header
 * @param rows nullRoww data
 * @return populated tmodel
 */
public static JTable populatetable(JTable table, String[] header, List<String[]> rows) {
    removeRowSelection(table);
    DefaultTableModel tablemodel = (DefaultTableModel) table.getModel();
    tablemodel.setRowCount(0);
    for (String col : header) {
        tablemodel.addColumn(col);
    }
    for (String[] row : rows) {
        tablemodel.addRow(row);
    }
    table.setModel(tablemodel);
    return table;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:22,代码来源:JtableUtils.java

示例2: construtorPanelIndicador

import javax.swing.JTable; //导入方法依赖的package包/类
private void construtorPanelIndicador(){

		Object[] colunas = new String[]{"Pesquisa","Resultado"};

		Object[][] dados = new Object[][]{
		};

		model = new DefaultTableModel(dados , colunas ){
			public boolean isCellEditable(int row, int col){
				return false;
			}
		};
		tabela = new JTable();
		tabela.setModel(model);
		tabela.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		painelTabela = new JScrollPane();
		painelTabela.setViewportView(tabela);
		
		// busca e inserção dos resultados na tabela
		this.consultaIndicadores();
		
	}
 
开发者ID:matheusPeresDeAraujo,项目名称:20170612-NotaFIscalEletronica,代码行数:23,代码来源:FrameIndicadores.java

示例3: CourseListPanel

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Create the panel.
 */
public CourseListPanel(String user,ProfessorFrame pf) throws Exception{
	setLayout(new BorderLayout(0, 0));
       TableCellRenderer buttonRenderer = new ButtonRenderer();
	dao = new ProfessorDAO();
	model=new tableModelTeach(dao.getAllCourses(user),user,pf);
	table = new JTable();
	table.setRowHeight(30);
	
	table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	table.setDefaultRenderer(JButton.class,buttonRenderer);
	table.addMouseListener(new JTableButtonMouseListener(table));
	table.setModel(model);
	JScrollPane scrollPane = new JScrollPane(table,JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
	//resizeColumnWidth(table);
	table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
	TableColumnModel tcm = table.getColumnModel();
	tcm.getColumn(0).setPreferredWidth(800);    
	tcm.getColumn(1).setPreferredWidth(200);    
	
	scrollPane.setBounds(10, 57, 1320, 450);
	add(scrollPane, BorderLayout.CENTER);
}
 
开发者ID:jtatia,项目名称:Course-Management-System,代码行数:26,代码来源:CourseListPanel.java

示例4: deletecol

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Delete a single column from the table model
 *
 * @param table target table
 * @param col target column
 * @deprecated
 */
static void deletecol(JTable table, int col) {
    DefaultTableModel tmodel = (DefaultTableModel) table.getModel();
    DefaultTableModel tmodel1 = new DefaultTableModel();
    TableModelListener[] listeners = tmodel.getTableModelListeners();

    Vector<?> v = tmodel.getDataVector();
    Vector<?> v1 = newvector(v, col);
    tmodel1.setDataVector(v1, getColumnIdentifiersremovecol(table, col));
    table.setModel(tmodel1);
    for (TableModelListener l : listeners) {
        tmodel1.addTableModelListener(l);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:21,代码来源:JtableUtils.java

示例5: addcol

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Adding column is done by creating new model by modifying older one.<p>
 *
 * Insert new column if column is outside the <code>limit</code> Adds new
 * column if selected column inside the <code>limit</code>[email protected] _table
 * target table
 *
 * @param limit the range to avoid inserting
 */
static void addcol(JTable table, int limit) {
    try {
        int sc = table.getSelectedColumn();
        if (sc < limit - 1) {
            sc = table.getColumnCount() - 1;
        }

        DefaultTableModel tableM = (DefaultTableModel) table.getModel();
        DefaultTableModel tableM1 = new DefaultTableModel();
        TableModelListener[] listeners = tableM.getTableModelListeners();

        tableM1.setDataVector(newvectoraddcol(tableM.getDataVector(), sc), getColumnIdentifiersaddcol(sc + 1, table));
        table.setModel(tableM1);
        for (TableModelListener l : listeners) {
            tableM1.addTableModelListener(l);
        }

    } catch (Exception ex) {
        Logger.getLogger(JtableUtils.class.getName()).log(Level.SEVERE, null, ex);
    }

}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:32,代码来源:JtableUtils.java

示例6: construtorTabelaModel

import javax.swing.JTable; //导入方法依赖的package包/类
private void construtorTabelaModel(){
		
		Object[] colunas = new String[]{"Numero","Date Emissão","CNPJ/CPF","Razão Social/Nome","Quantidade de Itens","Valor Total"};

		Object[][] dados = new Object[][]{
//		       {"100", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"200", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"300", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"400", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"},
//		       {"500", "2017-06-13", "10388767618", "Matheus", "100", "1000.00"}
		};

		model = new DefaultTableModel(dados , colunas ){
			public boolean isCellEditable(int row, int col){
				return false;
			}
		};
		tabela = new JTable();
		tabela.setModel(model);
		tabela.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		painelTabela = new JScrollPane();
		painelTabela.setViewportView(tabela);
		
//		busca e inserção de notas fiscais do banco na tabela
		this.buscaNf();
		
	}
 
开发者ID:matheusPeresDeAraujo,项目名称:20170612-NotaFIscalEletronica,代码行数:28,代码来源:FrameInicial.java

示例7: erzeugeKundenTable

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

    _kundenTableModel = new KundenTableModel();
    _kundenTable = new JTable();
    kundenAuflisterScrollPane.setViewportView(_kundenTable);
    _kundenTable.setModel(_kundenTableModel);
    _kundenTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    JTableHeader tableHeader = _kundenTable.getTableHeader();
    tableHeader.setFont(UIConstants.HEADER_FONT);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(false);
    _kundenTable.setFont(UIConstants.TEXT_FONT);

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

示例8: erzeugeMedienTable

import javax.swing.JTable; //导入方法依赖的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);

    _medienTableModel = new VormerkMedienTableModel();
    _medienTable = new JTable();
    medienAuflisterScrollPane.setViewportView(_medienTable);
    _medienTable.setModel(_medienTableModel);
    JTableHeader tableHeader = _medienTable.getTableHeader();
    tableHeader.setFont(UIConstants.HEADER_FONT);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(false);
    _medienTable.setFont(UIConstants.TEXT_FONT);

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

示例9: erzeugeVerleihkartenauflister

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * Erzeuge das Tabellen-Panel, in dem die Verleihkarten angezeigt werden.
 */
private void erzeugeVerleihkartenauflister()
{
    JPanel verleihkartenAuflisterPanel = new JPanel();
    _hauptPanel.add(verleihkartenAuflisterPanel, BorderLayout.CENTER);
    verleihkartenAuflisterPanel.setLayout(new BorderLayout());
    verleihkartenAuflisterPanel
        .setPreferredSize(new java.awt.Dimension(-1, -1));
    verleihkartenAuflisterPanel.setSize(-1, -1);
    verleihkartenAuflisterPanel.setBackground(UIConstants.BACKGROUND_COLOR);

    JScrollPane verleihkartenAuflisterScrollPane = new JScrollPane();
    verleihkartenAuflisterPanel.add(verleihkartenAuflisterScrollPane,
            BorderLayout.CENTER);
    verleihkartenAuflisterScrollPane
        .setPreferredSize(new java.awt.Dimension(-1, -1));
    verleihkartenAuflisterScrollPane.setSize(-1, -1);
    verleihkartenAuflisterScrollPane.setBorder(BorderFactory
        .createTitledBorder(null, "Verleihkarten", TitledBorder.LEADING,
                TitledBorder.DEFAULT_POSITION, UIConstants.HEADER_FONT));
    verleihkartenAuflisterScrollPane
        .setBackground(UIConstants.BACKGROUND_COLOR);
    verleihkartenAuflisterScrollPane.getVerticalScrollBar()
        .setBackground(UIConstants.BACKGROUND_COLOR);
    verleihkartenAuflisterScrollPane.getHorizontalScrollBar()
        .setBackground(UIConstants.BACKGROUND_COLOR);

    _verleihkartenAuflisterTableModel = new VerleihkartenTableModel();
    _verleihkartenAuflisterTable = new JTable();
    verleihkartenAuflisterScrollPane
        .setViewportView(_verleihkartenAuflisterTable);
    _verleihkartenAuflisterTable
        .setModel(_verleihkartenAuflisterTableModel);
    JTableHeader tableHeader = _verleihkartenAuflisterTable
        .getTableHeader();
    tableHeader.setFont(UIConstants.HEADER_FONT);
    tableHeader.setReorderingAllowed(false);
    tableHeader.setResizingAllowed(false);
    _verleihkartenAuflisterTable.setFont(UIConstants.TEXT_FONT);
}
 
开发者ID:polemonium,项目名称:SE2Project,代码行数:43,代码来源:RueckgabeUI.java

示例10: iniciaJTable

import javax.swing.JTable; //导入方法依赖的package包/类
/**
* Método responsável por inicializar JTable
*
*/
private void iniciaJTable() {
	tableTransacoes = new JTable();
	tableTransacoes.setModel(new DefaultTableModel(new Object[][] {},
	retornaNomeColunas()));
	tableTransacoes.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	tableTransacoes.setBounds(703, 24, -690, 140);
	tableTransacoes.getTableHeader().setReorderingAllowed(false);
	panelTransacoes.setLayout(null);
	JScrollPane scrollPane = new JScrollPane(tableTransacoes);
	scrollPane.setViewportView(tableTransacoes);
	scrollPane.setBounds(10, 21, 691, 154);
	panelTransacoes.add(scrollPane);
}
 
开发者ID:alexferreiradev,项目名称:3way_laboratorios,代码行数:18,代码来源:OperacoesBanco.java

示例11: LoadData

import javax.swing.JTable; //导入方法依赖的package包/类
public static void LoadData (String sql,JTable tb) {
    try{
        ps = con.prepareStatement(sql);
        rs = ps.executeQuery();
        tb.setModel((DbUtils.resultSetToTableModel(rs)));
    }
    catch(Exception e) {
        JOptionPane.showMessageDialog(null, e ,"Thông báo lỗi",1);
    }
}
 
开发者ID:GroupKT,项目名称:GroupK,代码行数:11,代码来源:UPDATE.java

示例12: createMapping

import javax.swing.JTable; //导入方法依赖的package包/类
private JComponent createMapping()
{
	attributeModel = new AttributeTableModel();
	attributeTable = new JTable(attributeModel);

	attributeTable.setModel(attributeModel);
	attributeTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
	attributeTable.changeSelection(0, 0, false, true);

	return new JScrollPane(attributeTable);
}
 
开发者ID:equella,项目名称:Equella,代码行数:12,代码来源:LDAPMappingPanel.java

示例13: PhotoList

import javax.swing.JTable; //导入方法依赖的package包/类
public PhotoList(ZooracleContentPanel zooracleContentPanel)
	{

		this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
		this.zooracleContentPanel = zooracleContentPanel;
		// Set the frame characteristics
//		setSize(150, 600);
		setBackground(Color.gray);

		// Create a panel to hold all other components
		topPanel = new JPanel();
		topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));

		this.add(topPanel);


		// Create some data
//		String dataValues[][] = { { "12", "234", "67" }, { "-123", "43", "853" }, { "93", "89.2", "109" }, { "279", "9033", "3092" } };

		// Create a new table instance
		table = new JTable(null, columnNames);
//		table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);

//		table.setMinimumSize(new Dimension(150, 600));
//		table.setPreferredSize(new Dimension(150, 600));

		// table.setD
		selectionModel = new DefaultListSelectionModel();
		
		model = new DefaultTableModel();
		

		// table.setC
		selectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		selectionModel.addListSelectionListener(new ListSelectionListener()
		{

			public void valueChanged(ListSelectionEvent e)
			{
				int selectionIndex = table.getSelectedRow();
				if (lastSelectionIndex != selectionIndex)
				{
					
					lastSelectionIndex = selectionIndex;
					
					if (selectionIndex==-1)
						return;
					System.out.println(table.getValueAt(selectionIndex, 0));
					System.out.println("sele:" + selectionIndex);
					
					if (PhotoList.this.zooracleContentPanel instanceof ImportView)
					{
						((ImportView)(PhotoList.this.zooracleContentPanel)).setCurrentPhoto(selectionIndex);
					}
//					if (selectionIndex > 2)
//						PhotoList.this.maximize(false);
				}
			}
		});
		// table.setDefaultRenderer(Object.class, new EditedCellRenderer(this));
		table.setSelectionModel(selectionModel);
		table.setDefaultRenderer(String.class, new BoardTableCellRenderer());
		table.setDefaultRenderer(Object.class, new BoardTableCellRenderer());
		
		table.setModel(model);
//		table.setMaximumSize(new Dimension(100, 300));
		

		// Add the table to a scrolling pane
		scrollPane = new JScrollPane();
//		scrollPane.add(table.getTableHeader());
//		scrollPane.add(table);
//		topPanel.add(scrollPane);
		
		topPanel.add(table.getTableHeader());
		topPanel.add(new JScrollPane(table));
	}
 
开发者ID:fossasia,项目名称:zooracle,代码行数:78,代码来源:PhotoList.java

示例14: erzeugeMedienTable

import javax.swing.JTable; //导入方法依赖的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

示例15: connectClassNames

import javax.swing.JTable; //导入方法依赖的package包/类
public static void connectClassNames(JTable table, SelectedTables selectedTables) {
    table.setModel(new TableClassNamesModel(selectedTables));
    setRenderer(table.getColumnModel().getColumn(0));
    setRenderer(table.getColumnModel().getColumn(1));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:TableUISupport.java


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