我创建了一个应用程序,我在其中实现了试用版代码。我的代码是
public class Test {
public static void main(String[] args) {
int s = 2013;
int t = 9;
int u = 29;
Calendar expireDate = Calendar.getInstance();
expireDate.set(s,t,u);
if (Calendar.getInstance().after(expireDate)) {
JTextField username = new JTextField();
JTextField password = new JPasswordField();
Object[] message = {
"Username:", username,
"Password:", password
};
int option = JOptionPane.showConfirmDialog(null, message, "Enter your Registration Code here", JOptionPane.OK_CANCEL_OPTION);
if (option == JOptionPane.OK_OPTION) {
String a ="as", b = "sa";
if (username.getText().equals(a) && password.getText().equals(b)) {
System.out.println("Login successful");
JFrame frame = new JFrame("Test");
frame.setVisible(true);
frame.setSize(500, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
frame.add(panel);
JButton button = new JButton("hello agin1");
panel.add(button);
button.addActionListener(new Action1());
JButton button2 = new JButton("hello agin2");
panel.add(button2);
} else {
System.out.println("login failed");
JOptionPane.showMessageDialog(null, "Not Valid");
}
} else {
System.out.println("Login canceled");
System.exit(1);
}
}else{
JFrame frame = new JFrame("Test");
frame.setVisible(true);
frame.setSize(500, 200);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel panel = new JPanel();
frame.add(panel);
JButton button = new JButton("hello agin1");
panel.add(button);
button.addActionListener(new Action1());
JButton button2 = new JButton("hello agin2");
panel.add(button2);
}
}
static class Action1 implements ActionListener {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
}
}
每次我在过期后打开应用程序时都必须注册。但我希望注册后不再寻找注册码。请帮忙。