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 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.SwingUtilities;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JMenuItem;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JFrame;
import javax.swing.JButton;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
public class ApplicationMainFrame {
private JFrame jFrame = null; // @jve:decl-index=0:visual-constraint="60,93"
private JMenuBar jJMenuBar = null;
private JMenu fileMenu = null;
private JMenuItem exitMenuItem = null;
private JPanel jPanel = null;
private JButton jButton = null;
private JButton jButton1 = null;
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.gridx = 0;
gridBagConstraints1.insets = new Insets(24, 0, 0, 0);
gridBagConstraints1.anchor = GridBagConstraints.NORTH;
gridBagConstraints1.gridy = 1;
GridBagConstraints gridBagConstraints = new GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.insets = new Insets(0, 60, 0, 64);
gridBagConstraints.gridy = 0;
jPanel = new JPanel();
jPanel.setLayout(new GridBagLayout());
jPanel.add(getJButton(), gridBagConstraints);
jPanel.add(getJButton1(), gridBagConstraints1);
}
return jPanel;
}
/**
* This method initializes jButton
*
* @return javax.swing.JButton
*/
private JButton getJButton() {
if (jButton == null) {
jButton = new JButton();
jButton.setText("premiere action");
jButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e)
{
javax.swing.JFileChooser dialogue = new javax.swing.JFileChooser("C:\\");
MySequenceFileFilter dsff = new MySequenceFileFilter("Fichiers xml", ".xml");
dialogue.addChoosableFileFilter(dsff);
int resultat = dialogue.showSaveDialog(jButton);
if(resultat == JFileChooser.APPROVE_OPTION)
{
try
{
new MyAction (dialogue.getSelectedFile().toString());
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
});
}
return jButton;
}
/**
* This method initializes jButton1
*
* @return javax.swing.JButton
*/
private JButton getJButton1() {
if (jButton1 == null) {
jButton1 = new JButton();
jButton1.setText("la deuxieme");
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent e)
{
javax.swing.JFileChooser dialogue = new javax.swing.JFileChooser("C:\\");
MySequenceFileFilter dsff = new MySequenceFileFilter("Fichiers xml", ".xml");
dialogue.addChoosableFileFilter(dsff);
int resultat = dialogue.showSaveDialog(jButton);
if(resultat == JFileChooser.APPROVE_OPTION)
{
try
{
MyAction dsr = new MyAction(dialogue.getSelectedFile().toString());
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
});
}
return jButton1;
}
/**
* @param args
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ApplicationMainFrame application = new ApplicationMainFrame();
application.getJFrame().setVisible(true);
}
});
}
/**
* This method initializes jFrame
*
* @return javax.swing.JFrame
*/
private JFrame getJFrame() {
if (jFrame == null) {
jFrame = new JFrame();
jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jFrame.setJMenuBar(getJJMenuBar());
jFrame.setSize(300, 200);
jFrame.setTitle("Mon titre");
jFrame.setContentPane(getJPanel());
jFrame.setResizable(false);
}
return jFrame;
}
/**
* This method initializes jJMenuBar
*
* @return javax.swing.JMenuBar
*/
private JMenuBar getJJMenuBar() {
if (jJMenuBar == null) {
jJMenuBar = new JMenuBar();
jJMenuBar.add(getFileMenu());
}
return jJMenuBar;
}
/**
* This method initializes jMenu
*
* @return javax.swing.JMenu
*/
private JMenu getFileMenu() {
if (fileMenu == null) {
fileMenu = new JMenu();
fileMenu.setText("File");
fileMenu.add(getExitMenuItem());
}
return fileMenu;
}
/**
* This method initializes jMenuItem
*
* @return javax.swing.JMenuItem
*/
private JMenuItem getExitMenuItem() {
if (exitMenuItem == null) {
exitMenuItem = new JMenuItem();
exitMenuItem.setText("Exit");
exitMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
}
return exitMenuItem;
}
} |
Partager