package synch;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Synch extends JPanel {
private JLabel targetLabel = new JLabel("Source");
private JLabel sourceLabel = new JLabel("Target");
private JButton browseButton = new JButton("Browse");
private JButton browseButton1 = new JButton("Browse");
private JButton copyButton = new JButton("Copy!");
private JTextField textField = new JTextField(" ");
private JTextField textField1 = new JTextField(" ");
private JFileChooser fc = new JFileChooser();
private JMenuItem Exit, oneWaySynch, twoWaySynch, Help, About, HelpMe;
public Synch(){
JFrame prog = new JFrame("Chris's file synchronization");
prog.setSize(600,350);
prog.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar jmb = new JMenuBar();
prog.setJMenuBar(jmb);
JMenu fileMenu = new JMenu("File");
jmb.add(fileMenu);
fileMenu.add(oneWaySynch = new JMenuItem(" One way Synch "));
fileMenu.add(twoWaySynch = new JMenuItem(" Two way Synch "));
fileMenu.add(Exit = new JMenuItem("Exit"));
JMenu helpMenu = new JMenu("Help");
jmb.add(helpMenu);
helpMenu.add(HelpMe = new JMenuItem("Help"));
helpMenu.add(About = new JMenuItem("About"));
GridLayout topPanel = new GridLayout(4,1);
prog.setLayout(topPanel);
JPanel P1 = new JPanel();
P1.add(targetLabel, FlowLayout.LEFT);
prog.add(P1);
P1.add(textField, FlowLayout.CENTER);
prog.add(P1);
textField.setPreferredSize(new Dimension(200,30));
P1.add(browseButton, FlowLayout.RIGHT);
prog.add(P1);
JPanel P2 = new JPanel();
P2.add(sourceLabel, FlowLayout.LEFT);
prog.add(P2);
P2.add(textField1, FlowLayout.CENTER);
textField1.setPreferredSize(new Dimension(200,30));
prog.add(P2);
P2.add(browseButton1, FlowLayout.RIGHT);
prog.add(P2);
JPanel P3 = new JPanel();
P3.add(fc, FlowLayout.LEFT);
;
prog.add(P3);
JPanel P4 = new JPanel();
P4.add(copyButton, FlowLayout.LEFT);
prog.add(P4);
Exit.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e){
exitMethod();
}
});
oneWaySynch.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e){
oneWayMethod();
}
});
twoWaySynch.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e){
twoWayMethod();
}
});
HelpMe.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e){
helpMethod();
}
});
About.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e){
aboutMethod();
}
});
browseButton.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e){
browseButtonMethod();
}
});
browseButton1.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e){
browseButton1Method();
}
});
copyButton.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e){
copyMethod();
}
});
prog.setVisible(true); //Display the window to the user!
} //end of method Synch()
public void exitMethod() {
if(JOptionPane.showConfirmDialog(null,"Are you sure you want it to close?", "Confirm Exit", JOptionPane.YES_NO_OPTION)==JOptionPane.YES_OPTION)
System.exit(0);
}
public void oneWayMethod() {
JOptionPane.showMessageDialog(null, "One way sync has been activated.");
}
public void twoWayMethod() {
JOptionPane.showMessageDialog(null, "Two way sync has been activated.");
}
public void aboutMethod() {
JOptionPane.showMessageDialog(null, "This is a file synchronization program, to speed things up, and over all make it easier for you.");
}
public void helpMethod() {
JOptionPane.showMessageDialog(null, "If you are needing assistance please contact me via email: egamespaypal@gmail.com or by phone 1-901-619-9413.");
}
public void browseButtonMethod() {
JOptionPane.showMessageDialog(null, "The browse button has been clicked!");
}
public void browseButton1Method() {
JOptionPane.showMessageDialog(null, "The browse button has been clicked!");
}
public void copyMethod() {
JOptionPane.showMessageDialog(null, "Copying has commenced, watch the magic happen!");
}
}