bonjour ça ne marche toujours pas.essai de me chercher ça avec :et ca comme explication j'arrive pas avec les SwingWorkers
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 class MonSwingWorker extends SwingWorker<Integer, String> { @Override public Integer doInBackground() { return tresLong(); } private int tresLong() { tache.TexC11(); //execution et affichage cellule 1 lign1 tache.TexC12(); tache.TexC13(); tache.TexC14(); tache.TexC15(); tache.TexC16(); tache.TexC17(); tache.TexC18(); tache.TexC19(); tache.TexC21(); //execution et affichage cellule 1 lign1 tache.TexC22(); tache.TexC23(); tache.TexC24(); tache.TexC25(); tache.TexC26(); tache.TexC27(); tache.TexC28(); tache.TexC29(); tache.TexC31(); //execution et affichage cellule 1 lign1 tache.TexC32(); tache.TexC33(); tache.TexC34(); tache.TexC35(); tache.TexC36(); tache.TexC37(); tache.TexC38(); tache.TexC39(); tache.TexC41(); //execution et affichage cellule 1 lign1 tache.TexC42(); tache.TexC43(); tache.TexC44(); tache.TexC45(); tache.TexC46(); tache.TexC47(); tache.TexC48(); tache.TexC49(); return 1; } @Override protected void done() { try { // Le traitement est terminé. jTextField1.setText(" fini "); // JOptionPane.showMessageDialog(null,String.valueOf(get())); } catch(Exception e) { } } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 public void TexC11(){ connexion.executeSQL("SELECT COUNT(Groupe) AS Nb_Groupe FROM Ec_Taches_en_cours WHERE Groupe = ( SELECT Ligne1 FROM Noms_Lignes WHERE Ligne10 = 'Rien_Ligne_Tableau_Bord' )"); try{ connexion.resultset.first(); Tablea.jtext1_table_vil.setText(connexion.resultset.getString("Nb_Groupe")); int text11 = Integer.parseInt(Tablea.jtext1_table_vil.getText()); try{ if (( text11 == 0) ) Tablea.jtext1_table_vil.setBackground(new Color( 255,255,255)); else if(( text11 <= 3) && (text11 < 5) ) Tablea.jtext1_table_vil.setBackground(new Color(255,255,0)); else if( text11 >= 5) Tablea.jtext1_table_vil.setBackground(new Color(0,255,0)); else if ( text11 < 0) Tablea.jtext1_table_vil.setBackground(new Color(255,0,0)); } catch( Exception e) { } Tablea.jtext1_table_vil.setEditable(false); } catch(SQLException error) { JOptionPane.showMessageDialog(null," erreur de lecture sur champs "+ error); } }
Partager