1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
|
import graph.menuGestionArt.*;
import dev.Article;
import dev.Client;
import dev.Facture;
import dev.FamArticle;
import dev.G_Article;
import dev.G_FamArticle;
import dev.Societe;
import java.awt.Dimension;
import java.util.ArrayList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.AbstractTableModel;
public class ListeFactLibre extends JPanel {
//
private ModelListArt unMod;
private JTable table;
private JScrollPane scrollPane;
//
private Societe uneSoc;
private Facture uneFact;
public ListeFactLibre(Societe _uneSoc) {
uneSoc = _uneSoc;
init();
}
public ListeFactLibre(Societe _uneSoc, Facture _uneFact) {
uneSoc = _uneSoc;
init();
//Boucle pour afficher 15 ligne vide (à remplir par l'utilisateur par l'interface graphique)
for (int i = 0; i < 15; i++) {
unMod.addData("");
}
}
public void init() {
//Liste Facture
unMod = new ModelListArt();
table = new JTable(getUnMod());
table.setPreferredScrollableViewportSize(new Dimension(800, 400));
table.setFillsViewportHeight(true);
table.setAutoCreateRowSorter(true);
scrollPane = new JScrollPane(getTable());
add(scrollPane);
}
/**
* @return the unMod
*/
public ModelListArt getUnMod() {
return unMod;
}
/**
* @param unMod the unMod to set
*/
public void setUnMod(ModelListArt unMod) {
this.unMod = unMod;
}
/**
* @return the table
*/
public JTable getTable() {
return table;
}
/**
* @param table the table to set
*/
public void setTable(JTable table) {
this.table = table;
}
class ModelListArt extends AbstractTableModel {
private String[] columnNames = {"Quantité", "Type", "P.U", "Total"};
private ArrayList<String> data = new ArrayList<String>();
public int getColumnCount() {
return columnNames.length;
}
public void addData(String unString) {
data.add(unString);
}
public int getRowCount() {
return data.size();
}
public String getColumnName(int col) {
return columnNames[col];
}
public boolean isCellEditable(int row, int col) {
return true;
}
public Object getValueAt(int rowIndex, int columnIndex) {
if (columnIndex == 0) {
return data.get(rowIndex);
} else if (columnIndex == 1) {
return data.get(rowIndex);
} else if (columnIndex == 2) {
return data.get(rowIndex);
} else if (columnIndex == 3) {
return data.get(rowIndex);
} else {
return null;
}
}
}
} |
Partager