unit fun_1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, SynEdit, FileUtil;


 procedure shablon_fx();
 procedure input_output();
 procedure shablon_swing();
 procedure shablon_console();
 procedure shablon_applet();
 procedure jar_win();
 procedure console_cr_win();
 procedure console_cr_win_exe();
 procedure console_cr_fx_win();
 function Str_Char_Del(str: String; ch: Char): String;
 function Name_Package(str1: String): String;
 function Name_Package_Dir(str: String): String;
 procedure Name_Package_Create_Dir(str: String);
 function Find_Package(SynEdit1: TSynEdit): Integer;
 function rep(java_home: String):String;
 function First_Package_Word(str: String): String;
 procedure console_cr_win_fx_exe();
 function ReadClassName(SynEditN:TSynEdit):String;



implementation
uses
  Unit1, Unit2;


function ReadClassName(SynEditN:TSynEdit):String;
var p_n, i, l : Integer;
    class_name1:String;
 begin
  class_name1:='';
  p_n:=pos('class', SynEditN.Lines.Text);
  if p_n>0 then
   begin
    for i := (p_n + 6) to Length(SynEditN.Lines.Text) do
     begin
      if SynEditN.Lines.Text[i]<>' '  then
       begin
        class_name1:=class_name1 + SynEditN.Lines.Text[i]
       end
      else
      begin
       if class_name1<>'' then break;
      end;
    end;
   end;
   l:= Length(class_name1);
   if pos('{', class_name1)>0 then  class_name1:=copy(class_name1, 0, pos('{', class_name1)-1);
   ReadClassName:= class_name1;
 end;


function First_Package_Word(str: String): String;
var word, str0: String;
    p: Integer;
begin
str0:=str;
p:= LastDelimiter('.',str0);
while  p>0 do
 begin
    word := copy(str0, 0, p-1);
    str0:= word;
    p:= LastDelimiter('.',str0);
 end;
      First_Package_Word:= str0;
end;



function rep(java_home: String):String;
var java_home_new: String;
    len, i: Integer;
begin
  java_home_new:='';
  len:= length(java_home);
  for i := 1 to len do
      begin
        if java_home[i] = '\' then java_home_new:= java_home_new + java_home[i] + '\'
          else java_home_new:= java_home_new + java_home[i];
      end;
  rep:=java_home_new;
end;


function Find_Package(SynEdit1: TSynEdit): Integer;
var i, se_len, p_n: Integer;
begin
 p_n:=0;
 se_len:= SynEdit1.Lines.Count;
 for i := 0 to se_len-1 do
     begin
          if pos('package', SynEdit1.Lines.Strings[i])>0 then
          begin
           p_n:=i;
           break;
          end;
     end;
  Find_Package:=p_n;
end;


 procedure Name_Package_Create_Dir(str: String);
var str1: string;
    z, p, len: integer;
    list: TStringList;
begin
 str1:=str;
 list := TStringList.Create;
 while LastDelimiter('.',str1)>0 do
  begin
     p:= LastDelimiter('.',str1);
     len:= Length(str1);
     list.add(copy(str1, p+1, len));
     str1:=copy(str1, 0, p-1);
  end;
  list.add(str1);
  for z:=list.count-1 downto 0 do
  begin
    If Not DirectoryExists(list.strings[z]) then CreateDir (list.strings[z]);
        chdir(list.strings[z]);
  end;
  list.Destroy;
end;


  function Name_Package_Dir(str: String): String;
  var str0: String;
      p: Integer;
  begin
  str0:=str;
  while LastDelimiter('.',str0)>0 do
   begin
      p:= LastDelimiter('.',str0);
      str0[p]:='\';
   end;
	Name_Package_Dir:= str0;
  end;




function Name_Package(str1: String): String;
var str_return, s2: String;
    p_n: Integer;
begin
  str_return:= str1;
  p_n:=pos('package', str_return);
  if p_n>0 then
   begin
    if pos('//', str_return)> 0 then Name_Package:= ''
    else
     begin
      s2 := copy(str_return, p_n+7, Length(str_return));
      s2:= Str_Char_Del(s2, ' ');
      s2:= Str_Char_Del(s2, ';');
      Name_Package:=s2;
     end
   end
  else Name_Package:= '';
end;


// Удаление из стоки str всех символов заданых в параметре ch
function Str_Char_Del(str: String; ch: Char): String;
var str_return: String;
begin
    str_return:= str;
    while pos(ch, str_return)<>0 do
      begin
       Delete(str_return,pos(ch, str_return),1);
      end;
    Str_Char_Del:= str_return;
end;





procedure jar_win();
var sss, jarstr, dop, FileJarName :String;
    i, n:  integer;
begin
      Form1.ProcessUTF8_3.Parameters.Clear;
      ChDir(ExtractFileDir(fullFileName));
     FileName := ExtractFileName(fullFileName);
     if FileExists('file_dir.ini') then Form2.ListBox1.Items.LoadFromFile('file_dir.ini');
     Form1.SynEdit1.Lines.SaveToFile(fullFileName);
     list := TStringList.Create;
     FileJarName:=Copy(FileName,1,Length(FileName)-5);
     pak:= Name_Package(Form1.SynEdit1.Lines.Strings[Find_Package(Form1.SynEdit1)]);
      if pak <> '' then
         begin
              sss := 'main-class: ' + pak + '.' + FileJarName;
              list.Clear;
              list.Add(sss);
              list.Add('');
              list.SaveToFile('MYMANIFEST.MF');
              list.Destroy;
              if  Form1.DirJDK <> '' then
                 begin
                  jarstr := Form1.DirJDK + st_bin +'jar' + ' -cvfm '+ FileJarName + '.jar' +' MYMANIFEST.MF ' + First_Package_Word(pak);
                  Form1.ProcessUTF8_3.Executable:=Form1.DirJDK+ st_bin +'jar';
                 end
              else
              begin
                jarstr := 'jar' + ' -cvfm '+ FileJarName + '.jar' +' MYMANIFEST.MF ' + First_Package_Word(pak);
                Form1.ProcessUTF8_3.Executable:='jar';
              end;
              Form1.ProcessUTF8_3.Parameters.Add('-cvfm');
              Form1.ProcessUTF8_3.Parameters.Add(FileJarName + '.jar');
              Form1.ProcessUTF8_3.Parameters.Add('MYMANIFEST.MF');
              Form1.ProcessUTF8_3.Parameters.Add(First_Package_Word(pak));
         end
      else
          begin

               sss := 'main-class: ' + FileJarName;
               list.Clear;
               list.Add(sss);
               list.Add('');
               list.SaveToFile('MYMANIFEST.MF');
               list.Destroy;
               if  Form1.DirJDK <> '' then
                 begin
                   jarstr := Form1.DirJDK+ st_bin +'jar' + ' -cvfm '+ FileJarName + '.jar' +' MYMANIFEST.MF ' + '*.class ';
                   Form1.ProcessUTF8_3.Executable:=Form1.DirJDK+ st_bin +'jar';
                 end
               else
               begin
                  jarstr := 'jar' + ' -cvfm '+ FileJarName + '.jar' +' MYMANIFEST.MF ' + '*.class ';
                  Form1.ProcessUTF8_3.Executable:='jar';
               end;

              Form1.ProcessUTF8_3.Parameters.Add('-cvfm');
              Form1.ProcessUTF8_3.Parameters.Add(FileJarName + '.jar');
              Form1.ProcessUTF8_3.Parameters.Add('MYMANIFEST.MF');
              Form1.ProcessUTF8_3.Parameters.Add('*.class');

          end;


    Form1.Memo1.Clear;
    Form1.Memo1.Text:= jarstr;

  n:= Form2.ListBox1.Count;
  dop:='';
  if n>=0 then
     begin
         for i := 0 to n-1 do
         begin
              dop:= Form2.ListBox1.Items.Strings[i];
              Form1.ProcessUTF8_3.Parameters.Add(dop);
              Form1.Memo1.Text:= Form1.Memo1.Text + ' ' + dop;
         end;
     end;


  Form1.ProcessUTF8_3.Execute;




end;






procedure shablon_applet();
 var str: String;
begin
  Form1.SynEdit1.Lines.Clear;
  str:='//Шаблон ';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('/*');
  Form1.SynEdit1.Lines.add(' Пример Базового Java-Апплета');
  Form1.SynEdit1.Lines.add('*/');
  Form1.SynEdit1.Lines.add(' ');
  Form1.SynEdit1.Lines.add('import java.applet.Applet;');
  Form1.SynEdit1.Lines.add('import java.awt.Graphics;');
  Form1.SynEdit1.Lines.add('');
  Form1.SynEdit1.Lines.add('/*');
  Form1.SynEdit1.Lines.add(' <applet code = "BasicAppletExample" width = 400 height = 200>');
  Form1.SynEdit1.Lines.add(' </applet>');
  Form1.SynEdit1.Lines.add('*/');
  Form1.SynEdit1.Lines.add('');
  Form1.SynEdit1.Lines.add('public class BasicAppletExample extends Applet{');
  Form1.SynEdit1.Lines.add(' public void paint(Graphics g){');
  Form1.SynEdit1.Lines.add('  g.drawString("This is my First Applet",20,100);');
  Form1.SynEdit1.Lines.add(' }');
  Form1.SynEdit1.Lines.add('}');
end;


procedure console_cr_fx_win();
 var sss, param, FileExeName :String;
begin
    Form1.SynEdit1.Lines.SaveToFile(fullFileName);
    ChDir(ExtractFileDir(fullFileName));
    FileName := ExtractFileName(fullFileName);
    Form1.Caption:=fullFileName;
    FileExeName:=Copy(FileName,1,Length(FileName)-5);
    //if FileExists(FileExeName + '.class') then DeleteFile(FileExeName + '.class');
    pak:= Name_Package(Form1.SynEdit1.Lines.Strings[Find_Package(Form1.SynEdit1)]);
    //if DirectoryExists(First_Package_Word(pak)) then DeleteDirectory(First_Package_Word(pak), False);
    param :='';
    if pak <> '' then
       begin
            sss:=pak + '.' + FileExeName;
            param :='-d ./';
       end
    else
        begin
             sss:= FileExeName;
        end;


     list := TStringList.Create;
     list.Clear;
     list.Add('echo off');
     list.Add('chcp 65001');
     list.Add('');
     //list.Add('set mainclass=' + FileName);
     list.Add('set path="' + Form1.DirJDK + st_bin + '";%path%');
     //list.Add('set PATH_TO_FX="' + DirFX + st_lib + '"');
     list.Add('set modules="javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web"');
     list.Add('');
     list.Add('echo ------------------------Версия javac-----------');
     list.Add('echo. ');
     list.Add('javac ' + '-version ');
     list.Add('echo.');
     list.Add('echo ----------------------------------------------- ');
     list.Add('echo ------------------------compiling program----------- ');
     list.Add('echo. ');
     list.Add('javac ' + param + ' -encoding utf8 --module-path %PATH_TO_FX% --add-modules %modules% '  + '*.java');   //FileName
     list.Add('echo. ');
     list.Add('echo -----------------------------------------------');
     list.Add('echo.');
     list.Add('echo ------------------------Версия java----------- ');
     list.Add('echo. ');
     list.Add('java ' + '-version ');
     list.Add('echo. ');
     list.Add('echo ----------------------------------------------- ');
     list.Add('echo. ');
     list.Add('echo ------------------------run java program--------------');
     list.Add('echo. ');

     list.Add('java --module-path %PATH_TO_FX% --add-modules %modules% ' + sss);
     list.Add('echo. ');
     list.Add('echo ------------------------end java program--------------');
     list.Add('echo. ');
     list.Add('pause');
     list.SaveToFile(file_con_fx);
     list.Destroy;
end;




procedure console_cr_win();
 var sss, FileExeName, param: String;
begin
    Form1.SynEdit1.Lines.SaveToFile(fullFileName);
    ChDir(ExtractFileDir(fullFileName));
    FileName := ExtractFileName(fullFileName);
    FileExeName:=Copy(FileName,1,Length(FileName)-5);
    //if FileExists(FileExeName + '.class') then DeleteFile(FileExeName + '.class');
    pak:= Name_Package(Form1.SynEdit1.Lines.Strings[Find_Package(Form1.SynEdit1)]);
    //if DirectoryExists(First_Package_Word(pak)) then DeleteDirectory(First_Package_Word(pak), False);
    param :='';
    if pak <> '' then
       begin
            sss:=pak + '.' + FileExeName;
            param :='-d ./';
       end
    else
        begin
             sss:= FileExeName;
        end;


     list := TStringList.Create;
     list.Clear;
     list.Add('echo off');
     list.Add('chcp 65001');
     list.Add('');
     //list.Add('set mainclass=' + FileExeName);
     list.Add('set path="' + Form1.DirJDK + st_bin + '";%path%');
     list.Add('');
     list.Add('echo ------------------------Версия javac-----------');
     list.Add('echo. ');
     list.Add('javac ' + '-version ');
     list.Add('echo.');
     list.Add('echo ----------------------------------------------- ');
     list.Add('echo ------------------------Компиляция программы----------- ');
     list.Add('echo. ');
     list.Add('javac ' + param + ' -encoding utf8 ' + FileName);
     list.Add('echo. ');
     list.Add('echo -----------------------------------------------');
     list.Add('echo.');
     list.Add('echo ------------------------Версия java----------- ');
     list.Add('echo. ');
     list.Add('java ' + '-version ');
     list.Add('echo. ');
     list.Add('echo ----------------------------------------------- ');
     list.Add('echo. ');
     list.Add('echo ------------------------Запуск java программы--------------');
     list.Add('echo. ');

     list.Add('java ' + sss);
     list.Add('echo. ');
     list.Add('echo ------------------------Завершение java программы--------------');
     list.Add('echo. ');
     list.Add('pause');
     list.SaveToFile(file_con);
     list.Destroy;
end;

procedure console_cr_win_exe();
 var sss, pak, FileExeName: String;
begin
    sss:='';
    Form1.SynEdit1.Lines.SaveToFile(fullFileName);
    ChDir(ExtractFileDir(fullFileName));
    FileName := ExtractFileName(fullFileName);
    FileExeName:=Copy(FileName,1,Length(FileName)-5);
    pak:= Name_Package(Form1.SynEdit1.Lines.Strings[Find_Package(Form1.SynEdit1)]);
    Form1.Caption:=FileExeName;
    if pak <> '' then
         begin
              sss:=java_exe + ' ' + pak + '.' + FileExeName;   //+ ' -cp ' + ExtractFileDir(fullFileName)
         end
    else
         begin
             sss:=java_exe + ' ' + FileExeName;               //+ ' -cp ' + ExtractFileDir(fullFileName)
         end;
     list := TStringList.Create;
     list.Clear;
     list.Add('echo off');
     list.Add('chcp 65001');
     list.Add('set path="' + Form1.DirJDK + st_bin + '";%path%');
     list.Add('');
     list.Add('echo. ');
     list.Add('echo -----------------------------------------------');
     list.Add('echo.');
     list.Add('echo ------------------------Версия java----------- ');
     list.Add('echo. ');
     list.Add(java_exe + ' -version ');
     list.Add('echo. ');
     list.Add('echo ----------------------------------------------- ');
     list.Add('echo. ');
     list.Add('echo ------------------------Запуск java программы--------------');
     list.Add('echo. ');

     list.Add(sss);
     list.Add('echo. ');
     list.Add('echo ------------------------Завершение java программы--------------');
     list.Add('echo. ');
     list.Add('pause');
     list.SaveToFile(file_con_exe);
     list.Destroy;
end;



procedure console_cr_win_fx_exe();
 var sss, pak, FileExeName: String;
begin
    Form1.SynEdit1.Lines.SaveToFile(fullFileName);
    ChDir(ExtractFileDir(fullFileName));
    FileName := ExtractFileName(fullFileName);
    FileExeName:=Copy(FileName,1,Length(FileName)-5);
    pak:= Name_Package(Form1.SynEdit1.Lines.Strings[Find_Package(Form1.SynEdit1)]);
    Form1.Caption:=FileExeName;
    if pak <> '' then
       begin
            sss:=pak + '.' + FileExeName;
       end
    else
        begin
             sss:= FileExeName;
        end;

     list := TStringList.Create;
     list.Clear;
     list.Add('echo off');
     list.Add('chcp 65001');
     list.Add('');
     list.Add('set mainclass=' + FileName);
     list.Add('set path="' + Form1.DirJDK + st_bin + '";%path%');
     list.Add('set PATH_TO_FX="' + Form1.DirJDK + st_lib + '"');
     list.Add('set modules="javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web"');
     list.Add('echo. ');
     list.Add('echo -----------------------------------------------');
     list.Add('echo.');
     list.Add('echo ------------------------java version----------- ');
     list.Add('echo. ');
     list.Add('java ' + '-version ');
     list.Add('echo. ');
     list.Add('echo ----------------------------------------------- ');
     list.Add('echo. ');
     list.Add('echo ------------------------run java program--------------');
     list.Add('echo. ');
     list.Add('java --module-path %PATH_TO_FX% --add-modules %modules% ' + sss);
     list.Add('echo. ');
     list.Add('echo ------------------------end java program--------------');
     list.Add('echo. ');
     list.Add('pause');
     list.SaveToFile(file_con_exe_fx);
     list.Destroy;
end;



procedure shablon_console();
 var str: String;
begin
  Form1.SynEdit1.Lines.Clear;
  str:='//Шаблон ';
  Form1.SynEdit1.Lines.add(str);
  str:='import java.util.Scanner; ';
  Form1.SynEdit1.Lines.add(str);
  str:='public class Shablon {';
  Form1.SynEdit1.Lines.add(str);
  str:='   public static void main(String[] args){';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('');
  str:='      //Ваш код ';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('      System.out.println("Шаблон программы!");');
  str:='      //Остановка закрытия окна ';
  Form1.SynEdit1.Lines.add(str);
  str:='      Scanner s = new Scanner(System.in);';
  Form1.SynEdit1.Lines.add(str);
  str:='      s.nextLine();';
  Form1.SynEdit1.Lines.add(str);
  str:='   } ';
  Form1.SynEdit1.Lines.add(str);
  str:='}';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('');
 end;



 procedure shablon_swing();
 var str: String;
begin
 Form1.SynEdit1.Lines.Clear;
  str:='//Шаблон ';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('  import javax.swing.*;');
  Form1.SynEdit1.Lines.add('import java.awt.*;');
  Form1.SynEdit1.Lines.add('class HelloWorldGUI { ');
   Form1.SynEdit1.Lines.add( '  private static void createAndShowGUI() {');
    Form1.SynEdit1.Lines.add('      JFrame frame = new JFrame("HelloWorldGUI");');
    Form1.SynEdit1.Lines.add('		frame.setSize(150,200); ');
    Form1.SynEdit1.Lines.add('		frame.setLocation(150,150); ');
    Form1.SynEdit1.Lines.add('        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); ');
     Form1.SynEdit1.Lines.add('       frame.setLayout (new FlowLayout(FlowLayout.CENTER)); ');
     Form1.SynEdit1.Lines.add('        JLabel label0 = new JLabel("Привет народ!!!");');
     Form1.SynEdit1.Lines.add('        JLabel label = new JLabel("HelloWorldGUI"); ');
     Form1.SynEdit1.Lines.add('       frame.add(label0);');
     Form1.SynEdit1.Lines.add('        frame.add(label); ');
     Form1.SynEdit1.Lines.add('                   ');
     Form1.SynEdit1.Lines.add('                   ');
     Form1.SynEdit1.Lines.add('        frame.setVisible(true); ');
     Form1.SynEdit1.Lines.add('    }              ');
     Form1.SynEdit1.Lines.add('                   ');
     Form1.SynEdit1.Lines.add('   public static void main(String[] args) { ');
     Form1.SynEdit1.Lines.add('                       ');
     Form1.SynEdit1.Lines.add('       javax.swing.SwingUtilities.invokeLater(new Runnable() { ');
     Form1.SynEdit1.Lines.add('           public void run() {     ');
     Form1.SynEdit1.Lines.add('                createAndShowGUI();  ');
     Form1.SynEdit1.Lines.add('            }   ');
     Form1.SynEdit1.Lines.add('        });     ');
     Form1.SynEdit1.Lines.add('    }           ');
     Form1.SynEdit1.Lines.add('}                ');
  Form1.SynEdit1.Lines.add('');

 end;


procedure input_output();
 var str: String;
begin
 Form1.SynEdit1.Lines.Clear;
  str:='//Требуется сложить два целых числа А и В. ';
  Form1.SynEdit1.Lines.add(str);
  Form1.SynEdit1.Lines.add('');
  Form1.SynEdit1.Lines.add('import java.util.*;');
  Form1.SynEdit1.Lines.add('import java.io.*;');
  Form1.SynEdit1.Lines.add('');
  Form1.SynEdit1.Lines.add('public class Main  {');
  Form1.SynEdit1.Lines.add('    PrintWriter pw;');
  Form1.SynEdit1.Lines.add('    Scanner sc;');
  Form1.SynEdit1.Lines.add('    public static void main(String[] args) throws FileNotFoundException { ');
  Form1.SynEdit1.Lines.add('        new Main().run();');
  Form1.SynEdit1.Lines.add('    }');
  Form1.SynEdit1.Lines.add('    public  void run() throws FileNotFoundException {');
  Form1.SynEdit1.Lines.add('        sc = new Scanner( new File("input.txt"));');
  Form1.SynEdit1.Lines.add(' ');
  Form1.SynEdit1.Lines.add('        int a = sc.nextInt();');
  Form1.SynEdit1.Lines.add('        int b = sc.nextInt(); ');
  Form1.SynEdit1.Lines.add('        int c = a + b;');
  Form1.SynEdit1.Lines.add('        String sss = "" + c;');
  Form1.SynEdit1.Lines.add(' ');
  Form1.SynEdit1.Lines.add('        pw = new PrintWriter(new File("output.txt"));');
  Form1.SynEdit1.Lines.add('        pw.println(sss); ');
  Form1.SynEdit1.Lines.add('        pw.close();');
  Form1.SynEdit1.Lines.add('    } ');
  Form1.SynEdit1.Lines.add('} ');
 end;



procedure shablon_fx();
var str: String;
begin
 Form1.SynEdit1.Lines.Clear;
 str:='//Шаблон ';
 Form1.SynEdit1.Lines.add(str);
 Form1.SynEdit1.Lines.add('import javafx.application.Application; ');
 Form1.SynEdit1.Lines.add('import javafx.geometry.Pos; ');
 Form1.SynEdit1.Lines.add('import javafx.scene.Scene;  ');
 Form1.SynEdit1.Lines.add('import javafx.scene.control.Label; ');
 Form1.SynEdit1.Lines.add('import javafx.stage.Stage;');
 Form1.SynEdit1.Lines.add(' ');
 Form1.SynEdit1.Lines.add('public class HelloWorldApplicationFX extends Application { ');
 Form1.SynEdit1.Lines.add(' ');
 Form1.SynEdit1.Lines.add('    @Override ');
 Form1.SynEdit1.Lines.add('    public void init() throws Exception {');
 Form1.SynEdit1.Lines.add('        super.init();');
 Form1.SynEdit1.Lines.add('        System.out.println("Inside init() method! Perform necessary initializations here.");');
 Form1.SynEdit1.Lines.add('    }  ');
 Form1.SynEdit1.Lines.add('      ');
 Form1.SynEdit1.Lines.add('    @Override');
 Form1.SynEdit1.Lines.add('    public void start(Stage primaryStage) throws Exception { ');
 Form1.SynEdit1.Lines.add('        Label label = new Label("Hello World");');
 Form1.SynEdit1.Lines.add('        label.setAlignment(Pos.CENTER); ');
 Form1.SynEdit1.Lines.add('        Scene scene = new Scene(label, 500, 350);');
 Form1.SynEdit1.Lines.add('');
 Form1.SynEdit1.Lines.add('        primaryStage.setTitle("Hello World Application");');
 Form1.SynEdit1.Lines.add('        primaryStage.setScene(scene);');
 Form1.SynEdit1.Lines.add('        primaryStage.show();');
 Form1.SynEdit1.Lines.add('    }');
 Form1.SynEdit1.Lines.add('');
 Form1.SynEdit1.Lines.add('    @Override');
 Form1.SynEdit1.Lines.add('    public void stop() throws Exception {');
 Form1.SynEdit1.Lines.add('        super.stop();');
 Form1.SynEdit1.Lines.add('        System.out.println("Inside stop() method! Destroy resources. Perform Cleanup.");');
 Form1.SynEdit1.Lines.add('    }');
 Form1.SynEdit1.Lines.add('');
 Form1.SynEdit1.Lines.add('    public static void main(String[] args) {');
 Form1.SynEdit1.Lines.add('        launch(args);');
 Form1. SynEdit1.Lines.add('    }');
 Form1.SynEdit1.Lines.add('}');
end;
end.

