才学java没几天,遇到问题了,创建窗口JFrame。在button中设置,具体代码如下
JButton btnNewButton = new JButton("New button");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String str1=textField.getText();
String str2=textField_1.getText();
String standard="\\p{Lower}+)";
if(str1.matches(standard)&&str2.matches(str2)){
boolean result=str1.equals(str2);
{if(result=true)
JOptionPane.showMessageDialog(String,"hengque");
else
JOptionPane.showMessageDialog(String,"buzhengque");}}
else
JOptionPane.showMessageDialog(null, "错误");}
JButton btnNewButton = new JButton("New button");
btnNewButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String str1=textField.getText();
String str2=textField_1.getText();
String standard="\\p{Lower}+)";
if(str1.matches(standard)&&str2.matches(str2)){
boolean result=str1.equals(str2);
{if(result=true)
JOptionPane.showMessageDialog(String,"hengque");
else
JOptionPane.showMessageDialog(String,"buzhengque");}}
else
JOptionPane.showMessageDialog(null, "错误");}