Transférer les fichiers vers 'src/Test'

This commit is contained in:
Romain BESSON 2022-12-03 16:12:37 +01:00
parent 53481c883b
commit da69910269
3 changed files with 116 additions and 67 deletions

View File

@ -127,9 +127,6 @@ public class Controller implements ActionListener, ListSelectionListener {
this.currentJTableUse = liste;
this.parent.updateTable(liste);
//forModal.add(liste);
//BFrame frame = new BFrame(frameTitle, loca_x, loca_y, size_x, size_y, this.parent, forModal);
}
/**
@ -545,75 +542,99 @@ public class Controller implements ActionListener, ListSelectionListener {
value = tm.getValueAt(cell[0], i);
if(Objects.equals(value, "[DEPLACER]")) {
JPanel forModal = new JPanel(new GridBagLayout());
BLayout settings = new BLayout();
this.tmpStud = new ArrayList<>();
this.tmpStud.add((String) tm.getValueAt(cell[0], 0));
this.tmpStud.add((String) tm.getValueAt(cell[0], 1));
settings.setPositionX(0);
settings.setPositionY(0);
JLabel intro = new JLabel(
"Deplacer " + tm.getValueAt(cell[0], 0) + " " +
tm.getValueAt(cell[0], 1) +
" dans le groupe : "
);
forModal.add(intro, settings);
settings.setPositionX(1);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(2);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(3);
settings.setPositionY(0);
this.list = new JComboBox<>();
for(Groupe groupe : this.g) {
this.list.addItem(groupe.getName());
}
forModal.add(list, settings);
settings.setPositionX(4);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(5);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(6);
settings.setPositionY(0);
JButton moveBtn = new JButton("Deplacer");
moveBtn.setActionCommand("crtll::ActionAddAndMoveGrup");
moveBtn.addActionListener(this);
forModal.add(moveBtn, settings);
DisplayModal(
"Deplacer l'eleve : "
+ tm.getValueAt(cell[0], 0) + " " + tm.getValueAt(cell[0], 1),
500,
250,
this.av.getX(),
this.av.getY(),
forModal
);
addMoveStudent(tm, cell, "[DEPLACER]");
}
if(Objects.equals(value, "[AJOUTER]")) {
System.out.println("Ajout");
addMoveStudent(tm, cell, "[AJOUTER]");
}
}
}
}
}
private void addMoveStudent(TableModel tm, int[] cell, String action){
String[] stringSetAdd = {
"Ajouter ",
"Ajouter",
"Nouveau groupe de l'eleve : "
};
String[] stringSetMove = {
"Deplacer ",
"Deplacer",
"Deplacer l'eleve : "
};
String[] stringSet;
if (action == "[AJOUTER]"){
stringSet = stringSetAdd;
} else {
stringSet = stringSetMove;
}
JPanel forModal = new JPanel(new GridBagLayout());
BLayout settings = new BLayout();
this.tmpStud = new ArrayList<>();
this.tmpStud.add((String) tm.getValueAt(cell[0], 0));
this.tmpStud.add((String) tm.getValueAt(cell[0], 1));
settings.setPositionX(0);
settings.setPositionY(0);
JLabel intro = new JLabel(
stringSet[0] + tm.getValueAt(cell[0], 0) + " " +
tm.getValueAt(cell[0], 1) +
" dans le groupe : "
);
forModal.add(intro, settings);
settings.setPositionX(1);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(2);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(3);
settings.setPositionY(0);
this.list = new JComboBox<>();
for(Groupe groupe : this.g) {
this.list.addItem(groupe.getName());
}
forModal.add(list, settings);
settings.setPositionX(4);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(5);
settings.setPositionY(0);
forModal.add(new JLabel(" "), settings);
settings.setPositionX(6);
settings.setPositionY(0);
JButton moveBtn = new JButton(stringSet[1]);
moveBtn.setActionCommand("crtll::ActionAddAndMoveGrup");
moveBtn.addActionListener(this);
forModal.add(moveBtn, settings);
DisplayModal(
stringSet[2]
+ tm.getValueAt(cell[0], 0) + " " + tm.getValueAt(cell[0], 1),
500,
250,
this.av.getX(),
this.av.getY(),
forModal
);
this.parent.updateTable(this.initTable());
}
public JTable initTable() {
Object[][] data = new Object[this.e.size()][3];
String[] title = {
@ -625,8 +646,7 @@ public class Controller implements ActionListener, ListSelectionListener {
Object[] info = {
this.e.get(i).getNom(),
this.e.get(i).getPrenom(),
String.valueOf(this.e.get(i).getGroupe()),
"[DEPLACER]"
String.valueOf(this.e.get(i).getGroupe())
};
data[i] = info;
}

View File

@ -26,8 +26,8 @@ public class CustomJButton extends JButton {
private void init() {
this.setFont(font);
this.setFocusPainted(false);
//this.setContentAreaFilled(false);
this.setBorderPainted(false);
this.setContentAreaFilled(false);
//this.setBorderPainted(false);
this.setBorder(new RoundedBorder(radius));
}
}

View File

@ -0,0 +1,29 @@
package Test;
import javax.swing.border.Border;
import java.awt.*;
public class RoundedBorder implements Border {
private int radius;
RoundedBorder(int radius) {
this.radius = radius;
}
public Insets getBorderInsets(Component c) {
return new Insets(this.radius+1, this.radius+1, this.radius+2, this.radius);
}
public boolean isBorderOpaque() {
return true;
}
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
g.drawRoundRect(x, y, width-1, height-1, radius, radius);
}
}