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
|
package test;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.naming.ldap.SortKey;
import javax.swing.BoxLayout;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.RowSorter;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
public class IHM extends JFrame {
/**
*
*/
private static final long serialVersionUID = 1L;
public IHM(){
// POUR DIMENSIONNER LA FENETRE
////////////////////////////////ENTETE//////////////////////////////
JPanel entete = new JPanel();
entete.setLayout(new FlowLayout());
entete.setBackground(Color.yellow);
JLabel labhaut = new JLabel("Contrôle de fichier IAT");
entete.add(labhaut); // panel du haut
// mise en place de la grid
JPanel LaGridCentrale = new JPanel();
LaGridCentrale.setLayout(new GridLayout(3,1));
LaGridCentrale.setBackground(Color.red);
//:::::::::::::::::::::::::LIGNE 1::::::::::::::::::::::::::::::::::::
JPanel ligne1 = new JPanel();
ligne1.setBackground(Color.LIGHT_GRAY);
//label info
JLabel lfichier1 = new JLabel(" Fichier IAT: ");//LABEL fichier 1
//Jtext
JTextField fichier1 = new JTextField();
fichier1.setPreferredSize(new Dimension(200,30));
fichier1.setColumns(10);
fichier1.setEditable(false);
fichier1.setBackground(Color.cyan);
//Jbutton 1
JButton parcourir1 = new JButton("Parcourir", createImage("parcourir.png")); //Bouton Parcourir fichier 1
// Ecouteur pour le bouton qui permet de parcourir et trouver le fichier journal des envois
//parcourir1.addActionListener(this);
//JButton 2
JButton controle = new JButton("Contrôle", createImage("controler.png"));
//controle.addActionListener((ActionListener) this);
controle.setToolTipText("Appuyer pour controler le fichier IAT");
// Create a file chooser for the button send
JFileChooser fc = new JFileChooser();
//fc.addPropertyChangeListener(this);
// Creation d'un JPopupMenu
JPopupMenu labelPopupMenu = new JPopupMenu();
labelPopupMenu.add(new JMenuItem("Contrôler",createImage("page_go.png")));
// ajout dans le panel ligne1
ligne1.add(lfichier1);
ligne1.add(fichier1);
ligne1.add(parcourir1);
ligne1.add(controle);
//:::::::::::::::::::::::::LIGNE2:::::::::::::::::::::::::::::
JPanel ligne2 = new JPanel();
ligne2.setLayout(new GridLayout(2,1));
ligne2.setBackground(Color.green);
JLabel labErreur = new JLabel("Erreurs trouvées: ");
ligne2.add(labErreur);
//JTable
DefaultTableModel tm = new DefaultTableModel();
tm.addColumn("Ligne");
tm.addColumn("N°portable faux");
tm.addColumn("Email faux");
tm.addColumn("Message d'erreur");
tm.addColumn("Agent");
tm.addColumn("ID_BP_SYMPH");
JTable table = new JTable(tm);
JScrollPane scrollpane = new JScrollPane(table);
// et ajuster la longueur des colonnes
DefaultTableCellRenderer custom = new DefaultTableCellRenderer();
custom.setHorizontalAlignment(JLabel.CENTER);
table.getColumnModel().getColumn(0).setCellRenderer(custom);
table.getColumnModel().getColumn(0).setMaxWidth(50);//ligne
table.getColumnModel().getColumn(1).setMinWidth(70);//portable
table.getColumnModel().getColumn(2).setMinWidth(170);//email
table.getColumnModel().getColumn(3).setMinWidth(190);//Msg erreur
table.getColumnModel().getColumn(4).setMinWidth(110);//Agent
table.getColumnModel().getColumn(5).setMinWidth(70);//id_BP_symph
//active le tri du tableau
table.setAutoCreateRowSorter(true);
//SortKey[] sks = new SortKey[]{ new RowSorter.SortKey(0, SortOrder.ASCENDING) };
//tri defaut tab sur 1ère colonne ds l'ordre croissant
//table.getRowSorter().setSortKeys(Arrays.asList(sks));
ligne2.add(scrollpane);
//:::::::::::::::::::::::::LIGNE3:::::::::::::::::::::::::::::
JPanel ligne3 = new JPanel();
ligne3.setLayout(new GridLayout(4,1));
ligne3.setBackground(Color.cyan);
//Pour Afficher les Résultats des taux Téléphones et emails
JLabel labcalcul1 = new JLabel("Taux qualifié global Téléphone: ");
ligne3.add(labcalcul1);
//:::::::::::::::::::::::::LIGNE4:::::::::::::::::::::::::::::
JLabel labcalcul2 = new JLabel("Taux d'anomalie/Téléphone qualifié: ");
ligne3.add(labcalcul2);
//:::::::::::::::::::::::::LIGNE5:::::::::::::::::::::::::::::
JLabel labcalcul3 = new JLabel("Taux qualifié global Email: ");
ligne3.add(labcalcul3);
//:::::::::::::::::::::::::LIGNE6:::::::::::::::::::::::::::::
JLabel labcalcul4 = new JLabel("Taux d'anomalie/Email qualifié: ");
ligne3.add(labcalcul4);
LaGridCentrale.add(ligne1);
LaGridCentrale.add(ligne2);
LaGridCentrale.add(ligne3);
// ajout dans la fenêtre
this.add(entete, BorderLayout.NORTH);
this.add(LaGridCentrale, BorderLayout.CENTER);
this.setSize(900,500);
//On quitte l'application quand la fenêtre est fermée
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private Icon createImage(String string) {
// TODO Auto-generated method stub
return null;
}
} |
Partager