Jeroen Mathon - 2013-01-01

[The Anime and Manga Lab]
Always wanted to quickly save multiple Urls of your favourite youtube vids?
NOW YOU CAN WITH THE URL SAVER
Which allows you to save up to 5 Urls!
It then gives you the ability to save them to an file!
GULLY AUTOMATED NO INSTALLATION!!!!!1
Be sure to have Java installed!
Download at the Code 2 Gether link!!!

http://sourceforge.net/projects/code2gether/files/Applications/Java/Jeroen%20Mathon/Url%20Saver/Url%20Saver.jar/download


import java.awt.Desktop;
import java.awt.EventQueue;
import java.awt.Robot;

import javax.swing.JFrame;
import javax.swing.GroupLayout;
import javax.swing.JOptionPane;
import javax.swing.GroupLayout.Alignment;
import javax.swing.JTextField;
import javax.swing.JLabel;
import java.awt.Font;
import javax.swing.JButton;
import javax.swing.LayoutStyle.ComponentPlacement;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.JProgressBar;
import java.awt.Color;
import java.io.;
import java.util.
;

public class Core {
private String url1 = "Empty";
private String url2 = "Empty";
private String url3 = "Empty";
private String url4 = "Empty";
private String url5 = "Empty";
private JFrame frmUrlGatherer;
private static JTextField textField;
private static String url;
private int bcount = 0;
private String[] urls ={url1, url2, url3, url4, url5};
private int pvalue = 0;
JButton btnClearUrls = new JButton("Clear Urls");
JProgressBar progressBar = new JProgressBar();
private int num;
JButton btnDownloadName = new JButton("Download Name");
JLabel lblCopyrightsCode = new JLabel("Copyrights@ Code 2 Gether 2013");
JButton btnAdd = new JButton("Add");
private final JButton btnSaveToFile = new JButton("Save to File");
/*
* Launch the application.
/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {

        public void run() {
            try {
                Core window = new Core();
                window.frmUrlGatherer.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

/**
 * Create the application.
 */
public Core() {
    initialize();
}
/**
 * Initialize the contents of the frame.
 */
private void initialize() {
    frmUrlGatherer = new JFrame();
    frmUrlGatherer.setTitle("GET URL!");
    frmUrlGatherer.setResizable(false);
    frmUrlGatherer.setBounds(100, 100, 700, 280);
    frmUrlGatherer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    textField = new JTextField();
    textField.setColumns(10);
    //Label Website

    JLabel lblPleaseEnterThe = new JLabel("Please Enter the Websites Url here!");
    lblPleaseEnterThe.setFont(new Font("Arial Black", Font.BOLD, 25));

    //Button btnDownloadName

    JButton btnDownloadName = new JButton("Show Saved");
    btnDownloadName.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {

        JOptionPane.showMessageDialog(null, "Saved url's MAX 5! \n" + url1 + "\n" + url2 + "\n" + url3 + "\n" + url4 + "\n" + url5);
        }

    });

    //Add button
    btnAdd.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
        bcount = bcount + 1;
        if(bcount == 1){
            url1 = textField.getText();
        }else if(bcount == 2){
            url2 = textField.getText();
        }else if(bcount == 3){
            url3 = textField.getText();
        }else if(bcount == 4){
            url4 = textField.getText();
        }else if(bcount == 5){
            url5 = textField.getText();

            btnAdd.setEnabled(false);
            JOptionPane.showMessageDialog(null, "You have reached the maximum ammount of saved urls!");
        }       
        pvalue = pvalue + 20;
        progressBar.setValue(pvalue);
        textField.setText("");
        }
    });

    //Clear urls Button
    btnClearUrls.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent arg0) {
         url1 = "0";
         url2 = "0";
         url3 = "0";
         url4 = "0";
         url5 = "0";
        bcount = 0;
        btnAdd.setEnabled(true);
        progressBar.setValue(0);
        pvalue = 0;
        ;
        }
    });
    progressBar.setStringPainted(true);

    //proccess bar
    progressBar.setForeground(Color.RED);

    JLabel lblCapacity = new JLabel("Capacity:");
    lblCapacity.setFont(new Font("Arial Black", Font.BOLD, 14));

    //Copyrights Disclamer
    GroupLayout groupLayout = new GroupLayout(frmUrlGatherer.getContentPane());
    groupLayout.setHorizontalGroup(
        groupLayout.createParallelGroup(Alignment.TRAILING)
            .addGroup(groupLayout.createSequentialGroup()
                .addGap(23)
                .addComponent(textField, GroupLayout.DEFAULT_SIZE, 669, Short.MAX_VALUE)
                .addGap(18))
            .addGroup(groupLayout.createSequentialGroup()
                .addGap(93)
                .addComponent(lblPleaseEnterThe)
                .addContainerGap(96, Short.MAX_VALUE))
            .addGroup(Alignment.LEADING, groupLayout.createSequentialGroup()
                .addGap(199)
                .addComponent(btnAdd)
                .addPreferredGap(ComponentPlacement.RELATED)
                .addComponent(btnDownloadName)
                .addGap(18)
                .addComponent(btnSaveToFile)
                .addContainerGap(256, Short.MAX_VALUE))
            .addGroup(groupLayout.createSequentialGroup()
                .addContainerGap(146, Short.MAX_VALUE)
                .addComponent(lblCapacity)
                .addPreferredGap(ComponentPlacement.UNRELATED)
                .addComponent(progressBar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addGap(38)
                .addComponent(btnClearUrls)
                .addGap(38)
                .addComponent(lblCopyrightsCode)
                .addContainerGap())
    );
    groupLayout.setVerticalGroup(
        groupLayout.createParallelGroup(Alignment.LEADING)
            .addGroup(groupLayout.createSequentialGroup()
                .addGap(37)
                .addComponent(lblPleaseEnterThe)
                .addGap(56)
                .addComponent(textField, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(ComponentPlacement.RELATED, 80, Short.MAX_VALUE)
                .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
                    .addComponent(btnDownloadName)
                    .addComponent(btnAdd)
                    .addComponent(btnSaveToFile))
                .addGroup(groupLayout.createParallelGroup(Alignment.LEADING)
                    .addGroup(groupLayout.createSequentialGroup()
                        .addGap(24)
                        .addComponent(lblCopyrightsCode))
                    .addGroup(groupLayout.createSequentialGroup()
                        .addPreferredGap(ComponentPlacement.UNRELATED)
                        .addGroup(groupLayout.createParallelGroup(Alignment.TRAILING)
                            .addComponent(lblCapacity)
                            .addGroup(groupLayout.createParallelGroup(Alignment.BASELINE)
                                .addComponent(progressBar, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
                                .addComponent(btnClearUrls)))))
                .addContainerGap())
    );
    btnSaveToFile.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

             try{
                  // Create file 
                  FileWriter fstream = new FileWriter("c://websites.txt");
                  BufferedWriter out = new BufferedWriter(fstream);
                  out.write("Websites ");
                  out.newLine();
                  out.write(url1);
                  out.newLine();
                  out.write(url2);
                  out.newLine();
                  out.write(url3);
                  out.newLine();
                  out.write(url4);
                  out.newLine();
                  out.write(url5);
                   //Close the output stream
                  out.close();
                  }catch (Exception e1){//Catch exception if any
                  System.err.println("Error: " + e1.getMessage());
                  }
             try {
                Desktop.getDesktop().open(new File("c:\\websites.txt"));
            } catch (IOException e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
            JOptionPane.showMessageDialog(null, "Files saved in your C:\\ Drive");

        }
    });
    frmUrlGatherer.getContentPane().setLayout(groupLayout);
}

}