所以我正在用 java 编写一个简单的隐写术代码,它包含一个简单的 gui 框架来执行解密和加密。 框架类有以下代码:
package Coding;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Encrypt_frame extends JFrame implements ActionListener {
private static final long serialVersionUID = 1L;
private JLabel label;
Encrypt_frame() {
super("Digital Image Steganography");
Container con = getContentPane();
con.setLayout(null);
label = new JLabel("<html><font color=black >STEGANOGRAPHY</font></html>");
label.setBounds(325, 1, 500, 300);
label.setFont(new Font("Times New Roman", Font.PLAIN, 50));
JButton encrypt = new JButton("<html><font color=#007399 >ENCRYPT</font></html>");
encrypt.addActionListener(this);
encrypt.setBounds(300, 300, 150, 50);
encrypt.setFont(new Font("Times New Roman", Font.PLAIN, 25));
JButton decryptmsg = new JButton("<html><font color=#007399 >DECRYPT</font></html>");
decryptmsg.addActionListener(this);
decryptmsg.setBounds(600, 300, 150, 50);
decryptmsg.setFont(new Font("Times New Roman", Font.PLAIN, 25));
con.add(label);
con.add(encrypt);
con.add(decryptmsg);
}
public void actionPerformed(ActionEvent ae) {
if (ae.getSource() == encrypt) {
this.dispose();
EncryptPage ep = new EncryptPage();
ep.setSize(1035, 790);
ep.getContentPane().setBackground(Color.gray);
ep.setVisible(true);
}
if (ae.getSource() == decryptmsg) {
this.dispose();
DecryptPage dp = new DecryptPage();
dp.setSize(1035, 790);
dp.getContentPane().setBackground(Color.gray);
dp.setVisible(true);
}
}
public static void main(String[] args) {
Encrypt_frame ef = new Encrypt_frame();
ef.setSize(1035, 790);
ef.getContentPane().setBackground(Color.gray);
ef.setVisible(true);
}
}
现在,在 actionPerformed() 方法中,我得到了错误
decryptmsg cannot be resolved to a variableJava(33554515)
encrypt cannot be resolved to a variableJava(33554515)
我无法弄清楚为什么会弹出这些错误。据我所知,加密和解密按钮的初始声明没有范围问题。
任何人都可以帮助我吗?
请注意,我可能会在 2-3 年后重新访问 JAVA,所以我并没有排除这个错误是非常微不足道的事情的可能性。
感谢您的宝贵时间!