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
|
@SuppressWarnings("serial")
public class MainFrame extends JFrame {
public MainFrame() {
// setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// Code
Dimension dimension = java.awt.Toolkit.getDefaultToolkit()
.getScreenSize();
int height = (int) dimension.getHeight();
int width = (int) dimension.getWidth();
setBounds(-10, 0, width, height);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
contentPane.setLayout(new BorderLayout(0, 0));
setContentPane(contentPane);
con.connection();
ArrayList<Manga> mangaList = con.getAllMangas();
con.close();
model = new Affichage(mangaList);
table = new JTable();
table.setModel(model);
contentPane.add(new JScrollPane(table), BorderLayout.CENTER);
JPanel boutons = new JPanel();
boutons.add(new JButton(new AddAction()));
boutons.add(new JButton(new RemoveAction()));
getContentPane().add(boutons, BorderLayout.WEST);
this.setVisible(true);
}
private class AddAction extends AbstractAction {
private AddAction() {
super("Ajouter");
}
@SuppressWarnings("static-access")
public void actionPerformed(ActionEvent e) {
System.out.println("Test appel booleen");
appel = true;
new Formulaire();
/* model.addManga(new Manga(titre, genre, auteur, dernierChap,
dateDernierChap, dernierChapLu, dateDerniereLecture, statut));
*/
}
}
public void recupInfo(String titre, String genre, String auteur,
String dernierChap, String dateDernierChap,
double dernierChapLu, String dateDerniereLecture, String statut){
model.addManga(new Manga(titre, genre, auteur, dernierChap,
dateDernierChap, dernierChapLu, dateDerniereLecture, statut));
}
/*
public void traitement(){
String[] valeur= con.lectureInfosTableau().split(";");
String d=null;
for (int i = 0; i < valeur.length; i++) {
titre=valeur[0];
genre=valeur[1];
auteur=valeur[2];
dernierChap=valeur[3];
dateDernierChap=valeur[4];
d=valeur[5];
dateDerniereLecture=valeur[6];
statut=valeur[7];
}
dernierChapLu = Double.parseDouble(d);
}
*/
private class RemoveAction extends AbstractAction {
private RemoveAction() {
super("Supprimmer");
}
@SuppressWarnings("static-access")
public void actionPerformed(ActionEvent e) {
int[] selection = table.getSelectedRows();
int ligne = table.getSelectedRow();// recupere le numero de la ligne
// selectionner
int colonne = 0;// recuperela 1ere collonne de la ligne selectionner
Object cellule = table.getValueAt(ligne, colonne);
con.connection();
if (con.delManga(cellule.toString())) {
con.close();
for (int i = selection.length - 1; i >= 0; i--) {
model.deleteMangaAt(selection[i]);
}
}
}
}
public static boolean appelTableau() {
return appel;
}
} |
Partager