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();
		}
	}
}

Edited 6 Years Ago by Nick Evan: Added code-tags

First of all always use Code tags.
If you only want to hide your frame and dont want to close your application you can use frame.setVisible(false) in your done button ActionListener so that you application wont exit only the frame will be hidden

first of all I am sorry and next time I'll use code tag
secon thank you I used it and it work properly thank you

First of all always use Code tags.
If you only want to hide your frame and dont want to close your application you can use frame.setVisible(false) in your done button ActionListener so that you application wont exit only the frame will be hidden

first of all I am sorry and next time I'll use code tag
secon thank you I used it and it work properly thank you

I can use JFrame object inside the aglet class But inherited JFrame class means to have two different threads , But use only a JFrame object inside aglet thread may solve the threading problem

This question has already been answered. Start a new discussion instead.