Drag and drop action
Fermé
imad-memati
Messages postés
4
Date d'inscription
vendredi 7 décembre 2012
Statut
Membre
Dernière intervention
18 mars 2013
-
18 mars 2013 à 19:33
imad-memati Messages postés 4 Date d'inscription vendredi 7 décembre 2012 Statut Membre Dernière intervention 18 mars 2013 - 18 mars 2013 à 20:03
imad-memati Messages postés 4 Date d'inscription vendredi 7 décembre 2012 Statut Membre Dernière intervention 18 mars 2013 - 18 mars 2013 à 20:03
A voir également:
- Drag and drop action
- Action - Guide
- Télécharger film d'action gratuitement et rapidement - Télécharger - TV & Vidéo
- Action fans - Accueil - Guide arnaque
- Share drop - Télécharger - Téléchargement & Transfert
- Cette action ne peut pas être réalisée car le fichier est ouvert dans system - Guide
2 réponses
KX
Messages postés
16754
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
25 novembre 2024
3 020
18 mars 2013 à 19:40
18 mars 2013 à 19:40
"changer le para DnDConstants.ACTION_MOVE à DnDConstants.ACTION_COPY"
Sans ton code, difficile de comprendre de quoi tu parles...
"déplacer une copie de mon composant"
Il faut créer un nouveau composant qui sera identique au premier, mais là encore cela dépendra de ton code et du contenu de tes composants...
Bref, expliques d'avantage ce que tu as déjà fait (code à l'appui), et ce que tu veux faire, plus ta question sera précise, plus la réponse sera adaptée...
Sans ton code, difficile de comprendre de quoi tu parles...
"déplacer une copie de mon composant"
Il faut créer un nouveau composant qui sera identique au premier, mais là encore cela dépendra de ton code et du contenu de tes composants...
Bref, expliques d'avantage ce que tu as déjà fait (code à l'appui), et ce que tu veux faire, plus ta question sera précise, plus la réponse sera adaptée...
imad-memati
Messages postés
4
Date d'inscription
vendredi 7 décembre 2012
Statut
Membre
Dernière intervention
18 mars 2013
18 mars 2013 à 19:46
18 mars 2013 à 19:46
ok voici mes codes :
d'abord j'une classe dérive d'un jpanel qui represente le dragsource :
public class Algo extends javax.swing.JPanel implements DragSourceListener, DragGestureListener, Transferable {
DragSource ds = DragSource.getDefaultDragSource();
DataFlavor dataFlavor = new DataFlavor(Algo.class, Algo.class.getSimpleName());
private String titre;
private int id;
Point p = new Point(-1111, -1111);
Point p2 = new Point(0, 0);
Point p0 = new Point(-1111, -1111);
MouseEvent evtt;
public Algo(String titre, int id) {
initComponents();
ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
this.titre = titre;
this.id = id;
this.jLabel2.setText(titre);
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitre() {
return titre;
}
public void setTitre(String titre) {
this.titre = titre;
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
formMouseClicked(evt);
}
public void mouseReleased(java.awt.event.MouseEvent evt) {
formMouseReleased(evt);
}
});
addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseDragged(java.awt.event.MouseEvent evt) {
formMouseDragged(evt);
}
});
jLabel2.setText("jLabel2");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(29, 29, 29)
.addComponent(jLabel2)
.addContainerGap(337, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jLabel2)
.addContainerGap(258, Short.MAX_VALUE))
);
}// </editor-fold>
private void formMouseClicked(java.awt.event.MouseEvent evt) {
}
private void formMouseDragged(java.awt.event.MouseEvent evt) {
}
private void formMouseReleased(java.awt.event.MouseEvent evt) {
p0 = new Point(-1111, -1111);
p = new Point(-1111, -1111);
System.out.println("sssssss");
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel2;
// End of variables declaration
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
dge.startDrag(DragSource.DefaultCopyDrop, this, this);
evtt = (MouseEvent) dge.getTriggerEvent();
p = evtt.getLocationOnScreen();
p0 = this.getLocation();
}
@Override
public void dragEnter(DragSourceDragEvent dsde) {
System.out.println("dropddd");
test.algorithmEnMain = id;
}
@Override
public void dragOver(DragSourceDragEvent dsde) {
//dsde.getDragSourceContext().getComponent().setLocation(Constant.x, Constant.y);
//this.setLocation(dsde.getLocation().x-this.getWidth(),dsde.getLocation().y-this.getHeight());
//System.out.println(p2.x-p.x);
PointerInfo a = MouseInfo.getPointerInfo();
p2 = a.getLocation();
System.out.println("fp " + p0 + " " + p);
System.out.println(p + " " + p2);
this.setLocation(p2.x - p.x + p0.x, p2.y - p.y + p0.y);
}
@Override
public void dropActionChanged(DragSourceDragEvent dsde) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void dragExit(DragSourceEvent dse) {
System.out.println("ssssssssssssssssssssss");
}
@Override
public void dragDropEnd(DragSourceDropEvent dsde) {
}
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[]{dataFlavor};
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.equals(dataFlavor);
}
@Override
public Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException, IOException {
if (flavor.equals(dataFlavor)) {
//System.out.println("flavor ok");
return this.id;
} else {
throw new UnsupportedFlavorException(flavor);
}
}
public String toString() {
return "Algo{" + "titre=" + titre + ", id=" + id + '}';
}
public void setPosition(Point p) {
this.setLocation(p);
}
}
et voila le code de l'emplacement ou je dois mettre le 1er Jpanel
public class AlgoPlace extends javax.swing.JPanel implements DropTargetListener{//,DragGestureListener,DragSourceListener {
/**
* Creates new form AlgoPlace
*/
int algorithmAAppliquer;
DropTarget dt;
//DragSource ds = DragSource.getDefaultDragSource();
DataFlavor dataFlavor = new DataFlavor(Algo.class,Algo.class.getSimpleName());
public AlgoPlace() {
initComponents();
algorithmAAppliquer = -1;
dt = new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
//drag
//ds.createDefaultDragGestureRecognizer(this,DnDConstants.ACTION_COPY_OR_MOVE, this);
}
public int getAlgorithmAAppliquer() {
return algorithmAAppliquer;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
}// </editor-fold>
// Variables declaration - do not modify
// End of variables declaration
//drop
@Override
public void dragEnter(DropTargetDragEvent dtde) {
System.out.println("entrée");
}
@Override
public void dragOver(DropTargetDragEvent dtde) {
}
@Override
public void dropActionChanged(DropTargetDragEvent dtde) {
System.out.println("dropActionChanged algoplace");
}
@Override
public void dragExit(DropTargetEvent dte) {
if(test.algorithmEnMain == this.algorithmAAppliquer){
System.out.println("sortie");
algorithmAAppliquer = -1;
}
}
@Override
public void drop(DropTargetDropEvent dtde) {
System.out.println("déposé");
try {
if (dtde.isDataFlavorSupported(dataFlavor) && algorithmAAppliquer ==-1) {
System.out.println("kayna");
dtde.acceptDrop(DnDConstants.ACTION_COPY);
System.out.println(((int)dtde.getTransferable().getTransferData(dataFlavor)));
algorithmAAppliquer = ((int)dtde.getTransferable().getTransferData(dataFlavor));
//this.add((Algo) dtde.getTransferable());
dtde.dropComplete(true);
this.validate();
return;
}
System.out.println("walou");
dtde.rejectDrop();
} catch (Exception e) {
e.printStackTrace();
dtde.rejectDrop();
}
}
@Override
public String toString() {
return "AlgoPlace{videeeeeee" + '}';
}
d'abord j'une classe dérive d'un jpanel qui represente le dragsource :
public class Algo extends javax.swing.JPanel implements DragSourceListener, DragGestureListener, Transferable {
DragSource ds = DragSource.getDefaultDragSource();
DataFlavor dataFlavor = new DataFlavor(Algo.class, Algo.class.getSimpleName());
private String titre;
private int id;
Point p = new Point(-1111, -1111);
Point p2 = new Point(0, 0);
Point p0 = new Point(-1111, -1111);
MouseEvent evtt;
public Algo(String titre, int id) {
initComponents();
ds.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
this.titre = titre;
this.id = id;
this.jLabel2.setText(titre);
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getTitre() {
return titre;
}
public void setTitre(String titre) {
this.titre = titre;
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jLabel2 = new javax.swing.JLabel();
addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
formMouseClicked(evt);
}
public void mouseReleased(java.awt.event.MouseEvent evt) {
formMouseReleased(evt);
}
});
addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
public void mouseDragged(java.awt.event.MouseEvent evt) {
formMouseDragged(evt);
}
});
jLabel2.setText("jLabel2");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(29, 29, 29)
.addComponent(jLabel2)
.addContainerGap(337, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(jLabel2)
.addContainerGap(258, Short.MAX_VALUE))
);
}// </editor-fold>
private void formMouseClicked(java.awt.event.MouseEvent evt) {
}
private void formMouseDragged(java.awt.event.MouseEvent evt) {
}
private void formMouseReleased(java.awt.event.MouseEvent evt) {
p0 = new Point(-1111, -1111);
p = new Point(-1111, -1111);
System.out.println("sssssss");
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel2;
// End of variables declaration
@Override
public void dragGestureRecognized(DragGestureEvent dge) {
dge.startDrag(DragSource.DefaultCopyDrop, this, this);
evtt = (MouseEvent) dge.getTriggerEvent();
p = evtt.getLocationOnScreen();
p0 = this.getLocation();
}
@Override
public void dragEnter(DragSourceDragEvent dsde) {
System.out.println("dropddd");
test.algorithmEnMain = id;
}
@Override
public void dragOver(DragSourceDragEvent dsde) {
//dsde.getDragSourceContext().getComponent().setLocation(Constant.x, Constant.y);
//this.setLocation(dsde.getLocation().x-this.getWidth(),dsde.getLocation().y-this.getHeight());
//System.out.println(p2.x-p.x);
PointerInfo a = MouseInfo.getPointerInfo();
p2 = a.getLocation();
System.out.println("fp " + p0 + " " + p);
System.out.println(p + " " + p2);
this.setLocation(p2.x - p.x + p0.x, p2.y - p.y + p0.y);
}
@Override
public void dropActionChanged(DragSourceDragEvent dsde) {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void dragExit(DragSourceEvent dse) {
System.out.println("ssssssssssssssssssssss");
}
@Override
public void dragDropEnd(DragSourceDropEvent dsde) {
}
@Override
public DataFlavor[] getTransferDataFlavors() {
return new DataFlavor[]{dataFlavor};
}
@Override
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.equals(dataFlavor);
}
@Override
public Object getTransferData(DataFlavor flavor)
throws UnsupportedFlavorException, IOException {
if (flavor.equals(dataFlavor)) {
//System.out.println("flavor ok");
return this.id;
} else {
throw new UnsupportedFlavorException(flavor);
}
}
public String toString() {
return "Algo{" + "titre=" + titre + ", id=" + id + '}';
}
public void setPosition(Point p) {
this.setLocation(p);
}
}
et voila le code de l'emplacement ou je dois mettre le 1er Jpanel
public class AlgoPlace extends javax.swing.JPanel implements DropTargetListener{//,DragGestureListener,DragSourceListener {
/**
* Creates new form AlgoPlace
*/
int algorithmAAppliquer;
DropTarget dt;
//DragSource ds = DragSource.getDefaultDragSource();
DataFlavor dataFlavor = new DataFlavor(Algo.class,Algo.class.getSimpleName());
public AlgoPlace() {
initComponents();
algorithmAAppliquer = -1;
dt = new DropTarget(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
//drag
//ds.createDefaultDragGestureRecognizer(this,DnDConstants.ACTION_COPY_OR_MOVE, this);
}
public int getAlgorithmAAppliquer() {
return algorithmAAppliquer;
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 400, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 300, Short.MAX_VALUE)
);
}// </editor-fold>
// Variables declaration - do not modify
// End of variables declaration
//drop
@Override
public void dragEnter(DropTargetDragEvent dtde) {
System.out.println("entrée");
}
@Override
public void dragOver(DropTargetDragEvent dtde) {
}
@Override
public void dropActionChanged(DropTargetDragEvent dtde) {
System.out.println("dropActionChanged algoplace");
}
@Override
public void dragExit(DropTargetEvent dte) {
if(test.algorithmEnMain == this.algorithmAAppliquer){
System.out.println("sortie");
algorithmAAppliquer = -1;
}
}
@Override
public void drop(DropTargetDropEvent dtde) {
System.out.println("déposé");
try {
if (dtde.isDataFlavorSupported(dataFlavor) && algorithmAAppliquer ==-1) {
System.out.println("kayna");
dtde.acceptDrop(DnDConstants.ACTION_COPY);
System.out.println(((int)dtde.getTransferable().getTransferData(dataFlavor)));
algorithmAAppliquer = ((int)dtde.getTransferable().getTransferData(dataFlavor));
//this.add((Algo) dtde.getTransferable());
dtde.dropComplete(true);
this.validate();
return;
}
System.out.println("walou");
dtde.rejectDrop();
} catch (Exception e) {
e.printStackTrace();
dtde.rejectDrop();
}
}
@Override
public String toString() {
return "AlgoPlace{videeeeeee" + '}';
}
KX
Messages postés
16754
Date d'inscription
samedi 31 mai 2008
Statut
Modérateur
Dernière intervention
25 novembre 2024
3 020
18 mars 2013 à 19:59
18 mars 2013 à 19:59
À quoi correspond "test" lorsqu'il est utilisé dans "test.algorithmEnMain = id;" ?
Je n'ai rien sur cet objet...
De plus je n'ai pas la méthode main, il est important que je puisse tester chez moi pour voir ce que tu as fait, parce que je ne connais pas du tout ce package java.awt.dnd
Je n'ai rien sur cet objet...
De plus je n'ai pas la méthode main, il est important que je puisse tester chez moi pour voir ce que tu as fait, parce que je ne connais pas du tout ce package java.awt.dnd
imad-memati
Messages postés
4
Date d'inscription
vendredi 7 décembre 2012
Statut
Membre
Dernière intervention
18 mars 2013
18 mars 2013 à 20:03
18 mars 2013 à 20:03
test c la classe qui contient la méthode main,
public class test extends javax.swing.JFrame { /** * Creates new form test */ public test() { initComponents(); a1.setSize(100, 100); a2.setSize(100, 100); a3.setSize(100, 100); a4.setSize(100, 100); a5.setSize(100, 100); a6.setSize(100, 100); a1.setBackground(Color.green); a2.setBackground(Color.green); a3.setBackground(Color.green); a4.setBackground(Color.green); a5.setBackground(Color.green); a6.setBackground(Color.green); a1.setLocation(450, 50); a2.setLocation(a1.getLocation().x + a1.getWidth()+50, a1.getY()); a3.setLocation(a2.getLocation().x + a2.getWidth()+50, a1.getY()); a4.setLocation(450, 50); a5.setLocation(a1.getLocation().x + a1.getWidth()+50, a1.getY()); a6.setLocation(a2.getLocation().x + a2.getWidth()+50, a1.getY()); this.jLayeredPane1.add(a1, 1); this.jLayeredPane1.add(a2, 1); this.jLayeredPane1.add(a3, 1); this.jLayeredPane1.add(a4, 1); this.jLayeredPane1.add(a5, 1); this.jLayeredPane1.add(a6, 1); this.jLayeredPane1.setComponentZOrder(this.algoPlace1, 7); this.jLayeredPane1.setComponentZOrder(this.algoPlace2, 7); this.jLayeredPane1.setComponentZOrder(this.algoPlace4, 7); this.jLayeredPane1.setComponentZOrder(this.entre1,7); this.jLayeredPane1.setComponentZOrder(this.principaleTable1,this.jLayeredPane1.getComponentCount()-1); this.jLabel3.setVisible(false); a3.setVisible(false); a4.setVisible(false); a5.setVisible(false); a1.setVisible(false); a2.setVisible(false); a6.setVisible(false); //algos.add(a1); // algos.add(a2); /* m.setSize(200, 200); m.setBackground(Color.black); m.setLocation(210, 10); this.jLayeredPane1.add(m,1); * */ } /* public static Vector getAlgos(){ return algos; }*/ /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code"> private void initComponents() { jButton1 = new javax.swing.JButton(); algoPlace3 = new imad.AlgoPlace(); jLayeredPane1 = new javax.swing.JLayeredPane(); principaleTable1 = new imad.PrincipaleTable(); algoPlace1 = new imad.AlgoPlace(); entre1 = new imad.Entre(); jButton2 = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); algoPlace2 = new imad.AlgoPlace(); algoPlace4 = new imad.AlgoPlace(); jButton1.setText("jButton1"); javax.swing.GroupLayout algoPlace3Layout = new javax.swing.GroupLayout(algoPlace3); algoPlace3.setLayout(algoPlace3Layout); algoPlace3Layout.setHorizontalGroup( algoPlace3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 100, Short.MAX_VALUE) ); algoPlace3Layout.setVerticalGroup( algoPlace3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 100, Short.MAX_VALUE) ); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jLayeredPane1.setBackground(new java.awt.Color(204, 204, 204)); jLayeredPane1.setOpaque(true); jLayeredPane1.setPreferredSize(new java.awt.Dimension(1366, 768)); principaleTable1.setBackground(new java.awt.Color(204, 255, 204)); principaleTable1.setPreferredSize(new java.awt.Dimension(1366, 768)); algoPlace1.setBackground(new java.awt.Color(51, 102, 255)); algoPlace1.setPreferredSize(new java.awt.Dimension(120, 120)); javax.swing.GroupLayout algoPlace1Layout = new javax.swing.GroupLayout(algoPlace1); algoPlace1.setLayout(algoPlace1Layout); algoPlace1Layout.setHorizontalGroup( algoPlace1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 120, Short.MAX_VALUE) ); algoPlace1Layout.setVerticalGroup( algoPlace1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 120, Short.MAX_VALUE) ); entre1.setPreferredSize(new java.awt.Dimension(300, 300)); jButton2.setText("Appliquer"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); jPanel1.setPreferredSize(new java.awt.Dimension(300, 300)); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addContainerGap(254, Short.MAX_VALUE) .addComponent(jLabel3) .addGap(46, 46, 46)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addGap(78, 78, 78) .addComponent(jLabel3) .addContainerGap(222, Short.MAX_VALUE)) ); algoPlace2.setBackground(new java.awt.Color(51, 102, 255)); algoPlace2.setPreferredSize(new java.awt.Dimension(120, 120)); javax.swing.GroupLayout algoPlace2Layout = new javax.swing.GroupLayout(algoPlace2); algoPlace2.setLayout(algoPlace2Layout); algoPlace2Layout.setHorizontalGroup( algoPlace2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 120, Short.MAX_VALUE) ); algoPlace2Layout.setVerticalGroup( algoPlace2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 120, Short.MAX_VALUE) ); algoPlace4.setBackground(new java.awt.Color(51, 102, 255)); algoPlace4.setPreferredSize(new java.awt.Dimension(120, 120)); javax.swing.GroupLayout algoPlace4Layout = new javax.swing.GroupLayout(algoPlace4); algoPlace4.setLayout(algoPlace4Layout); algoPlace4Layout.setHorizontalGroup( algoPlace4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 120, Short.MAX_VALUE) ); algoPlace4Layout.setVerticalGroup( algoPlace4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGap(0, 120, Short.MAX_VALUE) ); javax.swing.GroupLayout principaleTable1Layout = new javax.swing.GroupLayout(principaleTable1); principaleTable1.setLayout(principaleTable1Layout); principaleTable1Layout.setHorizontalGroup( principaleTable1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(principaleTable1Layout.createSequentialGroup() .addGap(59, 59, 59) .addComponent(entre1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(60, 60, 60) .addComponent(algoPlace1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(54, 54, 54) .addComponent(algoPlace2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(54, 54, 54) .addComponent(algoPlace4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 83, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(140, 140, 140)) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, principaleTable1Layout.createSequentialGroup() .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jButton2) .addGap(637, 637, 637)) ); principaleTable1Layout.setVerticalGroup( principaleTable1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, principaleTable1Layout.createSequentialGroup() .addGroup(principaleTable1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(principaleTable1Layout.createSequentialGroup() .addGap(206, 206, 206) .addGroup(principaleTable1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(entre1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(principaleTable1Layout.createSequentialGroup() .addGap(293, 293, 293) .addGroup(principaleTable1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(algoPlace2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(algoPlace1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(algoPlace4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addGap(58, 58, 58) .addComponent(jButton2) .addContainerGap(193, Short.MAX_VALUE)) ); algoPlace1.getAccessibleContext().setAccessibleParent(jLayeredPane1); principaleTable1.setBounds(-40, -20, 1410, 780); jLayeredPane1.add(principaleTable1, javax.swing.JLayeredPane.DEFAULT_LAYER); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLayeredPane1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) ); pack(); }// </editor-fold> private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) { if(Entre.getTypeDeDonnee()== 2){ a1.setVisible(true); a2.setVisible(true); a3.setVisible(true); switch(this.algoPlace1.getAlgorithmAAppliquer()){ case 0: m = Fct.somme(this.entre1.getMat()); switch(this.algoPlace2.getAlgorithmAAppliquer()){ case 0: break; case 1: m = Fct.trier(m); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: break; case 1: break; case 2: m = Fct.produit(m); break; default: break; } break; case 2: m = Fct.produit(m); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: break; case 1: m = Fct.trier(m); break; case 2: break; default: break; } break; default: switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: break; case 1: m = Fct.trier(m); break; case 2: m = Fct.produit(m); break; default: break; } break; } m.setSize(300,300); m.setLocation(0, 0); this.jPanel1.add(m); break; case 1: m = Fct.trier(this.entre1.getMat()); switch(this.algoPlace2.getAlgorithmAAppliquer()){ case 0: m = Fct.somme(m); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: break; case 1: break; case 2: m = Fct.produit(m); break; default: break; } break; case 1: break; case 2: m = Fct.produit(m); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: m = Fct.somme(m); break; case 1: break; case 2: break; default: break; } break; default: switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: m = Fct.somme(m); break; case 1: break; case 2: m = Fct.produit(m); break; default: break; } break; } m.setSize(300,300); m.setLocation(0, 0); this.jPanel1.add(m); break; case 2: m = Fct.produit(this.entre1.getMat()); switch(this.algoPlace2.getAlgorithmAAppliquer()){ case 0: m = Fct.somme(m); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: break; case 1: m = Fct.trier(m); break; case 2: break; default: break; } break; case 1: m = Fct.trier(m); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: m = Fct.somme(m); break; case 1: break; case 2: break; default: break; } break; case 2: break; default: switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: m = Fct.somme(m); break; case 1: m = Fct.trier(m); break; case 2: break; default: break; } break; } m.setSize(300,300); m.setLocation(0, 0); this.jPanel1.add(m); break; default: switch(this.algoPlace2.getAlgorithmAAppliquer()){ case 0: m = Fct.somme(this.entre1.getMat()); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: break; case 1: m = Fct.trier(m); break; case 2: m = Fct.produit(m); break; default: break; } break; case 1: m = Fct.trier(this.entre1.getMat()); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: m = Fct.somme(m); break; case 1: break; case 2: m = Fct.produit(m); break; default: break; } break; case 2: m = Fct.produit(this.entre1.getMat()); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: m = Fct.somme(m); break; case 1: m = Fct.trier(m); break; case 2: break; default: break; } break; default : switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 0: m = Fct.somme(this.entre1.getMat()); break; case 1: m = Fct.trier(this.entre1.getMat()); break; case 2: m = Fct.produit(this.entre1.getMat()); break; default: break; } break; } m.setSize(300,300); m.setLocation(0, 0); this.jPanel1.add(m); break; } } if(Entre.getTypeDeDonnee()== 1){ a4.setVisible(true); a5.setVisible(true); a6.setVisible(true); this.jLabel3.setVisible(true); switch(this.algoPlace1.getAlgorithmAAppliquer()){ case 3: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.getGray(Entre.getImg())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace2.getAlgorithmAAppliquer()){ case 3: break; case 4: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.floue(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: break; case 4: break; case 5: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.redim(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; default: break; } break; case 5: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.redim(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: break; case 4: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.floue(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 5: break; default: break; } break; default: switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: break; case 4: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.floue(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 5: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.redim(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; default: break; } break; } jLabel3.setSize(300,300); jLabel3.setLocation(0, 0); this.jPanel1.add(jLabel3); break; case 4: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.floue(Entre.getImg())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace2.getAlgorithmAAppliquer()){ case 3: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.getGray(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: break; case 4: break; case 5: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.redim(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; default: break; } break; case 4: break; case 5: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.redim(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.getGray(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 4: break; case 5: break; default: break; } break; default: switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.getGray(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 4: break; case 5: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.redim(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; default: break; } break; } jLabel3.setSize(300,300); jLabel3.setLocation(0, 0); this.jPanel1.add(jLabel3); break; case 5: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.redim(Entre.getImg())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace2.getAlgorithmAAppliquer()){ case 3: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.getGray(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: break; case 4: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.floue(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 5: break; default: break; } break; case 4: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.floue(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.getGray(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 4: break; case 5: break; default: break; } break; case 5: break; default: switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.getGray(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 4: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.floue(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 5: break; default: break; } break; } jLabel3.setSize(300,300); jLabel3.setLocation(0, 0); this.jPanel1.add(jLabel3); break; default: switch(this.algoPlace2.getAlgorithmAAppliquer()){ case 3: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.getGray(Entre.getImg())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: break; case 4: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.floue(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 5: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.redim(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; default: break; } break; case 4: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.floue(Entre.getImg())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.getGray(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 4: break; case 5: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.redim(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; default: break; } break; case 5: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.redim(Entre.getImg())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.getGray(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 4: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.floue(this.jLabel3.getIcon())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 5: break; default: break; } break; default : switch(this.algoPlace4.getAlgorithmAAppliquer()){ case 3: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.getGray(Entre.getImg())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 4: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.floue(Entre.getImg())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; case 5: jLabel3.setIcon(new javax.swing.ImageIcon(((javax.swing.ImageIcon)Fct.redim(Entre.getImg())).getImage().getScaledInstance(300,300, java.awt.Image.SCALE_SMOOTH))); break; default: break; } break; } jLabel3.setSize(300,300); jLabel3.setLocation(0, 0); this.jPanel1.add(jLabel3); break; } } } /** * @param args the command line arguments */ public static void main(String args[]) { /* * Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* * If Nimbus (introduced in Java SE 6) is not available, stay with the * default look and feel. For details see * https://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } } catch (ClassNotFoundException ex) { java.util.logging.Logger.getLogger(test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (InstantiationException ex) { java.util.logging.Logger.getLogger(test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (IllegalAccessException ex) { java.util.logging.Logger.getLogger(test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } catch (javax.swing.UnsupportedLookAndFeelException ex) { java.util.logging.Logger.getLogger(test.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } //</editor-fold> /* * Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { new test().setVisible(true); } }); } // Variables declaration - do not modify private imad.AlgoPlace algoPlace1; private imad.AlgoPlace algoPlace2; private imad.AlgoPlace algoPlace3; private imad.AlgoPlace algoPlace4; private imad.Entre entre1; private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel3; private javax.swing.JLayeredPane jLayeredPane1; public static javax.swing.JPanel jPanel1; private imad.PrincipaleTable principaleTable1; // End of variables declaration Algo a1 = new Algo("somme",0); Algo a2 = new Algo("trier",1); Algo a3 = new Algo("produit",2); Algo a4 = new Algo("Noir et Blanc",3); Algo a5 = new Algo("luminosité",4); Algo a6 = new Algo("Pixel",5); // static Vector algos = new Vector(); Matrice m; //Matrice m = new Matrice(4,3); static int algorithmEnMain=-2; javax.swing.JLabel jLabel2 = new javax.swing.JLabel(); }