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


Java JTable.getValueAt方法代码示例

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


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

示例1: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    ProfilingPoint ppoint = (ProfilingPoint)value;
    if (ppoint == null && table != null) ppoint = (ProfilingPoint)table.getValueAt(row, column);
    if (ppoint == null) {
        setText(""); // NOI18N
        setEnabled(true);
    } else {
        setText("<table cellspacing='0' cellpadding='0'><tr><td height='" + // NOI18N
                table.getRowHeight() + "' valign='middle'><nobr>&nbsp;" + // NOI18N
                ppoint.getResultsText() + "&nbsp;</nobr></td></tr></table>"); // NOI18N
        setEnabled(ppoint.isEnabled());
    }
    lastTable = new WeakReference(table);
    lastProfilingPoint = new WeakReference(ppoint);
    return this;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:ProfilingPoint.java

示例2: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public Component getTableCellRendererComponent(JTable table,
    Object value, boolean isSelected, boolean hasFocus,
    int row, int column) {
    Player player = (Player)value;
    if (player == null) {
        NationType nationType
            = (NationType)table.getValueAt(row, ADVANTAGE_COLUMN);
        if (nationType instanceof EuropeanNationType) {
            NationState nationState = (NationState)table
                .getValueAt(row, AVAILABILITY_COLUMN);
            if (nationState == NationState.AVAILABLE) {
                return button;
            }
        }
        Nation nation = (Nation) table.getValueAt(row, NATION_COLUMN);
        label.setText(nation.getRulerName());
    } else {
        label.setText(player.getName());
    }
    return label;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:26,代码来源:PlayersTable.java

示例3: mouseClicked

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    JTable table = (JTable) e.getSource();
    Point pt = e.getPoint();
    int ccol = table.columnAtPoint(pt);
    int crow = table.rowAtPoint(pt);
    Object value = table.getValueAt(crow, ccol);
    if (value instanceof URL) {
        URL url = (URL) value;
        Desktop desktop = null;
        try {
            if (Desktop.isDesktopSupported()) {
                desktop = Desktop.getDesktop();
            }
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
        if (desktop != null) {
            try {
                desktop.browse(url.toURI());
            } catch (Exception exc) {
                // browsing failed; just don't do anything
            }
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:27,代码来源:LibrariesTable.java

示例4: storeTableData

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
protected void storeTableData(final JTable table, final String optionID, final Preferences node) {
    StringBuilder sb = null;
    for (int i = 0; i < table.getRowCount(); i++) {
        if (sb == null) {
            sb = new StringBuilder();
        } else {
            sb.append(';');
        }
        for (int j = 0; j < table.getColumnCount(); j++) {
            if (Boolean.class.equals(table.getColumnClass(j))) {
                if (((Boolean)table.getValueAt(i, j)).booleanValue())
                    sb.append(j == 0 ? "static " : ".*"); //NOI18N
            } else {
                Object val = table.getValueAt(i, j);
                sb.append(allOtherImports == val ? "*" : val); //NOI18N
            }
        }
    }
    String value = sb != null ? sb.toString() : ""; //NOI18N
    if (getDefaultAsString(optionID).equals(value))
        node.remove(optionID);
    else
        node.put(optionID, value);            
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:FmtImports.java

示例5: actionPerformed

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    String action = e.getActionCommand();
    if (action.equals(Vars.PROP_NEW)) {
        CidadesCadastro cidadeCadastro = new CidadesCadastro(cidades);
        cidades.getPainel().getDesktopPane().add(cidadeCadastro);
        cidadeCadastro.setVisible(true);
        cidadeCadastro.toFront();
        cidadeCadastro.setLocation((cidades.getPainel().getWidth() - cidadeCadastro.getWidth()) / 2, (cidades.getPainel().getHeight() - cidadeCadastro.getHeight()) / 2);
        cidades.addChild(cidadeCadastro);

    } else if (action.equals(Vars.PROP_REMOVE)) {
        JTable tabela = cidades.getTable();
        int nome = (int) tabela.getValueAt(tabela.getSelectedRow(), 0);
        br.com.secharpe.dao.CidadeDAO cidDAO = new br.com.secharpe.dao.CidadeDAO();
        cidDAO.delete(nome);
        cidades.refreshTable();
    } else if (action.equals(Vars.PROP_CLOSE)) {
        cidades.dispose();
    }
}
 
开发者ID:luandr,项目名称:ProjetoERP,代码行数:22,代码来源:CidadesViewActionListener.java

示例6: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
public Component getTableCellRendererComponent(JTable table, Object value,
		boolean isSelected, boolean hasFocus, int row, int column) {
	JLabel l = (JLabel) renderer.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
	boolean plotable;
	if (value != null && value instanceof String) {
		try {
			int plotColumn = ((XBTable) table).getPlotColumnIndex();
			 plotable = (boolean) table.getValueAt(row, plotColumn);
		} catch(Exception e) {
			plotable = true;
		}
		if (validURL((String)value) && plotable) {
			l.setText("<html><u><font color=\"blue\">" + l.getText() + "</font></u></html>");
		} else {
			l.setForeground(Color.BLACK);
		}
	}
	return l;
}
 
开发者ID:iedadata,项目名称:geomapapp,代码行数:20,代码来源:HyperlinkTableRenderer.java

示例7: getColorByRow

import javax.swing.JTable; //导入方法依赖的package包/类
private Color getColorByRow(JTable table, int row) {
	int colorIndex = 0;
	// default color
	if (!(table.getValueAt(0, Brain.CONDITION_OBJECT_COLUMN) instanceof PlayerWorldObject)) {
		return Color.red;
	}
	PlayerWorldObject lastRowObj = (PlayerWorldObject) table.getValueAt(0,
			Brain.CONDITION_OBJECT_COLUMN);
	// get colors of all previous rows to determine new color
	for (int curRow = 0; curRow <= row; curRow++) {
		if (table.getValueAt(curRow, Brain.CONDITION_OBJECT_COLUMN) instanceof PlayerWorldObject) {
			PlayerWorldObject curRowObj = (PlayerWorldObject) table
					.getValueAt(curRow, Brain.CONDITION_OBJECT_COLUMN);
			// compare previous object to current
			if (lastRowObj == curRowObj) {
				// color as before
			} else {
				// choose next color
				colorIndex = (colorIndex + 1) % this.colors.length;
			}
			lastRowObj = curRowObj;
		}

	}
	return this.colors[colorIndex];
}
 
开发者ID:CognitiveModeling,项目名称:BrainControl,代码行数:27,代码来源:BrainTableRenderer.java

示例8: getTableCellRendererComponent

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus,
		int row, int column) {
	// TODO Auto-generated method stub
	final Component cellComponent =  super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
	
	String rowColVal = (String) table.getValueAt(row, 10);
	
	if(isSelected || hasFocus) {
		
		cellComponent.setBackground(Color.decode("#10d6d1"));
	}
	else if(rowColVal.equalsIgnoreCase("Cancelled")) {
		
		cellComponent.setBackground(Color.decode("#d62a41"));
	}
	else {
		
		cellComponent.setBackground(row % 2 == 0 ? table.getSelectionBackground() : table.getBackground());
	}
	
	return cellComponent;
}
 
开发者ID:Coder-ACJHP,项目名称:Hotel-Properties-Management-System,代码行数:24,代码来源:AllreservationRenderer.java

示例9: mouseClicked

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public void mouseClicked(MouseEvent e) {
    JTable table = (JTable) e.getSource();
    Point pt = e.getPoint();
    int ccol = table.columnAtPoint(pt);
    int crow = table.rowAtPoint(pt);
    Object value = table.getValueAt(crow, ccol);
    if (value instanceof URL) {
        URL url = (URL) value;
        try {
            if (Desktop.isDesktopSupported()) {
                Desktop.getDesktop().browse(url.toURI());
            }
        } catch (Exception ex) {
            throw new IllegalStateException(ex);
        }
    }
}
 
开发者ID:meteoorkip,项目名称:JavaGraph,代码行数:19,代码来源:ContributorsTable.java

示例10: createTransferable

import javax.swing.JTable; //导入方法依赖的package包/类
/******* Export Side *******/

	/* Create data from the selected rows and columns */
	@Override
	protected Transferable createTransferable(JComponent c)
	{
		JTable table = (JTable)c;
		rowsidx = table.getSelectedRows();
		colsidx = table.getSelectedColumns();

		Run store[][] = new Run[rowsidx.length][colsidx.length];
		for (int ii = 0; ii < rowsidx.length; ii++)
			for (int jj = 0; jj < colsidx.length; jj++)
				store[ii][jj] = (Run)table.getValueAt(rowsidx[ii], colsidx[jj]);

		return new SimpleDataTransfer(flavor, store);
	}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:18,代码来源:RunsTable.java

示例11: rightClick

import javax.swing.JTable; //导入方法依赖的package包/类
public void rightClick(JTable jtable, java.awt.event.MouseEvent evt ){
    try {
        impostaMenu();
    } catch (SQLException ex) {
        Logger.getLogger(GuiPrincipale.class.getName()).log(Level.SEVERE, null, ex);
    }
    if(SwingUtilities.isRightMouseButton(evt)){
        
      int[] coordinate = coordinateMouse(jtable);
      
       jMenuPrincipale.show(this, coordinate[0]+evt.getX(), coordinate[1]+evt.getY());
    }
    try{
        int i = jtable.getSelectedRow();        
        id = Integer.parseInt(jtable.getValueAt(i, 2).toString());
        nomePrenotazione = (String) jtable.getValueAt(i, 0);
    }catch(ArrayIndexOutOfBoundsException s){}
}
 
开发者ID:IngSW-unipv,项目名称:Progetto-N,代码行数:19,代码来源:GuiPrincipale.java

示例12: getTableData

import javax.swing.JTable; //导入方法依赖的package包/类
private List<HashMap<String, String>> getTableData(JTable table, String moduleId) {
    List<HashMap<String, String>> data = new ArrayList<>();
    HashMap<String, String> row;
    JtableUtils.removeEmptyRows(table);
    int colCount = table.getColumnCount(),
            rowCount = table.getRowCount(), i;

    for (i = 0; i < rowCount; i++) {
        row = new HashMap<>();
        row.put("moduleId", moduleId);
        for (int j = 0; j < colCount; j++) {
            Object val = table.getValueAt(i, j);
            row.put(column[j], (val == null) ? "" : val.toString());
        }
        data.add(row);
    }
    return data;
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:19,代码来源:SettingsUI.java

示例13: getTableCellEditorComponent

import javax.swing.JTable; //导入方法依赖的package包/类
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    if (table.getValueAt(row, 0) instanceof Library) {
        cb.setRenderer(library);
        cb.setModel(new DefaultComboBoxModel(comboValues));
    } else {
        cb.setRenderer(jar);
        cb.setModel(new DefaultComboBoxModel(comboValuesJar));
    }
    super.getTableCellEditorComponent(table, value, isSelected, row, column);
    return cb;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:MakeSharableVisualPanel2.java

示例14: showPopupMenu

import javax.swing.JTable; //导入方法依赖的package包/类
private boolean showPopupMenu(int row, int col, int x, int y) {
    JTable table = actionsTable;
    
    if (col != 1) {
        return false;
    }
    
    Object valueAt = table.getValueAt(row, col);
    ShortcutCellPanel scCell = (ShortcutCellPanel) table.getCellRenderer(row, col).getTableCellRendererComponent(table, valueAt, true, true, row, col);
    Rectangle cellRect = table.getCellRect(row, col, false);
    JButton button = scCell.getButton();
    if (x < 0  || x > (cellRect.x + cellRect.width - button.getWidth())) { //inside changeButton
        boolean isShortcutSet = scCell.getTextField().getText().length() != 0;
        final ShortcutPopupPanel panel = (ShortcutPopupPanel) popup.getComponents()[0];
        panel.setDisplayAddAlternative(isShortcutSet);
        panel.setRow(row);

        if (x == -1 || y == -1) {
            x = button.getX() + 1;
            y = button.getY() + 1;
        }
        panel.setCustomProfile(keymapModel.getMutableModel().isCustomProfile(keymapModel.getMutableModel().getCurrentProfile()));
        popup.show(table, x, y);
        SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                panel.requestFocus();
            }
        });
        popup.requestFocus();
        return true;
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:KeymapPanel.java

示例15: createTransferable

import javax.swing.JTable; //导入方法依赖的package包/类
/******* Export Side *******/

	/* Create data from the selected rows */
	@Override
	protected Transferable createTransferable(JComponent c)
	{
		JTable table = (JTable)c;
		rowsidx = table.getSelectedRows();

		Entrant store[] = new Entrant[rowsidx.length];
		for (int ii = 0; ii < rowsidx.length; ii++)
			store[ii] = (Entrant)table.getValueAt(rowsidx[ii], 0);

		return new SimpleDataTransfer(flavor, store);
	}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:16,代码来源:DriverTable.java


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