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 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248
|
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JFrame;
import java.awt.Dimension;
import javax.swing.JTextArea;
import java.awt.Rectangle;
import javax.swing.JButton;
import javax.swing.JFileChooser;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JTextField;
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import java.util.Vector;
public class Interface extends JFrame implements ActionListener {
private JPanel jContentPane = null; //declaration de notre panel
private JTextArea jTextArea = null; //pr la zone de text
private JButton jButton = null;// dclaration de notre boutton
private JButton jButton1 = null;// dclaration de notre boutton
private JLabel jLabel = null;
private JTextField jTextField = null;
private JButton jButton2 = null; // dclaration de notre boutton
private JButton jButton3 = null; // dclaration de notre boutton
private JList jList = null;
private Vector<String> vw = null; //declaration d'un vecteur j'en ai besoin pr le stockage des mots qui se trouve dans notre zone de text
/**
* Declaration de constructeur
*/
public Interface() {
initialize();
}
/**
*
*
* Methode d'intialisation
*/
private void initialize() {
this.setSize(771, 630);
this.setContentPane(getJContentPane());
this.setTitle("Ma fenêtre ");
}
/**
*methode qui initialise notre panneau
*
*
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jLabel = new JLabel();
jLabel.setBounds(new Rectangle(15, 152, 124, 29));
jLabel.setText(" ");
jContentPane = new JPanel();
jContentPane.setLayout(null);
jContentPane.setBackground(new Color(242, 228, 116));
jContentPane.add(getJTextArea(), null);
jContentPane.add(getJButton(), null);
jContentPane.add(getJButton1(), null);
jContentPane.add(jLabel, null);
jContentPane.add(getJTextField(), null);
jContentPane.add(getJButton2(), null);
jContentPane.add(getJButton3(), null);
jContentPane.add(getJList(), null);
}
return jContentPane;
}
/**
*
*
* methode initialiser textArea
*/
private JTextArea getJTextArea() {
if (jTextArea == null) {
jTextArea = new JTextArea();
jTextArea.setBounds(new Rectangle(322, 99, 418, 461));
}
return jTextArea;
}
private JList getJList() {
if (jList == null) {
jList = new JList();
jList.setBounds(new Rectangle(14, 270, 220, 500));
}
return jList;
}
/**
* methode initailisation JButton
*
*
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setBounds(new Rectangle(340, 49, 83, 37));
jButton.setForeground(new Color(51, 51, 98));
jButton.setFont(new Font("Dialog", Font.BOLD, 14));
jButton.setText("Clear");
jButton.addActionListener(this);
}
return jButton;
}
/**
*methode initailisation JButton1
*
*
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setBounds(new Rectangle(464, 49, 155, 38));
jButton1.setText("Extract entities");
jButton1.addActionListener(this);
}
return jButton1;
}
/**
*
*
* méthode pr initialiser les textField
*/
private JTextField getJTextField() {
if (jTextField == null) {
jTextField = new JTextField();
jTextField.setBounds(new Rectangle(6, 189, 212, 31));
}
return jTextField;
}
/**
* methode pr initialiser les boutton2
*/
private JButton getJButton2() {
if (jButton2 == null) {
jButton2 = new JButton();
jButton2.setBounds(new Rectangle(221, 188, 98, 31));
jButton2.setText("Parcourir...");
jButton2.addActionListener(this);
}
return jButton2;
}
/**
*
*
* methode pr initialiser jButton3
*/
private JButton getJButton3() {
if (jButton3 == null) {
jButton3 = new JButton();
jButton3.setBounds(new Rectangle(14, 228, 121, 33));
jButton3.setText("Netoyage");
jButton3.addActionListener(this);
}
return jButton3;
}
@Override
public void actionPerformed(ActionEvent arg0) {
if(arg0.getSource()==jButton1){
Word_Ex w=new Word_Ex();
w.setText(jTextArea.getText());
vw = w.Extract();//voilà ici j'ai affecté tous les mot du text entrée dans le vecteur vw
jList.setListData(vw);
}
// TODO Auto-generated method stub
if(arg0.getSource()==jButton){
jTextArea.setText(null);
}
if(arg0.getSource() == jButton2)
{
JFileChooser dialogue=new JFileChooser();
int returnVal = dialogue.showOpenDialog(this);
if(returnVal == JFileChooser.APPROVE_OPTION) {
IO_Files iof = new IO_Files();
jTextArea.setText(iof.OpenFile(dialogue.getSelectedFile().getPath()));
}
}
if(arg0.getSource() == jButton3){
Vector<String> result = new Vector<String>();
for(int i=0;i<vw.size();i++)
{
String req ;
req = "SELECT *FROM `nettoyage` WHERE mot = '" + vw.elementAt(i) + "'";
TestConnection.executeRequete(req);
try {
if(!TestConnection.results.wasNull())
result.add(vw.elementAt(i));
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
jList.setListData(result);
}
}
} |
Partager