bonjour

j'aimerai savoir comment faire pour réaliser des courbes en java.pouvez vous me donner le code source sous netbeans voila le code sous eclipse mai je c pas comment le rédiger sous netbeans.merci

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
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
import javax.swing.*;
import javax.swing.border.Border;
 
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
 
import com.mysql.jdbc.PreparedStatement;
 
import java.awt.event.*;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.sql.*;
import java.util.Vector;
public class Interfaceg extends JFrame{
    private JPanel ppannel;
    private JLabel l1;
    private JLabel l2;
    private JLabel l3;
    private JTextField t1; 
    private JTextField t2;
    private JButton b1;
    private JButton b2;
    private JButton b3;
    private JTable tab;
private void initComponents() throws SQLException, IOException{
 
    ppannel=new JPanel();
    ppannel.setLayout(null);
    Border b=BorderFactory.createTitledBorder("Gestion d'abscences");
    ppannel.setBorder(b);
    ppannel.setSize(500, 500);
    this.setLayout(null);
    this.setBounds(100, 100, 500, 500);
    this.setContentPane(ppannel);
    this.addWindowListener(new java.awt.event.WindowAdapter() {
        public void windowOpened(java.awt.event.WindowEvent evt) {
                try {
                constructGraphe();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
    });
    //////////////////////////////////////////////
    l1=new JLabel();
    l1.setText("NOM COMPLET");
    l1.setBounds(25, 25, 90, 20);
 
    l2=new JLabel();
    l2.setText("NB ABSCENCE");
    l2.setBounds(25, 45, 90, 20);
 
    l3=new JLabel();
    ////////////////////////////////////////////////////
    t1=new JTextField();
    t1.setBounds(125,25,80,20);
    t2=new JTextField();
    t2.setBounds(125,50,80,20);
 
    ////////////////////////////////////////////////////
    b1=new JButton();
    b1.setText("Ajouter");
    b1.setBounds(70,80,90,20);
    b1.addActionListener(new java.awt.event.ActionListener(){
 
 
        public void actionPerformed(ActionEvent evt) {
 
            try {
                Statement pst = Connect.getConnOra().createStatement();
                pst.executeUpdate("insert into personne values(19,'"+ t1.getText()+"',"+Integer.valueOf(t2.getText())+")");
                constructGraphe();
            } catch (SQLException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
 
 
        }
    });
    b2=new JButton();
    b2.setText("Modifier");
    b2.setBounds(165,80,90,20);
 
    b3=new JButton();
    b3.setText("Supprimer");
    b3.setBounds(260,80,95,20);
    b3.addActionListener(new java.awt.event.ActionListener(){
    public void actionPerformed(ActionEvent evt) {
 
        try {
            Statement pst = Connect.getConnOra().createStatement();
            pst.executeUpdate("delete from personne where nom ='"+t1.getText()+"'");
            constructGraphe();
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
 
 
    }
});
    ppannel.add(l1);
    ppannel.add(l2);
    ppannel.add(b1);
    ppannel.add(b2);
    ppannel.add(b3);
    ppannel.add(t1);
    ppannel.add(t2);
    tab=new JTable();
    tab.setBounds(260, 130, 200, 200);
 
 
    ppannel.add(tab);
    l3.setBounds(5, 100, 250, 300);
    ppannel.add(l3);
    //////////////////////////////////////////////////
}
public static void main(String[] argv) throws SQLException, IOException
{
 
 
    Interfaceg f=new Interfaceg();
    f.initComponents();
    f.setVisible(true);
}
public void constructGraphe() throws SQLException, IOException
{
    DefaultCategoryDataset dataset=new DefaultCategoryDataset();
 
    Statement st=Connect.getConnOra().createStatement();
    Vector<Object> matrice=new Vector<Object>();
 
    ResultSet rs=st.executeQuery("select num,nom,abscence from personne order by abscence");
    while(rs.next()){
    dataset.addValue(rs.getInt(3), rs.getString(2),""); 
    Vector<Object> V=new Vector<Object>();
    V.add(rs.getInt(1));
    V.add(rs.getString(2));
    V.add(rs.getInt(3));
    matrice.add(V);
 
    }
    Vector<String> titres=new Vector<String>();
    titres.add("Num");
    titres.add("Nom");
    titres.add("Abscence");
 
     tab.setModel(new javax.swing.table.DefaultTableModel(matrice,titres));
    //////////////////////////////////////////////
    JFreeChart chart=ChartFactory.createBarChart3D("Graphe 1.1 : Abscences", "Etudiants", "Total AB/ET", dataset, PlotOrientation.VERTICAL, true, true, true);
    File file=new File("./image.jpeg");
    ChartUtilities.saveChartAsJPEG(file, chart, 250, 300);
    ImageIcon img=new ImageIcon("./image.jpeg");
JLabel l4=new JLabel();
l4.setText("omar");
//l3.setText("omar");
l3.setIcon(img);    
 
 
}
}