本文整理汇总了Java中javax.swing.table.DefaultTableModel.setValueAt方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultTableModel.setValueAt方法的具体用法?Java DefaultTableModel.setValueAt怎么用?Java DefaultTableModel.setValueAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.table.DefaultTableModel
的用法示例。
在下文中一共展示了DefaultTableModel.setValueAt方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: renameDomainInComponents
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
/**
* Rename domain in components.
*
* @param oldDomainName the old domain name
* @param newDomainName the new domain name
*/
public void renameDomainInComponents(String oldDomainName, String newDomainName) {
DefaultTableModel dtmComponents = this.getTableModel4ComponentTypes();
int column = getColumnHeaderIndexComponents(COL_Domain);
// --- Get the component type definitions from table ----
JTable jtComponents = this.getJTable4ComponentTypes();
// --- Confirm, apply changes in table ------------------
TableCellEditor tceComponents = jtComponents.getCellEditor();
if (tceComponents!=null) {
tceComponents.stopCellEditing();
}
for(int row=0; row<dtmComponents.getRowCount(); row++){
String currValue = (String) dtmComponents.getValueAt(row, column);
if (currValue.equals(oldDomainName)) {
dtmComponents.setValueAt(newDomainName, row, column);
}
}
this.setTableCellEditor4DomainsInComponents(null);
}
示例2: jButton3ActionPerformed
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
MaskValue();
SLOT = jComboBox1.getSelectedIndex();
DefaultTableModel model = (DefaultTableModel)SlotTable.getModel();
String icb1 = String.valueOf(Input1.getSelectedItem());
String icb2 = String.valueOf(Input2.getSelectedItem());
String icb3 = icb1 + " + " + icb2;
String ocb1 = String.valueOf(Output1.getSelectedItem());
String ocb2 = String.valueOf(Output2.getSelectedItem());
String ocb3 = ocb1 + " + " + ocb2;
model.setValueAt(icb3,SLOT,1);
model.setValueAt(ocb3,SLOT,2);
}
示例3: initCurrentThread
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
/**
* 初始化当前线程
*/
public void initCurrentThread() {
PushManage.console(new StringBuffer().append("线程").append(this.getName()).append("负责处理:").append(pageFrom).append("-")
.append(pageTo).append("页的数据").toString());
int end = pageTo * pageSize + pageSize;
if (PushData.totalRecords < end) {
end = (int) PushData.totalRecords;
}
int start = pageFrom * pageSize;
list = PushData.toSendList.subList(start, end);
// 初始化线程列表行
tableModel = (DefaultTableModel) MainWindow.mainWindow.getPushThreadTable().getModel();
tableRow = Integer.parseInt(Thread.currentThread().getName().substring(2));
currentThreadSuccessCount = 0;
currentThreadFailCount = 0;
tableModel.setValueAt(currentThreadSuccessCount, tableRow, 2);
tableModel.setValueAt(currentThreadFailCount, tableRow, 3);
tableModel.setValueAt(list.size(), tableRow, 4);
tableModel.setValueAt(0, tableRow, 5);
}
示例4: filtersCheckAllButtonActionPerformed
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void filtersCheckAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filtersCheckAllButtonActionPerformed
DefaultTableModel model = (DefaultTableModel) filterClassesTable.getModel();
for (int i = 0; i < model.getRowCount(); i++) {
model.setValueAt(Boolean.TRUE, i, 0);
}
filterClassesTable.repaint();
}
示例5: filtersUncheckAllButtonActionPerformed
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void filtersUncheckAllButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filtersUncheckAllButtonActionPerformed
DefaultTableModel model = (DefaultTableModel) filterClassesTable.getModel();
for (int i = 0; i < model.getRowCount(); i++) {
model.setValueAt(Boolean.FALSE, i, 0);
}
filterClassesTable.repaint();
}
示例6: reset
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void reset(List<AnnotationExpression> exps) {
getSelectionModel().setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
DefaultTableModel model = getModel();
model.setColumnCount(2);
model.setRowCount(exps.size());
int r = -1;
for (Iterator<AnnotationExpression> it = exps.iterator(); it.hasNext();) {
AnnotationExpression annotationExpression = it.next();
r++;
model.setValueAt(annotationExpression.getUrlExp(), r, 0);
model.setValueAt(annotationExpression.getAnnotationExp(), r, 1);
}
}
示例7: updateSetterNames
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void updateSetterNames(String prefix) {
DefaultTableModel model = (DefaultTableModel) paramTable.getModel();
for (int k = 0;k < parameterNames.size();k ++) {
if (prefix == null || prefix.isEmpty()) {
model.setValueAt(parameterNames.get(k),k,1);
} else {
model.setValueAt(prefix + Character.toUpperCase(parameterNames.get(k).charAt(0))
+ parameterNames.get(k).substring(1),k,1);
}
}
}
示例8: createModel
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private DefaultTableModel createModel( Collection<String> patterns ) {
DefaultTableModel model = new DefaultTableModel(
new Object[] { NbBundle.getMessage( ToDoCustomizer.class, "ToDoCustomizer.TableHeader" ) }, patterns.size() ); //NOI18N
int row = 0;
for( String p : patterns ) {
model.setValueAt( p, row++, 0 );
}
return model;
}
示例9: PanneauCalendrier
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public PanneauCalendrier(Projet projet){
//Affichage de la fenêtre
this.setSize(1500, 800);
this.setLayout(new BorderLayout());
this.setVisible(true);
//Cadre
label = new JLabel();
label.setHorizontalAlignment(SwingConstants.CENTER);
JPanel panel = new JPanel();
panel.setLayout(new BorderLayout());
//Taille du tableau (lignes, colonnes)
//TODO Modifier le nombre de colonnes en fonction de la durée du projet
model = new DefaultTableModel(projet.getLotList().size(),0);
model.addColumn("Lots");
//Ajout des dates dans le tableau
for(String item :projet.getCalendar().getDatesBetween()){
model.addColumn(item);
}
//Ajouter les lignes des lots ordonnés
for (int k = 0; k < projet.getLotList().size(); k++){
//model.addRow(row);
//model.setValueAt(projet.getLotList().get(k).getName(), k, 0);
}
//Colorier les cases du tableau pendant la durée d'un lot
ArrayList<String> projectDuration = projet.getCalendar().getDatesBetween();
ArrayList<String> lotDuration;
String value = "1";
for (int h = 0; h < projet.getLotList().size(); h++){
lotDuration = projet.getLotList().get(h).getDatesBetween();
for (int i = 0; i < projectDuration.size(); i++){
for (int j = 0; j < lotDuration.size(); j++){
if (projectDuration.get(i) == lotDuration.get(j)){
model.setValueAt(value, h, i+1);
}
}
}
}
//Création du tableau
JTable table = new JTable(model);
//Disable réduction des colonnes
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
//Barre de défilements
JScrollPane pane = new JScrollPane(table);
this.add(panel, BorderLayout.NORTH);
this.add(pane, BorderLayout.CENTER);
}
示例10: firstComeFirstServe
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
protected void firstComeFirstServe(ArrayList<Processus> file, executionFrame frame) {
int currentTime = 0;
int numberOfProcess = file.size();
ArrayList<Processus> waitingList = new ArrayList<>();
DefaultTableModel processingModel = (DefaultTableModel) frame.processingTable.getModel();
while (numberOfProcess > 0) {
System.out.println("current time: " + currentTime);
System.out.println("process filling phase:");
for (int i = 0; i < file.size(); i++) {
//if the processus are arriving
if (file.get(i).getArriveTime() <= currentTime && !file.get(i).isPassed()) {
waitingList.add(file.get(i));
file.get(i).setPassed(true);
processingModel.setValueAt("" + currentTime, i, 1);
}
}
System.out.println();
System.out.println("process working phase:");
if (waitingList.size() > 0) {
System.out.println("processus " + waitingList.get(0).getName() + " is being processed");
currentTime += waitingList.get(0).getCpuTime();
waitingList.get(0).processing(waitingList.get(0).getCpuTime());
System.out.println("processus " + waitingList.get(0).getName() + " left the system");
int indexOfProcessLeaving = 0;
while (waitingList.get(0).getName() != file.get(indexOfProcessLeaving).getName()) {
++indexOfProcessLeaving;
}
processingModel.setValueAt("" + currentTime, indexOfProcessLeaving, 2);
file.get(0).setExitTime(currentTime);
waitingList.remove(0);
--numberOfProcess;
} else {
System.out.println("no Processus are waiting");
++currentTime;
}
System.out.println();
if (file.size() > 0) {
System.out.println("remaining processes: ");
boolean check = false;
for (int i = 0; i < file.size(); i++) {
if (!file.get(i).isPassed()) {
System.out.println("Processus " + file.get(i).getName());
check = true;
}
}
if (!check) {
System.out.println("No Proceses remained");
}
}
System.out.println();
frame.repaint();
}
//temps que la list des processus n est pas vide (il y a des processus dans le tableau
}
示例11: roundRobinNonPreemptif
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
protected void roundRobinNonPreemptif(ArrayList<Processus> file, int quantum, executionFrame frame) {
int currentTime = 0;
int numberOfProcess = file.size();
ArrayList<Processus> waitingList = new ArrayList<>();
DefaultTableModel processingModel = (DefaultTableModel) frame.processingTable.getModel();
while (numberOfProcess > 0) {
System.out.println("current time: " + currentTime);
System.out.println();
System.out.println("process filling phase:");
for (int i = 0; i < file.size(); i++) {
//if the processus are arriving
if (file.get(i).getArriveTime() <= currentTime && !file.get(i).isPassed()) {
System.out.println("the processus " + file.get(i).getName() + " was added to the waiting list");
waitingList.add(file.get(i));
file.get(i).setPassed(true);
processingModel.setValueAt("" + currentTime, i, 1);
}
}
System.out.println();
System.out.println("process working phase:");
if (waitingList.size() > 0) {
currentTime += quantum;
System.out.println("processus " + waitingList.get(0).getName() + " is being processed...");
waitingList.get(0).processing(quantum);
if (waitingList.get(0).getCpuTime() > 0) {
Processus p = waitingList.get(0);
//waitingList.add(waitingList.size() - 1, waitingList.get(0));
waitingList.remove(0);
waitingList.add(p);
System.out.println("processus " + waitingList.get(0).getName() + " is the head of the list");
System.out.println("processus " + waitingList.get(waitingList.size() - 1).getName() + " is the tail of the list");
} else {
System.out.println("processus " + waitingList.get(0).getName() + " has left the system");
--numberOfProcess;
int indexOfProcessLeaving = 0;
while (waitingList.get(0).getName() != file.get(indexOfProcessLeaving).getName()) {
++indexOfProcessLeaving;
}
processingModel.setValueAt("" + currentTime, indexOfProcessLeaving, 2);
file.get(0).setExitTime(currentTime);
waitingList.remove(0);
}
} else {
System.out.println("No processes available");
currentTime++;
}
//---------
System.out.println();
if (file.size() > 0) {
System.out.println("remaining processes: ");
boolean check = false;
for (int i = 0; i < file.size(); i++) {
if (!file.get(i).isPassed()) {
System.out.println("Processus " + file.get(i).getName());
check = true;
}
}
if (!check) {
System.out.println("No Proceses remained");
}
}
System.out.println();
}
}
示例12: WipeSlotActionPerformed
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
private void WipeSlotActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WipeSlotActionPerformed
int SLOT = jComboBox1.getSelectedIndex();
if (SLOT == 0)
{
I3a = 0;
O3a = 0;
I4a = null;
O4a = null;
}
if (SLOT == 1)
{
I3b = 0;
O3b = 0;
I4b = null;
O4b = null;
}
if (SLOT == 2)
{
I3c = 0;
O3c = 0;
I4c = null;
O4c = null;
}
if (SLOT == 3)
{
I3d = 0;
O3d = 0;
I4d = null;
O4d = null;
}
if (SLOT == 4)
{
I3e = 0;
O3e = 0;
I4e = null;
O4e = null;
}
if (SLOT == 5)
{
I3f = 0;
O3f = 0;
I4f = null;
O4f = null;
}
DefaultTableModel model = (DefaultTableModel)SlotTable.getModel();
model.setValueAt("None", SLOT, 1);
model.setValueAt("None", SLOT, 2);
}
示例13: populateMainTable
import javax.swing.table.DefaultTableModel; //导入方法依赖的package包/类
public void populateMainTable(DefaultTableModel model) {
model.setRowCount(0);
/*Simple object POJO class (entity)*/
Blockade blockade = null;
final Calendar c = Calendar.getInstance();
final SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
for (int colindex = 0; colindex < roomList.size(); colindex++) {
/////////////////////////////////////////////////////////////////
//here we created new 'Blockade' object special for this table //
//and we will use this object to move datas as desire //
blockade = new Blockade(); //
blockade.setNumber(roomList.get(colindex).getNumber()); //
blockade.setType(roomList.get(colindex).getType()); //
blockade.setStatus(roomList.get(colindex).getCleaningStatus());//
/////////////////////////////////////////////////////////////////
//populate first three columns with following informations
model.addRow(new Object[]{blockade.getNumber(), blockade.getType(), blockade.getStatus()});
////////////////////////////////////////////////////////////////////
//in this part of code we gonna use special date array 'weekDates'//
//that initialized up and populated table header as date, so after//
//checking the date we have to get that reservation is equals with//
//header date and finally populate the table. //
for (int listIndex = 0; listIndex < resList.size(); listIndex++) {
if (blockade.getNumber().equals(resList.get(listIndex).getRentedRoomNum())) {
for (int rowIndex = 3; rowIndex < weekDates.length; rowIndex++) {
try {
//convert all String type dates to real date type,
//we have to extract one day from checkout date because,
//it get dates that between checkin and checkout dates included
Date today = sdf.parse(weekDates[rowIndex]);
Date checkinDate = sdf.parse(resList.get(listIndex).getCheckinDate());
Date checkouDate = sdf.parse(resList.get(listIndex).getCheckoutDate());
c.setTime(checkouDate);
c.add(Calendar.DATE, -1);
if (checkinDate.compareTo(today) * today.compareTo(c.getTime()) >= 0) {
//populating table and sorting as dates
model.setValueAt(resList.get(listIndex).getGroupName(), colindex, rowIndex);
}
} catch (ParseException e) {
System.err.println("Holaaa"+e.getLocalizedMessage());
}
}
}
}
}
}