Plusieurs action listener
oula je commence a saturé de swing , je comprend plus rien ......
Code:
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
| public Ouvrir() {
super("Module OPC"); //titre
setSize(450,100); //taille
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//fermeture
JScrollPane scrollPane = new JScrollPane(text,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
text.setEditable(false);
text.setBackground(Color.WHITE);
text.setLineWrap(true);
text.setAutoscrolls(true);
text.setWrapStyleWord(true);
text.setBorder(BorderFactory.createLoweredBevelBorder());
boutonOpen.addActionListener(this);//ajout d'un actionlistener
JPanel pane=new JPanel();
BorderLayout bord = new BorderLayout();
pane.setLayout(bord);
pane.add("Center",text);
pane.add("East", boutonOpen);
pane.add("South",boutonConfirm);
pane.setLayout(bord);
setContentPane(pane);
setVisible(true);
} |
Code:
1 2 3 4 5 6 7 8 9 10
| public static void main(String[] arguments) {
try{
UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel"); //windows classique :javax.swing.plaf.metal.MetalLookAndFeel
}
catch (Exception e)
{
}
@SuppressWarnings("unused")
Ouvrir index = new Ouvrir();
} |
Code:
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
| public void actionPerformed(ActionEvent evt) {
JFileChooser chooser = new JFileChooser(FileSystemView.getFileSystemView().getHomeDirectory());//création d'un nouveau filechosser
chooser.setMultiSelectionEnabled(true);
chooser.setApproveButtonText("Choix fichier(s)"); //intitulé du bouton
chooser.setToolTipText("Selection multpile possible");
chooser.setAcceptAllFileFilterUsed(false);
chooser.setDialogTitle("Ouvrir (Multi-sélection possible)");
ExampleFileFilter filter = new ExampleFileFilter("xml");
filter.setDescription("Xml Files");
chooser.addChoosableFileFilter(filter);
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION)
{
File selectionFichier[] = chooser.getSelectedFiles();
String fichier="";
for (int i=0,n=selectionFichier.length; i<n; i++) {
fichier=selectionFichier[i].getName()+"\n"+fichier;
StockerNomFichier(selectionFichier[i].getAbsolutePath());
}
text.setText(fichier);
}
}
} |
J'ai besoin que le bouton "boutonConfirm" envoi au click l'ArrayList qui a été crée par l'actionListener sur le bouton "boutonOpen" vers le main :arf: :arf: :arf: :arf:
J'ai vraipment pas d'idée sur ce coup , j'ai passé la journée a bidouillé sur le sujet
Merci d'avance ;)