In my application, when I am clicking on the submit button then new applet window is opening fine but it is only showing the value entered in the textbox of parent window, the countdown is happening only in the parent window. I want countdown to happen in the child window once the submit is clicked (starting from the value entered in textbox). What I am doing wrong here?
package com.tcs.applet;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.util.Timer;
import java.util.TimerTask;
//import javax.swing.JButton;
public class MyApplet extends Applet implements ActionListener {
static int interval;
static Timer timer;
TextField inputLine = new TextField(15);
private Button button = new Button("Submit");
Label tmpLbl = new Label();
public MyApplet() {
button.addActionListener(this);
add(inputLine);
add(button);
add(tmpLbl);
// button.addActionListener(ActionListener act);
// / doCountDown("10");
}
private String doCountDown(String secInput){
int delay = 1000;
int period = 1000;
timer = new Timer();
interval = Integer.parseInt(secInput);
// System.out.println(secs);
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
// System.out.println(setInterval());
int tmpTimer=setInterval();
tmpLbl.setText(Integer.toString(tmpTimer));
}
}, delay, period);
return secInput;
}
private static final int setInterval() {
if (interval == 1)
timer.cancel();
return --interval;
}
// setup all the context...
public void actionPerformed(ActionEvent e) {
// TODO Auto-generated method stub
Button source = (Button)e.getSource();
String tmp=e.getActionCommand();
if (tmp=="Submit"){
Frame frame = new Frame();
frame.setSize(1000, 300);
Label jname=new Label(doCountDown(inputLine.getText()));
frame.add(jname);
int tmpTimer=setInterval();
frame.show();
}
}
}