JButton erro

Galera, tentei colocar uma função que funcionava perfeitamente sem interface gráfica dentro de um Jbutton com a finalidade de quando clicar no botão, realizar a função!

segue abaixo

[code]package escravo;

import java.awt.Robot;
import java.awt.event.KeyEvent;
import java.io.IOException;
import java.awt.AWTException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*

  • @author RODRIGO
    */
    public class Principal extends javax.swing.JPanel {

    /** Creates new form Principal */
    public Principal() {
    initComponents();
    }

    /** This method is called from within the constructor to

    • initialize the form.

    • WARNING: Do NOT modify this code. The content of this method is

    • always regenerated by the Form Editor.
      */
      @SuppressWarnings(“unchecked”)
      //
      private void initComponents() {

      jButton1 = new javax.swing.JButton();
      jLabel1 = new javax.swing.JLabel();
      jLabel2 = new javax.swing.JLabel();

      jButton1.setText(“Editar Texto”);
      jButton1.addActionListener(new java.awt.event.ActionListener() {
      public void actionPerformed(java.awt.event.ActionEvent evt) {
      jButton1ActionPerformed(evt);
      }
      });

      jLabel1.setText(“Desenvolvido por: Alan Nogueira”);

      jLabel2.setText("alan.sistema@gmail.com");

      javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
      this.setLayout(layout);
      layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
      .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
      .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
      .addComponent(jLabel1)
      .addContainerGap())
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
      .addComponent(jLabel2)
      .addGap(24, 24, 24))
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
      .addComponent(jButton1)
      .addGap(40, 40, 40))))
      );
      layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
      .addContainerGap(18, Short.MAX_VALUE)
      .addComponent(jButton1)
      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
      .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE)
      .addGap(5, 5, 5)
      .addComponent(jLabel2))
      );
      }//

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
    int keyInput[] = {
    KeyEvent.VK_END,
    KeyEvent.VK_DELETE,
    KeyEvent.VK_SPACE,

     };
    

    Robot robot = null;
    try {
    robot = new Robot();
    } catch (AWTException ex) {
    Logger.getLogger(Principal.class.getName()).log(Level.SEVERE, null, ex);
    }

    robot.keyPress(KeyEvent.VK_ALT);
    robot.keyPress(KeyEvent.VK_TAB);
    robot.delay(200);
    robot.keyRelease(KeyEvent.VK_ALT);
    robot.keyRelease(KeyEvent.VK_TAB);

    for (int cnt2 = 0;cnt2 <= 200; cnt2++){
    for (int key : keyInput) {
    robot.keyPress(key);
    robot.delay(20);
    }
    }
    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    // End of variables declaration

}
[/code]