the following code
I want to press done buttone to close JFrame without exit the application
----------------------------------------------------------------------------------
package examples.SecretaryAgent;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Display extends JFrame
{
private JCheckBox _first_Interval;
private JCheckBox _second_Interval;
private JButton _done_Button;
public Display()
{
setLayout(new FlowLayout());
_first_Interval=new JCheckBox("First Interval");
_second_Interval=new JCheckBox("Second Interval");
_done_Button=new JButton("Done");
add(_first_Interval);
add(_second_Interval);
add(_done_Button);
CheckBoxHandler handler=new CheckBoxHandler();
ButtonHandler handler2 =new ButtonHandler();
_first_Interval.addItemListener(handler);
_second_Interval.addItemListener(handler);
_done_Button.addActionListener(handler2);
}
private class CheckBoxHandler implements ItemListener
{
public void itemStateChanged(ItemEvent e)
{
}
}
private class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent event1)
{
if(event1.getSource()==_done_Button)
{
//SecretaryAgent._Dialoge=true;
//System.out.println("At done buttone handling");
//System.exit(0);
//JFrame.CLOSE;
}
}
}
}
package examples.SecretaryAgent;
import com.ibm.aglet.*;
import com.ibm.aglet.event.*;
import java.net.*;
import javax.swing.*;
public class SecretaryAgent extends Aglet
{
public static boolean _Dialoge=false;
private URL destination;
String strDest=new String("atp://OMAR-PC:1024");
boolean remote=false;
public void onCreation(Object o)
{
addMobilityListener
(
new MobilityAdapter()
{
public void onDispatching(MobilityEvent e)
{
System.out.println("I am at the origin now");
setText("I am at the origin");
//waitMessage(2*1000);
}
public void onArrival(MobilityEvent e)
{
remote=true;
setText("I am at the destination now");
//setText("I am at Remote");
Dialoge();
setText("After Dialoge()");
}
}
);
}
public void Dialoge()
{
Display x=new Display();
//x.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
x.setSize(350,100);
x.setVisible(true);
}
public void run()
{
if(remote==false)
{
System.out.println("The original aglet runs here");
try
{
destination=new URL (strDest);
dispatch(destination);
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
else if(remote==true && SecretaryAgent._Dialoge==true)
{
System.out.println(" The aglets runs at"+destination);
//waitMessage(5*1000);
dispose();
}
}
}