次のようなダイアログ ボックスがあります。
JOptionPane.showMessageDialog(null,"Once medicine is given, measure temperature within 5 minutes." ,"Medication" ,JOptionPane.PLAIN_MESSAGE);
ユーザーが「OK」を押すと、Jframe に直接移動し、ユーザーにスライダーを使用して温度を入力するように求め、ボタンを押すと次のセットに進みます。
とにかく、ユーザーが「OK」を押した後、目に見えないカウントダウンを作成したいので、Jframeメニューで5分間アイドル状態になった後、JFrameの上に1つの警告ダイアログボックスが表示され、「NEED ATTENTION」のようなメッセージが表示されます。
これはactionListenerを思い出させます。ただし、非物理的な要素によって 5 分間呼び出されます (ボタンのクリックではありません)。
したがって、コードは次のようになります。
JOptionPane.showMessageDialog(null,"Once medicine is given, measure temperature within 5 minutes." ,"Medication" ,JOptionPane.PLAIN_MESSAGE);
temperature_class temp = new temperature_class(); // going to a different class where the the Jframe is coded
if (time exceeds 5 minutes) { JOptionPane.showMessageDialog(null, "NEED attention", JOptionPane.WARNING_MESSAGE);}
else { (do nothing) }
コードの動作:
JOptionPane.showMessageDialog(null,"measure temp" ,"1" ,JOptionPane.PLAIN_MESSAGE);
int delay = 3000; //milliseconds
ActionListener taskPerformer = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
JOptionPane.showMessageDialog(null,"hurry." ,"Bolus Therapy Protocol" ,JOptionPane.PLAIN_MESSAGE); } };
new Timer(delay, taskPerformer).start();
temperature_class temp = new temperature_class();
ただし、1回だけにしてほしい。では、set.Repeats(false) を呼び出すにはどうすればよいでしょうか。