Ola!
Você deve capturar o evento de "fechar janela" e terminar a execução:

algo do tipo:
(sobrescrevendo o processWindowEvent ...)
  protected void processWindowEvent(WindowEvent e) {
    super.processWindowEvent(e);
    if (e.getID() == WindowEvent.WINDOW_CLOSING) {
      System.exit(0);
    }
  }

[]s Alexandre.

"José Fernando R. do Val" wrote:

 Olá pessoal ! Rodei um pequeno exemplo de código e ele funciona OK, mas quando fecho a aplicação, o prompt não retorna. Sou obrigado a ir no gerenciador de tarefa e matar o processo java.exe no Winnt.Não sei se é relevante, mas para conseguir rodar, tive que setar o classpath com o comando SET CLASSPATH=  , para desaparecer o erro que estava ocorrendo ao rodar: ""Exception in thread "main" java.lang.NoClassDefFounError:Teste"" O que tem de errado nesse código ? //
import javax.swing.*;
import java.awt.event.*;
import java.awt.*; public class Teste extends JFrame implements ActionListener
{
 JPanel pn1A;
 JPanel pn1B;
 JLayeredPane layeredPane;
 JMenuItem mA;
 JMenuItem mB;
 public static void main( String args[] )
 {
  new Teste();
 }
 public Teste()
 {
  super("Teste");
  setBounds( 200, 100, 400, 400 );
  layeredPane = getLayeredPane();
  layeredPane.setLayout( null );   //Prepara o menu
  JMenuBar menuBar = new JMenuBar();
  getRootPane().setJMenuBar( menuBar );
  JMenu menu = new JMenu( "Painéis");
  menuBar.add( menu );
  mA = new JMenuItem("Panel A");
  mA.addActionListener( this );
  menu.add( mA );
  mB = new JMenuItem("Panel B");
  mB.addActionListener( this );
  menu.add( mB );   // Cria os Painéis
  pn1A = new JPanel();
  pn1A.setBackground( Color.blue );
  pn1A.setBounds( 0, 20, 400, 380 );
  layeredPane.add( pn1A, new Integer(1));

  pn1B = new JPanel();
  pn1B.setBackground( Color.yellow );
  pn1B.setBounds( 0, 20, 400, 380 );
  layeredPane.add( pn1B, new Integer(2));   setVisible( true );
 }  public void actionPerformed( ActionEvent ae )
 {   if( ae.getSource() == mA )
  {
   layeredPane.setLayer( pn1A, 1 );
   layeredPane.setLayer( pn1B, 0 );
  }
  else
  {
   layeredPane.setLayer( pn1A, 0 );
   layeredPane.setLayer( pn1B, 1 );
  }
 }
}
// Abraços. José Fernando

Responder a