无法调用main方法

时间:2017-06-05 10:48:14

标签: java

我正在尝试从我的'Clicker'类调用一个方法到我的'Main'类但是我不断收到错误,这会因我调用的方法而异。 这是主要的课程。当前错误是“此令牌后预期的令牌(XYZ)标识符上的语法错误。”

package me.removed.clicker;

public class Main
{
  public static void main(String[] args) {}

}

这是点击者类。

package me.removed.clicker;

import java.awt.EventQueue;
import java.awt.Robot;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.Logger;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.FloatControl.Type;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import me.dewgs.clicker.handler.KeyboardHandler;
import me.dewgs.clicker.handler.MouseHandler;
import me.dewgs.clicker.util.Time;
import org.jnativehook.GlobalScreen;

public class Clicker
{
  public static Clicker instance;
  private boolean LEFT_held;
  private boolean LEFT_skip;
  private Time LEFT_pressTime;
  private boolean toggled;
  private Random random;
  private ClickerFrame clickerFrame;
  private MouseHandler clickerHandler;
  private KeyboardHandler keyHandler;
  private Robot robot;
  private Thread thread;

  public boolean isToggled()
  {
    return this.toggled;
  }

  public void setToggled(boolean toggled)
  {
    this.toggled = toggled;
  }

  public Clicker()
  {
    this.LEFT_held = false;
    this.LEFT_skip = false;
    this.toggled = false;
    this.random = new Random();
    try
    {
      GlobalScreen.registerNativeHook();
      this.clickerHandler = new MouseHandler();
      this.keyHandler = new KeyboardHandler();
      GlobalScreen.addNativeMouseListener(this.clickerHandler);
      GlobalScreen.addNativeKeyListener(this.keyHandler);
      this.robot = new Robot();
      LogManager.getLogManager().reset();
      Logger logger = Logger.getLogger(GlobalScreen.class.getPackage().getName());
      logger.setLevel(Level.OFF);
    }
    catch (Exception e)
    {
      e.printStackTrace();
    }
    this.thread = new Thread(new Runnable()
    {
      public void run()
      {
        try
        {
          for (;;)
          {
            Thread.sleep(1L);
            if ((Clicker.this.isToggled()) && 


              (Clicker.this.isLeftHeld()))
            {
              long CPSDelay = Clicker.this.generateCPSDelay();
              if (Clicker.this.getLeftPressTime() != null)
              {
                if (Clicker.this.getLeftPressTime().hasPassed())
                {
                  Clicker.this.setLeftPressTime(new Time(CPSDelay));
                  Clicker.this.setLeftSkip(true);
                  Clicker.this.robot.mousePress(16);
                  Clicker.this.robot.mouseRelease(16);

                  Thread runThread = new Thread(new Runnable()
                  {
                    public void run()
                    {
                      try
                      {
                        AudioInputStream audioInputStream = 
                          AudioSystem.getAudioInputStream(Clicker.class.getClassLoader().getResource("left_click.wav"));

                        Clip clip = AudioSystem.getClip();

                        clip.open(audioInputStream);

                        float volume = -9.0F - Clicker.this.random.nextFloat() * 11.0F;


                        FloatControl gainControl = 
                          (FloatControl)clip.getControl(FloatControl.Type.MASTER_GAIN);
                        gainControl.setValue(volume);

                        clip.start();
                      }
                      catch (Exception localException) {}
                    }
                  });
                  runThread.start();
                }
              }
              else
              {
                Clicker.this.setLeftPressTime(new Time(CPSDelay));
                Clicker.this.setLeftSkip(true);
              }
            }
          }
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
    });
    this.thread.start();
  }

  public boolean isLeftHeld()
  {
    return this.LEFT_held;
  }

  public void setLeftHeld(boolean LEFT_held)
  {
    this.LEFT_held = LEFT_held;
  }

  public void destroy()
  {
    try
    {

    }
    catch (Throwable e)
    {
      e.printStackTrace();
    }
    System.exit(0);
  }

  public void openUI()
  {
    EventQueue.invokeLater(new Runnable()
    {
      public void run()
      {
        try
        {
          UIManager.LookAndFeelInfo[] installedLookAndFeels;
          int length = (installedLookAndFeels = UIManager.getInstalledLookAndFeels()).length;
          for (int i = 0; i < length; i++)
          {
            UIManager.LookAndFeelInfo info = installedLookAndFeels[i];
            if ("Windows".equals(info.getName()))
            {
              UIManager.setLookAndFeel(info.getClassName());
              break;
            }
          }
          Clicker.this.clickerFrame = new ClickerFrame();
          Clicker.this.clickerFrame.setVisible(true);
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
      }
    });
  }

  public boolean getLeftSkip()
  {
    return this.LEFT_skip;
  }

  public void setLeftSkip(boolean LEFT_skip)
  {
    this.LEFT_skip = LEFT_skip;
  }

  public Time getLeftPressTime()
  {
    return this.LEFT_pressTime;
  }

  public void setLeftPressTime(Time LEFT_pressTime)
  {
    this.LEFT_pressTime = LEFT_pressTime;
  }

  public ClickerFrame getClickerFrame()
  {
    return this.clickerFrame;
  }

  public long generateCPSDelay()
  {
    int minCPS = 12;
    int maxCPS = 15;
    double minDiff = 83.0D;
    double maxDiff = 66.0D;
    double randomDiff = this.random.nextDouble() * 17.0D;
    return (long) (66.0D + randomDiff);
  }

  public static void setupClicker()
  {
    (Clicker.instance = new Clicker()).openUI();
  }

  public static Clicker getClicker()
  {
    return instance;
  }
}

我尝试拨打setupClicker,即使我按照其他网页上的步骤操作也无效,

Clicker click = new Clicker();
click.setupClicker.

我尝试过并使用其他方法也无济于事。

仅供参考:我正在尝试打开GUI并启动点击器本身。

1 个答案:

答案 0 :(得分:0)

  

我尝试拨打setupClicker,即使我按照步骤进行操作也是如此   其他页面无效,

Clicker click = new Clicker();
click.setupClicker.

您错过了添加括号

public class Main
{
  public static void main(String[] args) {

          Clicker click = new Clicker();
          click.setupClicker();   
  }

}