如何将Java应用程序重定向到另一个java文件

时间:2016-04-21 20:32:10

标签: java

这是我的代码:

public class Cyptography implements ActionListener {
  JFrame frame = new JFrame("Cyptography");

  JTextField input = new JTextField();
  JButton decrypt = new JButton("decrypt");
  JTextField output = new JTextField();
  JButton encrypt = new JButton("encrypt");
  Container north = new Container();

  JRadioButton Scytale = new JRadioButton("Scytale");
  JRadioButton CaesarCipher = new JRadioButton("Caesar Cipher");
  JRadioButton VigenereCipher = new JRadioButton("Vigenere Cipher");
  Container south = new Container();

  public Cyptography() {
    frame = new JFrame("Cyptography");
    frame.setLayout(new BorderLayout());
    frame.setSize(700,300);

    north.setLayout(new GridLayout(1,4));
    north.add(decrypt);
    north.add(input);
    input.addActionListener(this);
    north.add(encrypt);
    north.add(output);
    output.addActionListener(this);
    frame.add(north, BorderLayout.NORTH);

    south.setLayout(new GridLayout(1,3));
    south.add(Scytale);
    Scytale.addActionListener(this);
    south.add(CaesarCipher);
    CaesarCipher.addActionListener(this);
    south.add(VigenereCipher);
    VigenereCipher.addActionListener(this);
    frame.add(south, BorderLayout.SOUTH);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }

  public static void main(String[] args) {
    new Cyptography();
  }

  @Override
  public void actionPerformed(ActionEvent event) {
    if (event.getSource().equals(Scytale)){
      //redirects to Scytale


    }
    else if (event.getSource().equals(CaesarCipher)){
      //redirects to Ceasar Cipher

    }
    else if (event.getSource().equals(VigenereCipher)){
      //redirects to Vigenere Cipher
    }
  }

  //decrypt - a text that has been decoded.
  public void decrypt() {

  }

  //encrypt - convert (information or data) into a cipher or code, especially to prevent unauthorized access
  public void encrypt() {

  }
}

这三个(Scytale,Caesar Cipher和Vigenere Cipher)按钮是Radio Buttons。这就是我想要的:我要点击一个单选按钮,然后我希望方法actionPreformed指向另一个java类。称为Scytale.java或CaesarCipher.java或VigenereCipher.java。

0 个答案:

没有答案