package synch;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Synch extends JFrame {
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(500,300);
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"));
prog.setLayout(new GridLayout(4,1)); //declares the program to be in a 4,1 grid
JPanel Pane = new JPanel(); //creates the JPanel
Pane.add(targetLabel, FlowLayout.LEFT); //adds the target label on the left side
prog.add(Pane , new GridLayout(1,1)); //puts it in the 1,1 section of the grid
Pane.add(textField, FlowLayout.CENTER); //adds the text field in the center of the FlowLayout
prog.add(Pane, new GridLayout(1,1)); //puts it in 1,1 layout again
textField.setPreferredSize(new Dimension(200,30)); // sets the size of the text field
Pane.add(browseButton, FlowLayout.RIGHT); // makes the browse button the right side of the flow
prog.add(Pane, new GridLayout(1,1)); // puts it in 1,1
JPanel Pane2 = new JPanel(); // START OF PANE 2 WOOT!
Pane2.add(sourceLabel, FlowLayout.LEFT); //puts it in Flow
prog.add(Pane2 , new GridLayout(2,1)); //puts it on the 2nd column which it does not do??
Pane2.add(textField1, FlowLayout.CENTER);
textField1.setPreferredSize(new Dimension(200,30));
prog.add(Pane2 , new GridLayout(2,1));
Pane2.add(browseButton1, FlowLayout.RIGHT);
prog.add(Pane2 , new GridLayout(2,1));
JPanel Pane3 = new JPanel();
Pane3.add(fc, FlowLayout.LEFT); //THIS IS WHERE I NEED HELP :(
prog.add(Pane3, new GridLayout(3,1));
JPanel Pane4 = new JPanel();
Pane4.add(copyButton, FlowLayout.LEFT);
prog.add(Pane4, new GridLayout(4,1));
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!");
}
}