// Path: src/main/java/net/openbyte/FileUtil.java
// public class FileUtil {
// 
//     /**
//      * Sets the content of the file via the format provided.
//      *
//      * @param format the format that the file with be formatted
//      * @param file the file that will be formatted
//      */
//     public static void format(String format, File file){
//         byte[] formatBytes = format.getBytes();
//         try {
//             FileOutputStream stream = new FileOutputStream(file);
//             stream.write(formatBytes);
//             stream.close();
//         } catch (Exception e){
//             e.printStackTrace();
//         }
//     }
// }
// 
// Path: src/main/java/net/openbyte/Formats.java
// public class Formats {
// 
//     /**
//      * Represents the regular class creation format.
//      *
//      * @param thePackage the package the class is in
//      * @param className the class name
//      * @return the format
//      */
//     public static String classFormat(String thePackage, String className){
//         String format = "package " + thePackage + ";" + " \n" + "public class " + className + " {" + " \n" + "}";
//         return format;
//     }
// 
//     /**
//      * Represents the java interface class format.
//      *
//      * @param thePackage the package the interface is in
//      * @param interfaceName the interface name
//      * @return the format
//      */
//     public static String interfaceFormat(String thePackage, String interfaceName) {
//         String format = "package " + thePackage + ";" + "\n" + "public interface " + interfaceName + " {" + "\n" + "}";
//         return format;
//     }
// }


import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.IOException;
import javax.swing.*;
import net.openbyte.FileUtil;
import net.openbyte.Formats;
            return;
        }
        String[] splittedName = textField1.getText().split("\\.");
        if(splittedName.length < 2){
            JOptionPane.showMessageDialog(this, "You need to put the class inside of a package to create a class.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(splittedName.length > 4){
            JOptionPane.showMessageDialog(this, "You cannot create a class inside of more than 3 packages.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(splittedName.length == 4){
            File mainPackageDir = new File(src, splittedName[0]);
            File secondPackageDir = new File(mainPackageDir, splittedName[1]);
            File thirdPackageDir = new File(secondPackageDir, splittedName[2]);
            File theClass = new File(thirdPackageDir, splittedName[3] + ".java");
            if(!mainPackageDir.exists()){
                mainPackageDir.mkdir();
            }
            if(!secondPackageDir.exists()){
                secondPackageDir.mkdir();
            }
            if(!theClass.exists()){
                try {
                    theClass.createNewFile();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
            setVisible(false);
// Path: src/main/java/net/openbyte/FileUtil.java
// public class FileUtil {
// 
//     /**
//      * Sets the content of the file via the format provided.
//      *
//      * @param format the format that the file with be formatted
//      * @param file the file that will be formatted
//      */
//     public static void format(String format, File file){
//         byte[] formatBytes = format.getBytes();
//         try {
//             FileOutputStream stream = new FileOutputStream(file);
//             stream.write(formatBytes);
//             stream.close();
//         } catch (Exception e){
//             e.printStackTrace();
//         }
//     }
// }
// 
// Path: src/main/java/net/openbyte/Formats.java
// public class Formats {
// 
//     /**
//      * Represents the regular class creation format.
//      *
//      * @param thePackage the package the class is in
//      * @param className the class name
//      * @return the format
//      */
//     public static String classFormat(String thePackage, String className){
//         String format = "package " + thePackage + ";" + " \n" + "public class " + className + " {" + " \n" + "}";
//         return format;
//     }
// 
//     /**
//      * Represents the java interface class format.
//      *
//      * @param thePackage the package the interface is in
//      * @param interfaceName the interface name
//      * @return the format
//      */
//     public static String interfaceFormat(String thePackage, String interfaceName) {
//         String format = "package " + thePackage + ";" + "\n" + "public interface " + interfaceName + " {" + "\n" + "}";
//         return format;
//     }
// }


// Path: src/main/java/net/openbyte/gui/ClassCreationFrame.java
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.io.IOException;
import javax.swing.*;
import net.openbyte.FileUtil;
import net.openbyte.Formats;

            return;
        }
        String[] splittedName = textField1.getText().split("\\.");
        if(splittedName.length < 2){
            JOptionPane.showMessageDialog(this, "You need to put the class inside of a package to create a class.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(splittedName.length > 4){
            JOptionPane.showMessageDialog(this, "You cannot create a class inside of more than 3 packages.", "Error", JOptionPane.ERROR_MESSAGE);
            return;
        }
        if(splittedName.length == 4){
            File mainPackageDir = new File(src, splittedName[0]);
            File secondPackageDir = new File(mainPackageDir, splittedName[1]);
            File thirdPackageDir = new File(secondPackageDir, splittedName[2]);
            File theClass = new File(thirdPackageDir, splittedName[3] + ".java");
            if(!mainPackageDir.exists()){
                mainPackageDir.mkdir();
            }
            if(!secondPackageDir.exists()){
                secondPackageDir.mkdir();
            }
            if(!theClass.exists()){
                try {
                    theClass.createNewFile();
                } catch (IOException e1) {
                    e1.printStackTrace();
                }
            }
            setVisible(false);
            tree.updateUI();