TP3 Terminé
This commit is contained in:
parent
9dc29b2cbe
commit
e5116b051f
@ -20,15 +20,76 @@ public class Tableau {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JFrame f = new JFrame();
|
||||||
|
f.setLayout(new GridBagLayout());
|
||||||
|
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
f.setSize(150, 500);
|
||||||
|
|
||||||
|
GridBagConstraints g = new GridBagConstraints();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
PreparedStatement req = cnx.prepareStatement("SELECT Module.code, Champ.code FROM Champ JOIN Module ON Champ.id = Module.id ORDER BY Module.code ASC;");
|
PreparedStatement req = cnx.prepareStatement("SELECT Module.code, Champ.code FROM Champ JOIN Module ON Champ.id = Module.id ORDER BY Module.code ASC;");
|
||||||
req.executeUpdate();
|
req.executeUpdate();
|
||||||
ResultSet rs = req.executeQuery();
|
ResultSet rs = req.executeQuery();
|
||||||
|
|
||||||
|
String lastMod = null;
|
||||||
|
int length = 0;
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
while (rs.next()) {
|
while (rs.next()) {
|
||||||
System.out.println(rs.getString(1) + " " + rs.getString(2));
|
String moduleName = rs.getString(1);
|
||||||
|
String fieldName = rs.getString(2);
|
||||||
|
|
||||||
|
if (!moduleName.equals(lastMod) && lastMod != null) {
|
||||||
|
JLabel modLabel = new JLabel(lastMod);
|
||||||
|
modLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||||
|
g.gridx = 1;
|
||||||
|
g.gridy = count - length;
|
||||||
|
g.gridwidth = 1;
|
||||||
|
g.gridheight = length;
|
||||||
|
g.anchor = GridBagConstraints.CENTER;
|
||||||
|
g.fill = GridBagConstraints.BOTH;
|
||||||
|
g.weightx = 1f;
|
||||||
|
g.weighty = 1f;
|
||||||
|
g.insets = new Insets(0, 0, 0, 0);
|
||||||
|
f.add(modLabel, g);
|
||||||
|
length = 0;
|
||||||
|
lastMod = moduleName;
|
||||||
|
} else {
|
||||||
|
lastMod = moduleName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JLabel fieldLabel = new JLabel(fieldName);
|
||||||
|
fieldLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||||
|
|
||||||
|
g.gridx = 2;
|
||||||
|
g.gridy = count;
|
||||||
|
g.gridwidth = 1;
|
||||||
|
g.gridheight = 1;
|
||||||
|
g.anchor = GridBagConstraints.CENTER;
|
||||||
|
g.fill = GridBagConstraints.BOTH;
|
||||||
|
g.weightx = 1f;
|
||||||
|
g.weighty = 1f;
|
||||||
|
g.insets = new Insets(0, 0, 0, 0);
|
||||||
|
f.add(fieldLabel, g);
|
||||||
|
|
||||||
|
length++;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
JLabel modLabel = new JLabel(lastMod);
|
||||||
|
modLabel.setBorder(BorderFactory.createLineBorder(Color.BLACK));
|
||||||
|
g.gridx = 1;
|
||||||
|
g.gridy = count - length;
|
||||||
|
g.gridwidth = 1;
|
||||||
|
g.gridheight = length;
|
||||||
|
g.anchor = GridBagConstraints.CENTER;
|
||||||
|
g.fill = GridBagConstraints.BOTH;
|
||||||
|
g.weightx = 1f;
|
||||||
|
g.weighty = 1f;
|
||||||
|
g.insets = new Insets(0, 0, 0, 0);
|
||||||
|
f.add(modLabel, g);
|
||||||
|
|
||||||
rs.close();
|
rs.close();
|
||||||
req.close();
|
req.close();
|
||||||
|
|
||||||
@ -37,6 +98,8 @@ public class Tableau {
|
|||||||
System.err.println (ex);
|
System.err.println (ex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f.setVisible(true);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
cnx.close();
|
cnx.close();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
Loading…
Reference in New Issue
Block a user