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
|
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Toolkit;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.UIManager;
import java.awt.event.*;
import javax.swing.JDesktopPane;
public class Main{
public static JFrame jFrame = null;
private JPanel jContentPane = null;
private JPanel jPanel = null;
public static JDesktopPane jDesktopPane = null;
/**
* This method initializes jFrame
*
* @return javax.swing.JFrame
*/
private JFrame getJFrame() {
if (jFrame == null) {
jFrame = new JFrame();
jFrame.setContentPane(getJContentPane());
java.awt.Dimension screend = Toolkit.getDefaultToolkit().getScreenSize();
jFrame.setSize((int)screend.getWidth(), (int)screend.getHeight());
jFrame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
jFrame.addWindowListener(new WindowListener(){
public void windowOpened(WindowEvent e){}
public void windowClosing(WindowEvent e){
Object[] options = {"Yes", "No", "Cancel"};
int n = javax.swing.JOptionPane.showOptionDialog(jFrame,
"Are you sure to quit ?",
"Quit",
javax.swing.JOptionPane.YES_NO_CANCEL_OPTION,
javax.swing.JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]);
if(n!=0){
jFrame.setDefaultCloseOperation(jFrame.DO_NOTHING_ON_CLOSE);
}
else
System.exit(0);
}
public void windowClosed(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowActivated(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
});
}
return jFrame;
}
/**
* This method initializes jContentPane
*
* @return javax.swing.JPanel
*/
private JPanel getJContentPane() {
if (jContentPane == null) {
jContentPane = new JPanel();
jContentPane.setLayout(new BorderLayout());
jContentPane.add(getJPanel(), java.awt.BorderLayout.CENTER);
}
return jContentPane;
}
/**
* This method initializes jPanel
*
* @return javax.swing.JPanel
*/
private JPanel getJPanel() {
if (jPanel == null) {
jPanel = new JPanel(new BorderLayout());
jPanel.add(getJDesktopPane(), BorderLayout.CENTER);
}
return jPanel;
}
public Main() {
//Create an object who contains all the text of the differents components in all languages
JFrame mainFrame = getJFrame();
mainFrame.setVisible(true);
}
private void Exit(ActionEvent evt){
Object[] options = {"Yes", "No", "Cancel"};
int n = javax.swing.JOptionPane.showOptionDialog(Main.jFrame,
"Are you sure to quit ?",
"Quit 2",
javax.swing.JOptionPane.YES_NO_CANCEL_OPTION,
javax.swing.JOptionPane.QUESTION_MESSAGE,
null,
options,
options[0]);
if(n==0)
System.exit(0);
}
/**
* This method initializes jDesktopPane
*
* @return javax.swing.JDesktopPane
*/
private JDesktopPane getJDesktopPane() {
if (jDesktopPane == null) {
jDesktopPane = new JDesktopPane();
try{
java.net.URL url = getClass().getResource("debian.png");
java.awt.image.BufferedImage image = javax.imageio.ImageIO.read(url);
jDesktopPane.setBorder(new CentredBackgroundBorder(image));
}
catch(java.net.MalformedURLException murle){ murle.printStackTrace(); }
catch(java.io.IOException ioe){ ioe.printStackTrace(); }
}
return jDesktopPane;
}
public static void main(String[] args) {
try {
UIManager.setLookAndFeel("com.sun.java.swing.plaf.metal.MetalLookAndFeel");
} catch (Exception e) { }
new Main();
}
} |
Partager