public static void main(final String args[]) {
// copy certificate file from jar.
final ProxyUIStarter proxyUIStarter = new ProxyUIStarter();
final InputStream is = proxyUIStarter.getClass().getResourceAsStream(
"/ProxyCertificate.ser");
proxyUIStarter.copyFile(proxyUIStarter, is);
final String currentDir = new File("").getAbsolutePath();
final File file = new File(currentDir + File.separator
+ "ProxyConfig.dat");
if (!file.exists())
{
ProxyUIStarter.showSettings();
}
else
{
final Settings getvalues = new Settings();
getvalues.updateField();
authorize tc = new authorize();
tc.authorizeing();
}
final String cerfile = currentDir + File.separator
+ "ProxyCertificate.ser";
try {
final PrintStream stdout = new PrintStream(new FileOutputStream(
ProxyConstants.LOG_FILE));
System.setOut(stdout);
} catch (final FileNotFoundException e) {
final String currentDir1 = new File("").getAbsolutePath();
JOptionPane.showMessageDialog(null,
"Could not access LOG file in : " + currentDir1
+ File.separator + "ProxyLog.txt", "Message",
JOptionPane.ERROR_MESSAGE);
}
uiuser();
}
public static void uiuser ()
{
final JFrame jd = new JFrame();
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final Dimension screenSize = toolkit.getScreenSize();
final int x = (screenSize.width - jd.getWidth()) / 2;
final int y = (screenSize.height - jd.getHeight()) / 2;
final JPanel panel = new JPanel(new GridLayout(5, 1));
jd.addWindowListener(new MyWindowListener());
jd.setTitle("Coded by @amir");
jd.setLocation(100, 100);
jd.setSize(300, 200);
final JButton jb1 = new JButton("شروع");
final JButton jb2 = new JButton("تنظیمات");
final JButton jb3 = new JButton("توقف");
final JButton jb4 = new JButton("درباره");
final JButton jb5 = new JButton();
if(ProxyConstants.sessionid.equals("0"))
{
jb1.setEnabled(false);
}
else
{
JFrame frame;
frame = new JFrame();
frame.setSize(200, 100);
JOptionPane.showMessageDialog(frame,"hey", "پیام سیستم", JOptionPane.PLAIN_MESSAGE);
jb1.setEnabled(true);
}
jb1.addActionListener(new ButtonListener(jb1, jd, jb5, jb2));
jb2.addActionListener(new ButtonListener(jb2, jd, jb5, jb2));
jb3.addActionListener(new ButtonListener(jb3, jd, jb5, jb2));
jb4.addActionListener(new ButtonListener(jb4, jd, jb5, jb2));
panel.add(jb1);
panel.add(jb2);
panel.add(jb3);
panel.add(jb4);
panel.add(jb5);
jd.add(panel);
jd.show();
}
public static void showSettings() {
final Toolkit toolkit = Toolkit.getDefaultToolkit();
final Dimension screenSize = toolkit.getScreenSize();
final Settings frame = new Settings();
final int x = (screenSize.width - frame.getWidth()) / 2;
final int y = (screenSize.height - frame.getHeight()) / 2;
frame.setLocation(100, 100);
frame.setSize(500, 500);
frame.show();
}
}
class ButtonListener implements ActionListener {
JButton jb;
JButton jb5;
JButton jb2;
JFrame jf;
ButtonListener(final JButton jb, JFrame jf, JButton jb5, JButton jb2) {
this.jb = jb;
this.jf = jf;
this.jb5 = jb5;
this.jb2 = jb2;
}