【发布时间】:2014-08-26 11:13:57
【问题描述】:
我有一个名为“btnSearch”的按钮和一个名为“textFieldSearch”的文本字段。 我有一个属性文件,用户可以搜索它以从中获取密钥。如果密钥存在,我希望它从文件中返回密钥并用它的值显示它,但当我认为我应该工作时它并没有这样做。感谢任何可以提供帮助的人!
//按钮代码
JButton btnSearch = new JButton("Search");
btnSearch.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
//find selected command
String key_name = textFieldSearch.getText();
if(textFieldSearch.getText().equals(properties.getProperty(key_name)))
{
System.out.println("hurrah");
}
}
});
panelSearch.add(btnSearch, "cell 6 3");
【问题讨论】: