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 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226
|
package royaldivx;
import java.awt.*;
import java.sql.*;
import java.sql.SQLException;
import javax.swing.*;
import java.awt.event.*;
import java.awt.event.ActionListener ;
/**
*
*
*/
public class FenetreAjout extends JFrame implements ActionListener{
//Déclaration générale
private JPanel monPanel = new JPanel();
private GridBagConstraints gbc = new GridBagConstraints();
//Déclaration des JLabel
private JLabel label_bienvenue = new JLabel("<html><b><font color='black'>ROYAL DIVX: Veuillez complèter les informations ci-dessous !</font></b><html>");
private JLabel titre_film = new JLabel("<html><u><font color='black'>Titre du film:</font></u></html>");
private JLabel duree_film = new JLabel("<html><u><font color='black'>Durée:</font></u></html>");
private JLabel synopsis = new JLabel ("<html><u><font color='black'>Synopsis:</font></u></html>");
private JLabel annee_film = new JLabel("<html><u><font color='black'>Année:</font></u></html>");
private JLabel genre_film = new JLabel("<html><u><font color='black'>Genre:</font></u></html>");
private JLabel realisateur_film = new JLabel("<html><u><font color='black'>Réalisateur:</font></u></html>");
private JLabel acteur_film = new JLabel("<html><u><font color='black'>Acteur Principal:</font></u></html>");
private JLabel origine_film = new JLabel("<html><u><font color='black'>Origine:</font></u></html>");
//Déclaration des JTextField
private JTextField titreField = new JTextField();
//Déclaration JFormattedTextField pour la Durée
private JFormattedTextField dureeField2 = new JFormattedTextField();
//Déclaration du JTextArea
private JTextArea synopsisArea = new JTextArea(5,30);
//Déclaration du JScrollPane
private JScrollPane scrollPane = new JScrollPane(synopsisArea);
//Déclaration des JComboBox
private JComboBox anneeCombo = new JComboBox();
private JComboBox genreCombo = new JComboBox();
private JComboBox realisateurCombo = new JComboBox();
private JComboBox acteurCombo = new JComboBox();
private JComboBox origineCombo = new JComboBox();
//Déclaration des JButton
private JButton validerBouton = new JButton("VALIDER");
private JButton annulerBouton = new JButton("ANNULER");
//*************************************************************************
//Connexion à la base de données
//*************************************************************************
Connection con= Connexion.getConnection();
String req1 = "SELECT LIBELLE_GENRE FROM ROYALDIVX.GENRES ORDER BY LIBELLE_GENRE";
Statement stmt;
try {
stmt = con.createStatement();
ResultSet res = stmt.executeQuery(req1);
while (res.next()){
genreCombo.addItem(res.getString("Genre")) ;
}
res.close();
}
catch (SQLException e){
e.printStackTrace();
}
//*************************************************************************
//**************************************************************************
public FenetreAjout(){
super();
build3();
annulerBouton.addActionListener(this);
this.setVisible(true);
}
//**************************************************************************
//*************************************************************************
private void build3(){
setTitle("Royal Div'x : Ajouter un film");
setSize(600,500);
setLocationRelativeTo(null);
setResizable(false);
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
//On définit le Grid
monPanel.setLayout(new GridBagLayout());
//On place les label
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets (10,10,10,10);
gbc.gridx = 1;
gbc.gridy = 4;
monPanel.add(label_bienvenue,gbc);
gbc.gridx = 0;
gbc.gridy = 6;
gbc.gridwidth = 1;
monPanel.add(titre_film,gbc);
gbc.gridx = 0;
gbc.gridy = 7;
monPanel.add(duree_film,gbc);
gbc.gridx = 0;
gbc.gridy = 8;
monPanel.add(synopsis,gbc);
gbc.gridx = 0;
gbc.gridy = 9;
monPanel.add(annee_film,gbc);
gbc.gridx = 0;
gbc.gridy = 10;
monPanel.add(genre_film,gbc);
gbc.gridx = 0;
gbc.gridy = 11;
monPanel.add(realisateur_film,gbc);
gbc.gridx = 0;
gbc.gridy = 12;
monPanel.add(acteur_film,gbc);
gbc.gridx = 0;
gbc.gridy = 13;
monPanel.add(origine_film,gbc);
//On place les JTextFied
gbc.gridx = 1;
gbc.gridy = 6;
gbc.weightx=50;
gbc.gridwidth = 1;
monPanel.add(titreField,gbc); //Titre
gbc.gridx = 1;
gbc.gridy = 7;
monPanel.add(dureeField2,gbc); //Durée en min
gbc.gridx = 1;
gbc.gridy = 8;
monPanel.add(scrollPane,gbc); //Zone de texte pour le synopsis, je récup le
//scrollPane qui lui meme récup mon JTextArea synopsisArea
//On place les JComboBox
gbc.gridx = 1;
gbc.gridy = 9;
monPanel.add(anneeCombo,gbc); //Annee
gbc.gridx = 1;
gbc.gridy = 10;
monPanel.add(genreCombo,gbc); //Genre
gbc.gridx = 1;
gbc.gridy = 11;
monPanel.add(realisateurCombo,gbc); //Réalisateur
gbc.gridx = 1;
gbc.gridy = 12;
monPanel.add(acteurCombo,gbc); //Acteur Principal
gbc.gridx = 1;
gbc.gridy = 13;
monPanel.add(origineCombo,gbc); //Origine
//On place les JButton
gbc.gridx = 2;
gbc.gridy = 12;
gbc.gridwidth = GridBagConstraints.REMAINDER;
monPanel.add(validerBouton,gbc);
gbc.gridx = 2;
gbc.gridy = 13;
gbc.gridwidth = GridBagConstraints.REMAINDER;
monPanel.add(annulerBouton,gbc);
// On attache monPanel
add(monPanel);
monPanel.setBackground(Color.LIGHT_GRAY); //couleur d'arriere plan
}
//************************************************************************
public void actionPerformed (ActionEvent e) {
if (e.getSource() == annulerBouton){
int reponse = JOptionPane.showConfirmDialog(this,"Etes-vous sûr de vouloir annuler l'insertion?",
"Royal Div'x", JOptionPane.YES_NO_OPTION);
if (reponse == JOptionPane.YES_OPTION){
this.dispose();
}
else if (reponse == JOptionPane.NO_OPTION){
//On ferme la fenetre de dialogue
}
} |
Partager