package application; import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.filechooser.*; /** * Fenêtre pour charger des graphes */ public final class SelecteurFichiers extends JDialog implements ActionListener { //Main UI panel JPanel contentPane; JFileChooser jFileChooser1 = new JFileChooser(); //Construct the frame public SelecteurFichiers(CadrePrincipal parent) { super(parent); enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(parent); } catch (Exception e) { e.printStackTrace(); } } //Component initialization private void jbInit(CadrePrincipal parent) throws Exception { //Create main UI panel contentPane = (JPanel) this.getContentPane(); jFileChooser1.setBounds(new Rectangle(5, 5, 425, 245)); //Paramaetrage du chooser int returnVal = jFileChooser1.showOpenDialog(parent); if (returnVal == JFileChooser.APPROVE_OPTION) { parent.setFile(jFileChooser1.getSelectedFile().getCanonicalPath()); } contentPane.setLayout(null); this.setSize(new Dimension(500, 300)); this.setTitle("Card Layout Sample"); contentPane.add(jFileChooser1, null); } //Overridden so we can exit when window is closed protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { this.hide(); //System.exit(0); } } /** * Fermer le dialogue sur un événement bouton */ public void actionPerformed(ActionEvent e) { } }