From 8f86f3798f36b7da0c60f325ec252105d497b399 Mon Sep 17 00:00:00 2001 From: HORVILLE Ewen Date: Wed, 21 Sep 2022 15:40:01 +0200 Subject: [PATCH] Modifs loulz --- DEV 3.1/TP3/Tableau/Tableau.java | 33 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/DEV 3.1/TP3/Tableau/Tableau.java b/DEV 3.1/TP3/Tableau/Tableau.java index 62556b4..bd044ad 100644 --- a/DEV 3.1/TP3/Tableau/Tableau.java +++ b/DEV 3.1/TP3/Tableau/Tableau.java @@ -3,6 +3,18 @@ import javax.swing.*; import java.awt.*; public class Tableau { + + private static void changeConstraints(GridBagConstraints g, int gx, int gy, int gw, int gh, int anchor, int fill, double wx, double wy, Insets i) { + g.gridx = gx; + g.gridy = gy; + g.gridwidth = gw; + g.gridheight = gh; + g.anchor = anchor; + g.fill = fill; + g.weightx = wx; + g.weighty = wy; + g.insets = i; + } public static void main(String[] args) { try { Class.forName("org.mariadb.jdbc.Driver"); @@ -43,15 +55,7 @@ public class Tableau { 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); + changeConstraints(g, 1, count - length, 1, length, GridBagConstraints.CENTER, GridBagConstraints.BOTH, 1f, 1f, new Insets(0, 0, 0, 0)); f.add(modLabel, g); length = 0; lastMod = moduleName; @@ -61,16 +65,7 @@ public class Tableau { 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); + changeConstraints(g, 2, count, 1, 1, GridBagConstraints.CENTER, GridBagConstraints.BOTH, 1f, 1f, new Insets(0, 0, 0, 0)); f.add(fieldLabel, g); length++;