試用版のコードを実装するアプリケーションを作成します。私のコードは
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);
}
}
}
有効期限が切れた後にアプリケーションを開くたびに登録する必要があります。しかし、登録後に登録コードを探す必要はありません。助けてください。