package testGraphique; import testGraphique.Graphique; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.*; import javax.swing.GroupLayout; import javax.swing.JButton; import javax.swing.JComponent; import javax.swing.JFileChooser; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.SwingUtilities; /** * This code was edited or generated using CloudGarden's Jigloo SWT/Swing GUI * Builder, which is free for non-commercial use. If Jigloo is being used * commercially (ie, by a corporation, company or business for any purpose * whatever) then you should purchase a license for each developer using Jigloo. * Please visit www.cloudgarden.com for details. Use of Jigloo implies * acceptance of these licensing terms. A COMMERCIAL LICENSE HAS NOT BEEN * PURCHASED FOR THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED LEGALLY FOR * ANY CORPORATE OR COMMERCIAL PURPOSE. */ public class GraphiquePontJFrame extends javax.swing.JFrame { { // Set Look & Feel try { javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName()); } catch (Exception e) { e.printStackTrace(); } } /** * */ private static final long serialVersionUID = 1L; private JButton ButtonOuvrir; private JFileChooser jFileChooser1; private JLabel jLabel1; private File fichier; private Graphique graphe; /** * Auto-generated main method to display this JFrame */ public static void main(String[] args) { SwingUtilities.invokeLater(new Runnable() { public void run() { GraphiquePontJFrame inst = new GraphiquePontJFrame(); inst.setLocationRelativeTo(null); inst.setVisible(true); } }); } public GraphiquePontJFrame() { super(); initGUI(); } private void initGUI() { try { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); GroupLayout thisLayout = new GroupLayout( (JComponent) getContentPane()); getContentPane().setLayout(thisLayout); this.setTitle("Accélération maquette de pont"); { ButtonOuvrir = new JButton(); ButtonOuvrir.setText("Ouvrir fichier"); ButtonOuvrir.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { try { ButtonOuvrirActionPerformed(evt); } catch (Exception e) { e.printStackTrace(); } } }); } { jLabel1 = new JLabel(); jLabel1.setText("Choisir fichier de mesure"); } thisLayout.setVerticalGroup(thisLayout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE) .addGap(17) .addComponent(ButtonOuvrir, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE) .addContainerGap(53, 53)); thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup() .addContainerGap(116, 116) .addGroup(thisLayout.createParallelGroup() .addComponent(jLabel1, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 133, GroupLayout.PREFERRED_SIZE) .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup() .addComponent(ButtonOuvrir, GroupLayout.PREFERRED_SIZE, 118, GroupLayout.PREFERRED_SIZE) .addGap(15))) .addContainerGap(124, 124)); { jFileChooser1 = new JFileChooser(); } pack(); this.setSize(381, 169); } catch (Exception e) { e.printStackTrace(); } } public JLabel getJLabel1() { return jLabel1; } public JButton getButtonOuvrir() { return ButtonOuvrir; } public JFileChooser getJFileChooser1() { return jFileChooser1; } private void ButtonOuvrirActionPerformed(ActionEvent evt) throws Exception { System.out.println("ButtonOuvrir.actionPerformed, event=" + evt); int returnval = jFileChooser1.showDialog(null, null); if (returnval == JFileChooser.APPROVE_OPTION) { fichier = jFileChooser1.getSelectedFile(); System.out.println(fichier.getName()); graphe=new Graphique(fichier); graphe.afficherGraphique(); } } }