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
|
public class AjouterFacture implements ActionListener {
private JFrame fs;
private JFrame fc;
private JTable jTable1;
List<Facture> tableauFactures;
private JTextField numFact = new JTextField(12);
private JTextField prixFact = new JTextField(6);
private Choice c;
private JLabel lfact = new JLabel("Numéro de la facture : ");
private JLabel lclient = new JLabel("Nom du client : ");
private JLabel lprixTTC = new JLabel("Prix de la prestation : ");
private JButton valider = new JButton("Valider",new ImageIcon("images/valider.png"));
private JButton annuler = new JButton("Annuler",new ImageIcon("images/annuler.gif"));
static Dimension tailleEcran = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
static final int DEFAULT_WIDTH = (int)tailleEcran.getWidth();
static final int DEFAULT_HEIGHT = (int)tailleEcran.getHeight();
AjouterFacture(List<Facture> tableauFactures, JTable jTable1, JFrame fs,JFrame fc){
this.jTable1=jTable1;
this.fs=fs;
this.tableauFactures=tableauFactures;
this.fc=fc;
}
public void actionPerformed(ActionEvent e)
{
fc= new JFrame();
fs.setEnabled(false);
fc.setTitle("Création d'une facture");
fc.setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
fc.setResizable(false);
fc.setLayout(null);
//Where the GUI is created:
JMenuBar menuBar;
JMenu menu;
JMenuItem menuItem;
//Create the menu bar.
menuBar = new JMenuBar();
//Build the first menu.
menu = new JMenu("Fichier");
menuBar.add(menu);
//a group of JMenuItems
menuItem = new JMenuItem("quitter");
menuItem.addActionListener(new QuitterListenerFenetreSecondaire(fs,fc));
menu.add(menuItem);
menuItem = new JMenuItem("Description");
menuItem.addActionListener(new DescriptionListener(fs));
menu.add(menuItem);
//Build second menu in the menu bar.
menu = new JMenu("Edition");
menuBar.add(menu);
fc.setJMenuBar(menuBar);
fc.addWindowListener (new WindowAdapter(){
public void windowClosing (WindowEvent e){
fs.setEnabled(true);
fc.dispose();
}
});
c = Client.remplirListeDeroulante();
c.setBounds(150,200,150,25);
lfact.setBounds(0,150,150,25);
numFact.setBounds(150,150,150,25);
lclient.setBounds(0,200,150,25);
lprixTTC.setBounds(0,250,150,25);
prixFact.setBounds(150,250,150,25);
valider.setBounds(470,900,120,30);
annuler.setBounds(590,900,120,30);
fc.add(valider);
fc.add(c);
fc.add(numFact);
fc.add(lfact);
fc.add(lprixTTC);
fc.add(lclient);
fc.add(prixFact);
fc.add(annuler);
tableauFactures=Facture.getTableauFactures();
valider.addActionListener(new validerAjoutFacture(tableauFactures,c,prixFact,numFact,jTable1,fs,fc));
annuler.addActionListener(new QuitterListenerFenetreSecondaire(fs,fc));
fc.setVisible(true);
}
} |