基本上
JButton.isEnabled()
不适合我。一旦按下按钮,我需要一个方法来运行,目前我无法检查按钮是否被按下。有很多类似的问题与此相关,但没有为图书馆使用或者根本没有,但是如果偶然我错过了答案请链接它:)非常感谢 这是代码
public class main_runner extends Frame {
private static encription_algorithm ea;
private static String password;
private static Scanner scan;
public static JFrame f ;
static Container pane;
static JLabel dir;
static JPasswordField en;
static JTextField decr;
static JButton encrypt;
// get hash button doesnt work useless needs fix
public static void main(String[] args) {
decr = new JTextField(30);
dir = new JLabel("type in your message to encript it");
f = new JFrame("encryptor");
encrypt = new JButton("press to get hash");
en = new JPasswordField(10);
f.setSize(600,400);
Color c = new Color(11,45,115);
f.setBackground(c);
f.add(dir);
f.add(en);
f.add(encrypt);
if(encrypt.isEnabled() == true)
{
decr.setText(getHash());
System.out.println("trigger");
}
else
decr.setText("");
f.add(decr);
进一步详细说明触发器正在打印输出,但按下按钮
时方法没有运行