Como puedo cerrar un Jframe

Problemas
13 de Enero del 2005
Quiero cerrar el JFrame atencion que se esta en la clase buscar, desde un boton de la clase borrar. Esta puesto con comentarios a ver si alguien me puede exar un cable. Muchas gracias.


Aki esta el codigo completo algo tedioso pero es que ya no se como hacerlo:


import java.*;
import javax.swing.*;
import java.awt.Rectangle;
import java.awt.Color;
import java.awt.event.*;
import javax.swing.border.*;

public class principal extends JPanel {

JLabel jLabel1 = new JLabel();
JLabel jLabel2 = new JLabel();
JButton jButton1 = new JButton();
JButton jButton2 = new JButton();
JButton jButton3 = new JButton();
JButton jButton4 = new JButton();
JButton jButton5 = new JButton();
TitledBorder titledBorder1;


public principal() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}


}


public static void main(String[] args) {

JFrame primero = new JFrame("Buscador R.A.J.");
primero.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
});

primero.getContentPane().add(new principal());
primero.pack();
primero.setSize(400,350);
primero.setResizable(false);
primero.setVisible(true);

}

private void jbInit() throws Exception {
titledBorder1 = new TitledBorder("");
setLayout(null);
jLabel1.setBounds(new Rectangle(27, 24, 144, 68));
jLabel1.setIcon(new ImageIcon("c:/uco.gif"));
jLabel1.setText("");
jLabel2.setBounds(new Rectangle(162, 37, 214, 54));
jLabel2.setIcon(new ImageIcon("c:/Dibujo.jpg"));
jLabel2.setText("");
jButton1.setBackground(new Color(201, 55, 69));
jButton1.setBounds(new Rectangle(41, 130, 96, 28));
jButton1.setFont(new java.awt.Font("Dialog", 1, 13));
jButton1.setForeground(Color.white);
jButton1.setBorder(BorderFactory.createLineBorder(Color.black));
jButton1.setText("Buscar");
jButton1.addActionListener(new principal_jButton1_actionAdapter(this));
jButton2.setBackground(new Color(201, 55, 69));
jButton2.setBounds(new Rectangle(41, 170, 96, 28));
jButton2.setFont(new java.awt.Font("Dialog", 1, 13));
jButton2.setForeground(Color.white);
jButton2.setText("Añadir");
jButton2.addActionListener(new principal_jButton2_actionAdapter(this));
jButton3.setBackground(new Color(201, 55, 69));
jButton3.setBounds(new Rectangle(41, 210, 96, 28));
jButton3.setFont(new java.awt.Font("Dialog", 1, 13));
jButton3.setForeground(Color.white);
jButton3.setDebugGraphicsOptions(0);
jButton3.setText("Ayuda");
jButton3.addActionListener(new principal_jButton3_actionAdapter(this));
jButton4.setBackground(new Color(214, 255, 255));
jButton4.setBounds(new Rectangle(295, 202, 59, 45));
jButton4.setForeground(Color.white);
jButton4.setBorder(null);
jButton4.setBorderPainted(true);
jButton4.setIcon(new ImageIcon("c:/info.gif"));
jButton4.setText("");
jButton4.addActionListener(new principal_jButton4_actionAdapter(this));

jButton5.setBackground(new Color(201, 55, 69));
jButton5.setBounds(new Rectangle(41, 250, 96, 28));
jButton5.setFont(new java.awt.Font("Dialog", 1, 13));
jButton5.setForeground(Color.white);
jButton5.setBorder(BorderFactory.createLineBorder(Color.black));
jButton5.setText("Salir");
jButton5.addActionListener(new principal_jButton5_actionAdapter(this));
jButton5.addActionListener(new principal_jButton5_actionAdapter(this));

this.setBackground(new Color(214, 255, 255));
this.add(jLabel1, null);
this.add(jLabel2, null);
this.add(jButton1, null);
this.add(jButton3, null);
this.add(jButton2, null);
this.add(jButton4, null);
this.add(jButton5, null);
}

void jButton4_actionPerformed(ActionEvent e) {
JFrame info = new JFrame("A cerca de ...");

info.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.runFinalization();}
});

info.getContentPane().add(new acercade());
info.pack();
info.setSize(400,350);
info.setResizable(false);
info.setVisible(true);


}

void jButton1_actionPerformed(ActionEvent e) {

JFrame ventanabuscar = new JFrame("Buscar");

ventanabuscar.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.runFinalization();}
});

ventanabuscar.getContentPane().add(new buscar());
ventanabuscar.pack();
ventanabuscar.setSize(460,520);
ventanabuscar.setResizable(false);
ventanabuscar.setVisible(true);

}

void jButton2_actionPerformed(ActionEvent e) {
JFrame ventanaanadir = new JFrame("Añadir");

ventanaanadir.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.runFinalization();}
});

ventanaanadir.getContentPane().add(new anadir());
ventanaanadir.pack();
ventanaanadir.setSize(530,500);
ventanaanadir.setResizable(false);
ventanaanadir.setVisible(true);

}

void jButton5_actionPerformed(ActionEvent e) {
System.exit(0);
}

void jButton3_actionPerformed(ActionEvent e) {

}

}

/********************************************************************************/
/* Acontinuacion esta la clase acercade*/
/********************************************************************************/

class acercade extends JPanel {
JLabel jLabel1acercad = new JLabel();
JLabel jLabel2acercad = new JLabel();
JLabel jLabel3acercad = new JLabel();
JLabel jLabel4acercad = new JLabel();
JLabel jLabel5acercad = new JLabel();
JLabel jLabel6acercad = new JLabel();
JLabel jLabel7acercad = new JLabel();
JLabel jLabel8acercad = new JLabel();
JLabel jLabel9acercad = new JLabel();
JLabel jLabel10acercad = new JLabel();
JLabel jLabel11acercad = new JLabel();
public acercade() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
acercade acercade1 = new acercade();
}
private void jbInit() throws Exception {
setLayout(null);
jLabel1acercad.setBounds(new Rectangle(27, 24, 144, 68));
jLabel1acercad.setIcon(new ImageIcon("c:/uco.gif"));
jLabel1acercad.setText("");
jLabel2acercad.setBounds(new Rectangle(152, 39, 209, 54));
jLabel2acercad.setIcon(new ImageIcon("c:/Dibujo.jpg"));
jLabel2acercad.setText("");
jLabel3acercad.setFont(new java.awt.Font("Dialog", 1, 16));
jLabel3acercad.setForeground(new Color(201, 55, 69));
jLabel3acercad.setText("Escuela Politécnica Superior");
jLabel3acercad.setBounds(new Rectangle(41, 113, 226, 36));
jLabel4acercad.setFont(new java.awt.Font("Dialog", 0, 13));
jLabel4acercad.setForeground(new Color(255, 131, 0));
jLabel4acercad.setText("Departamento de Ingeniería del Software");
jLabel4acercad.setBounds(new Rectangle(72, 143, 246, 25));
jLabel5acercad.setFont(new java.awt.Font("Dialog", 1, 16));
jLabel5acercad.setForeground(new Color(201, 55, 69));
jLabel5acercad.setText("Autores");
jLabel5acercad.setBounds(new Rectangle(41, 187, 66, 30));
jLabel6acercad.setFont(new java.awt.Font("Dialog", 0, 13));
jLabel6acercad.setForeground(new Color(255, 131, 0));
jLabel6acercad.setText("Rafael Graciano Arroyo");
jLabel6acercad.setBounds(new Rectangle(72, 221, 144, 25));
jLabel7acercad.setBounds(new Rectangle(72, 241, 144, 25));
jLabel7acercad.setText("Alvaro Puerto López");
jLabel7acercad.setFont(new java.awt.Font("Dialog", 0, 13));
jLabel7acercad.setForeground(new Color(255, 131, 0));
jLabel8acercad.setBounds(new Rectangle(72, 261, 144, 25));
jLabel8acercad.setText("José David Vela Castro");
jLabel8acercad.setFont(new java.awt.Font("Dialog", 0, 13));
jLabel8acercad.setForeground(new Color(255, 131, 0));
jLabel9acercad.setFont(new java.awt.Font("Dialog", 1, 11));
jLabel9acercad.setText("versión 1.0 de libre distribución");
jLabel9acercad.setBounds(new Rectangle(171, 87, 216, 24));
jLabel10acercad.setBounds(new Rectangle(280, 204, 95, 87));
jLabel10acercad.setIcon(new ImageIcon("c:/politecnica.gif"));
jLabel10acercad.setText("");
jLabel11acercad.setFont(new java.awt.Font("Dialog", 0, 13));
jLabel11acercad.setForeground(new Color(255, 131, 0));
jLabel11acercad.setText("I.T. Informática de Gestión");
jLabel11acercad.setBounds(new Rectangle(72, 170, 175, 27));

this.setBackground(new Color(214, 255, 255));
this.add(jLabel1acercad, null);
this.add(jLabel3acercad, null);
this.add(jLabel5acercad, null);
this.add(jLabel6acercad, null);
this.add(jLabel7acercad, null);
this.add(jLabel8acercad, null);
this.add(jLabel9acercad, null);
this.add(jLabel4acercad, null);
this.add(jLabel10acercad, null);
this.add(jLabel11acercad, null);
this.add(jLabel2acercad, null);



}

}






/********************************************************************************/
/************************ Clase añadir ********************/
/********************************************************************************/
class anadir extends JPanel {
JLabel jLabel1anadir = new JLabel();
JLabel jLabel2anadir = new JLabel();
JList jList1anadir = new JList();
JTextField jTextField1anadir = new JTextField();
JLabel jLabel3anadir = new JLabel();
JButton jButton1anadir = new JButton();
JButton jButton2anadir = new JButton();
JLabel jLabel4anadir = new JLabel();
JTextArea jTextArea1anadir = new JTextArea();
JButton jButton3anadir = new JButton();
JButton jButton4anadir = new JButton();
public anadir() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
anadir anadir1 = new anadir();
}
private void jbInit() throws Exception {
setLayout(null);
jLabel1anadir.setText("");
jLabel1anadir.setIcon(new ImageIcon("c:/uco.gif"));
jLabel1anadir.setBounds(new Rectangle(40, 22, 144, 68));
jLabel2anadir.setBounds(new Rectangle(245, 30, 209, 54));
jLabel2anadir.setIcon(new ImageIcon("c:/Dibujo.jpg"));
jLabel2anadir.setText("");
jList1anadir.setBorder(BorderFactory.createLineBorder(Color.black));
jList1anadir.setBounds(new Rectangle(92, 106, 93, 114));
jTextField1anadir.setText("jTextField1");
jTextField1anadir.setBounds(new Rectangle(210, 123, 181, 25));
jLabel3anadir.setText("Introduzca palabra clave");
jLabel3anadir.setBounds(new Rectangle(242, 97, 180, 19));
jButton1anadir.setBackground(new Color(201, 55, 69));
jButton1anadir.setBounds(new Rectangle(208, 161, 90, 31));
jButton1anadir.setForeground(Color.white);
jButton1anadir.setText("Agregar");
jButton2anadir.setBackground(new Color(201, 55, 69));
jButton2anadir.setBounds(new Rectangle(300, 161, 90, 31));
jButton2anadir.setForeground(Color.white);
jButton2anadir.setText("Quitar");
jButton2anadir.addActionListener(new anadir_jButton2anadir_actionAdapter(this));
jLabel4anadir.setText("Ahora introduzca el nuevo resumen");
jLabel4anadir.setBounds(new Rectangle(147, 230, 204, 26));
jTextArea1anadir.setBorder(BorderFactory.createLineBorder(Color.black));
jTextArea1anadir.setText("jTextArea1");
jTextArea1anadir.setBounds(new Rectangle(47, 261, 406, 91));
jButton3anadir.setBackground(new Color(201, 55, 69));
jButton3anadir.setBounds(new Rectangle(129, 369, 106, 31));
jButton3anadir.setForeground(Color.white);
jButton3anadir.setText("Aceptar");
jButton3anadir.addActionListener(new anadir_jButton3anadir_actionAdapter(this));
jButton4anadir.setBackground(new Color(201, 55, 69));
jButton4anadir.setBounds(new Rectangle(260, 369, 106, 31));
jButton4anadir.setForeground(Color.white);
jButton4anadir.setText("Cancelar");
jButton4anadir.addActionListener(new anadir_jButton4anadir_actionAdapter(this));
this.setBackground(new Color(214, 255, 255));
this.add(jTextArea1anadir, null);
this.add(jLabel2anadir, null);
this.add(jLabel1anadir, null);
this.add(jLabel3anadir, null);
this.add(jTextField1anadir, null);
this.add(jButton2anadir, null);
this.add(jButton1anadir, null);
this.add(jList1anadir, null);
this.add(jLabel4anadir, null);
this.add(jButton4anadir, null);
this.add(jButton3anadir, null);
}

void jButton2anadir_actionPerformed(ActionEvent e) {

}

void jButton3anadir_actionPerformed(ActionEvent e) {

JFrame frame = new JFrame("Añadir ruta");

frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.runFinalization();}
});

frame.getContentPane().add(new ruta());
frame.pack();
frame.setSize(530,500);
frame.setResizable(false);
frame.setVisible(true);

}

void jButton4anadir_actionPerformed(ActionEvent e) {

}

}

class anadir_jButton2anadir_actionAdapter implements java.awt.event.ActionListener {
anadir adaptee;

anadir_jButton2anadir_actionAdapter(anadir adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2anadir_actionPerformed(e);
}
}

class anadir_jButton3anadir_actionAdapter implements java.awt.event.ActionListener {

anadir adaptee;

anadir_jButton3anadir_actionAdapter(anadir adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton3anadir_actionPerformed(e);
}
}

class anadir_jButton4anadir_actionAdapter implements java.awt.event.ActionListener {
anadir adaptee;

anadir_jButton4anadir_actionAdapter(anadir adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton4anadir_actionPerformed(e);
}
}





/********************************************************************************/
/********************************************************************************/
/************************* Clase Buscar *************************/
/********************************************************************************/


class buscar extends JPanel {

JLabel jLabel1buscar = new JLabel();
JLabel jLabel2buscar = new JLabel();
JCheckBox jCheckBox1buscar = new JCheckBox();
JCheckBox jCheckBox2buscar = new JCheckBox();
JLabel jLabel3buscar = new JLabel();
JLabel jLabel4buscar = new JLabel();
JTextField jTextField1buscar = new JTextField();
JButton jButton1buscar = new JButton();
JButton jButton2buscar = new JButton();
JButton jButton4buscar = new JButton();
JList jList1buscar = new JList();
JTextField jTextField2buscar = new JTextField();
JButton jButton3buscar = new JButton();
public buscar() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
buscar buscar1 = new buscar();
}
private void jbInit() throws Exception {
setLayout(null);
jLabel1buscar.setText("");
jLabel1buscar.setIcon(new ImageIcon("c:/uco.gif"));
jLabel1buscar.setBounds(new Rectangle(25, 30, 144, 68));
jLabel2buscar.setBounds(new Rectangle(187, 35, 211, 54));
jLabel2buscar.setIcon(new ImageIcon("c:/Dibujo.jpg"));
jLabel2buscar.setText("");
jCheckBox1buscar.setBackground(new Color(201, 55, 69));
jCheckBox1buscar.setForeground(Color.white);
jCheckBox1buscar.setText("jCheckBox1");
jCheckBox1buscar.setBounds(new Rectangle(34, 142, 21, 17));
jCheckBox2buscar.setBackground(new Color(201, 55, 69));
jCheckBox2buscar.setForeground(Color.white);
jCheckBox2buscar.setBorder(null);
jCheckBox2buscar.setText("jCheckBox2");
jCheckBox2buscar.setBounds(new Rectangle(178, 141, 21, 18));
jLabel3buscar.setForeground(Color.orange);
jLabel3buscar.setText("Por Palabras Clave");
jLabel3buscar.setBounds(new Rectangle(59, 142, 118, 14));
jLabel4buscar.setForeground(Color.orange);
jLabel4buscar.setText("Por Resumen");
jLabel4buscar.setBounds(new Rectangle(202, 143, 83, 14));
jTextField1buscar.setText("Introduzca la busqueda");
jTextField1buscar.setBounds(new Rectangle(37, 174, 281, 25));
jButton1buscar.setBackground(new Color(201, 55, 69));
jButton1buscar.setBounds(new Rectangle(325, 174, 81, 25));
jButton1buscar.setFont(new java.awt.Font("Dialog", 1, 13));
jButton1buscar.setForeground(Color.white);
jButton1buscar.setText("Buscar");

this.setBackground(new Color(214, 255, 255));
this.setForeground(Color.white);

jButton2buscar.setText("Borrar");
jButton2buscar.addActionListener(new buscar_jButton2buscar_actionAdapter(this));

jButton2buscar.setForeground(Color.white);
jButton2buscar.setBounds(new Rectangle(253, 438, 100, 30));
jButton2buscar.setBackground(new Color(201, 55, 69));

jButton4buscar.setText("Modificar");

jButton4buscar.setForeground(Color.white);
jButton4buscar.setBounds(new Rectangle(96, 438, 100, 30));
jButton4buscar.setBackground(new Color(201, 55, 69));
jList1buscar.setBounds(new Rectangle(36, 224, 392, 136));
jList1buscar.setBorder(BorderFactory.createLineBorder(Color.black));
jTextField2buscar.setBounds(new Rectangle(36, 385, 245, 24));
jTextField2buscar.setText("Introduzca la busqueda");

jButton3buscar.setText("Busqueda anidada");

jButton3buscar.setForeground(Color.white);
jButton3buscar.setBounds(new Rectangle(292, 381, 139, 30));
jButton3buscar.setBackground(new Color(201, 55, 69));
this.add(jLabel1buscar, null);
this.add(jLabel2buscar, null);
this.add(jCheckBox1buscar, null);
this.add(jLabel3buscar, null);
this.add(jCheckBox2buscar, null);
this.add(jLabel4buscar, null);
this.add(jTextField1buscar, null);
this.add(jButton1buscar, null);
this.add(jList1buscar, null);
this.add(jTextField2buscar, null);
this.add(jButton3buscar, null);
this.add(jButton4buscar, null);
this.add(jButton2buscar, null);
}

void jButton2buscar_actionPerformed(ActionEvent e) {
/*Este es el que quiero cerrar con el jButton2borrar de la clase borrar*/
JFrame atencion = new JFrame("Atencion");

atencion.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.runFinalization();}
});

atencion.getContentPane().add(new borrar());
atencion.pack();
atencion.setSize(400,200);
atencion.setResizable(false);
atencion.setVisible(true);




}


}

class buscar_jButton2buscar_actionAdapter implements java.awt.event.ActionListener {
buscar adaptee;

buscar_jButton2buscar_actionAdapter(buscar adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2buscar_actionPerformed(e);
}
}




/********************************************************************************/
/********************************************************************************/
/****************** Clase Resultados ******************/
class resultados extends JPanel {
JLabel jLabel1resultados = new JLabel();
JLabel jLabel2resultados = new JLabel();
JList jList1resultados = new JList();
JButton jButton1resultados = new JButton();
JButton jButton2resultados = new JButton();
JButton jButton3resultados = new JButton();
JTextField jTextField1resultados = new JTextField();
public resultados() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
resultados resultados1 = new resultados();
}
private void jbInit() throws Exception {
setLayout(null);
jLabel1resultados.setBounds(new Rectangle(55, 34, 144, 68));
jLabel1resultados.setIcon(new ImageIcon("c:/uco.gif"));
jLabel1resultados.setText("");
jLabel2resultados.setBounds(new Rectangle(229, 39, 222, 54));
jLabel2resultados.setIcon(new ImageIcon("c:/Dibujo.jpg"));
jLabel2resultados.setText("");
jList1resultados.setBorder(BorderFactory.createLineBorder(Color.black));
jList1resultados.setBounds(new Rectangle(55, 127, 392, 136));
jButton1resultados.setBackground(new Color(201, 55, 69));
jButton1resultados.setBounds(new Rectangle(101, 330, 100, 30));
jButton1resultados.setForeground(Color.white);
jButton1resultados.setText("Modificar");
jButton1resultados.addActionListener(new resultados_jButton1resultados_actionAdapter(this));
jButton2resultados.setBackground(new Color(201, 55, 69));
jButton2resultados.setBounds(new Rectangle(258, 330, 100, 30));
jButton2resultados.setForeground(Color.white);
jButton2resultados.setText("Borrar");
jButton2resultados.addActionListener(new resultados_jButton2resultados_actionAdapter(this));
jButton3resultados.setBackground(new Color(201, 55, 69));
jButton3resultados.setBounds(new Rectangle(307, 276, 139, 30));
jButton3resultados.setForeground(Color.white);
jButton3resultados.setText("Busqueda anidada");
jButton3resultados.addActionListener(new resultados_jButton3resultados_actionAdapter(this));
jTextField1resultados.setText("Introduzca la busqueda");
jTextField1resultados.setBounds(new Rectangle(55, 277, 245, 24));
this.setBackground(new Color(214, 255, 255));
this.add(jLabel1resultados, null);
this.add(jList1resultados, null);
this.add(jButton3resultados, null);
this.add(jButton1resultados, null);
this.add(jButton2resultados, null);
this.add(jTextField1resultados, null);
this.add(jLabel2resultados, null);
}

void jButton2resultados_actionPerformed(ActionEvent e) {
JFrame borrar = new JFrame("ATENCIÓN");

borrar.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.runFinalization();}
});

borrar.getContentPane().add(new borrar());
borrar.pack();
borrar.setSize(400,150);
borrar.setResizable(false);
borrar.setVisible(true);


}

void jButton1resultados_actionPerformed(ActionEvent e) {
JFrame modificar = new JFrame("Modificar");

modificar.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.runFinalization();}
});

modificar.getContentPane().add(new anadir());
modificar.pack();
modificar.setSize(530,500);
modificar.setResizable(false);
modificar.setVisible(true);

}

void jButton3resultados_actionPerformed(ActionEvent e) {

}

}

class resultados_jButton2resultados_actionAdapter implements java.awt.event.ActionListener {
resultados adaptee;

resultados_jButton2resultados_actionAdapter(resultados adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2resultados_actionPerformed(e);
}
}

class resultados_jButton1resultados_actionAdapter implements java.awt.event.ActionListener {
resultados adaptee;

resultados_jButton1resultados_actionAdapter(resultados adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1resultados_actionPerformed(e);
}
}

class resultados_jButton3resultados_actionAdapter implements java.awt.event.ActionListener {
resultados adaptee;

resultados_jButton3resultados_actionAdapter(resultados adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton3resultados_actionPerformed(e);
}
}




/********************************************************************************/
/********************************************************************************/
/************************* Clase Ruta *************************/

class ruta extends JPanel {
JLabel jLabel1ruta = new JLabel();
JLabel jLabel2ruta = new JLabel();
JLabel jLabel3ruta = new JLabel();
Border border1ruta;
JFileChooser jFileChooser1ruta = new JFileChooser();
public ruta() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
ruta ruta1 = new ruta();
}
private void jbInit() throws Exception {
border1ruta = BorderFactory.createBevelBorder(BevelBorder.RAISED,Color.white,Color.white,new Color(214, 255, 255),new Color(214, 255, 255));
setLayout(null);
jLabel1ruta.setText("");
jLabel1ruta.setIcon(new ImageIcon("c:/uco.gif"));
jLabel1ruta.setBounds(new Rectangle(30, 34, 144, 68));
jLabel2ruta.setBounds(new Rectangle(244, 44, 209, 54));
jLabel2ruta.setIcon(new ImageIcon("c:/Dibujo.jpg"));
jLabel2ruta.setText("");
jLabel3ruta.setText("Introduzca la ruta del archivo ");
jLabel3ruta.setBounds(new Rectangle(155, 109, 161, 29));
this.setBackground(new Color(214, 255, 255));
jFileChooser1ruta.setBounds(new Rectangle(43, 151, 422, 306));
this.add(jLabel1ruta, null);
this.add(jLabel2ruta, null);
this.add(jFileChooser1ruta, null);
this.add(jLabel3ruta, null);
}

}





/********************************************************************************/
/********************************************************************************/
/************************ Clase Borrar ****************/

class borrar extends JPanel{
JLabel jLabel1borrar = new JLabel();
JButton jButton1borrar = new JButton();
JButton jButton2borrar = new JButton();
public borrar() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}



public static void main(String[] args) {
borrar borrar1 = new borrar();
}
private void jbInit() throws Exception {

setLayout(null);
jLabel1borrar.setFont(new java.awt.Font("Dialog", 1, 13));
jLabel1borrar.setText("¿Desea borrar la referencia de este archivo?");
jLabel1borrar.setBounds(30,20,300,20);


jButton1borrar.setFont(new java.awt.Font("Dialog", 1, 13));
jButton1borrar.setForeground(Color.white);
jButton1borrar.setText("Aceptar");
jButton1borrar.setBackground(new Color(201, 55, 69));
jButton1borrar.setBounds(60,60,100,30);


jButton2borrar.setBackground(new Color(201, 55, 69));
jButton2borrar.setBounds(200,60,100,30);
jButton2borrar.setFont(new java.awt.Font("Dialog", 1, 13));
jButton2borrar.setForeground(Color.white);
jButton2borrar.setText("Cancelar");
jButton2borrar.addActionListener(new borrar_jButton2borrar_actionAdapter(this));


this.setBackground(new Color(214, 255, 255));
this.add(jLabel1borrar, null);
this.add(jButton1borrar, null);
this.add(jButton2borrar, null);


}

void jButton2borrar_actionPerformed(ActionEvent e) {

/************************************/
/*¿Como puedo cerrar la ventana atencion que esta en buscar?*/

/*He probado
atencion.hide();
atencion.dispose();

y nada de nada.
*/
/****************************************/



}

}

class borrar_jButton2borrar_actionAdapter implements java.awt.event.ActionListener {
borrar adaptee;

borrar_jButton2borrar_actionAdapter(borrar adaptee) {
this.adaptee = adaptee;


}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2borrar_actionPerformed(e);

}
}




/********************************************************************************/
/********************************************************************************/


class principal_jButton4_actionAdapter implements java.awt.event.ActionListener {
principal adaptee;

principal_jButton4_actionAdapter(principal adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton4_actionPerformed(e);
}
}

class principal_jButton1_actionAdapter implements java.awt.event.ActionListener {
principal adaptee;

principal_jButton1_actionAdapter(principal adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton1_actionPerformed(e);
}
}

class principal_jButton2_actionAdapter implements java.awt.event.ActionListener {
principal adaptee;

principal_jButton2_actionAdapter(principal adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton2_actionPerformed(e);
}
}

class principal_jButton5_actionAdapter implements java.awt.event.ActionListener {
principal adaptee;

principal_jButton5_actionAdapter(principal adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton5_actionPerformed(e);
}
}

class principal_jButton3_actionAdapter implements java.awt.event.ActionListener {
principal adaptee;

principal_jButton3_actionAdapter(principal adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jButton3_actionPerformed(e);
}

}

Tigre Negro
13 de Enero del 2005
Si unicamente quieres cerrar el frame sin cerrar toda la aplicacion con un el metodo dispose() lo puedes hacer o simplemente ocultando el frame

frame.setVisible(false);

Saludos

Problemas
13 de Enero del 2005
El JFrame se llama atencion, pero cuando pongo atencion.dispose(); o atencion.hide(); o bien lo oculto atencion.setVisible(false);
me dice que no puede resolver el simbolo:variable atencion en la clase borrar.
A ver si alguien me exa un cable que ya toy loco con esta mierda
Un saludo

Tigre Negro
13 de Enero del 2005
Ya revise tu codigo, para que puedas cerrar la ventana tienes crear una instancia de buscar en borrar, puedes hacer un metodo dentro de buscar que cierre el frame, y desde borrar llamas al metodo cuando hayas instanceado la clase buscar.

Saludos