|  Peroblema al borrar JtextFields de un Panel  
  Buenas a todos gracias por entrar.Estoy introduciendome en el mundo del AWT de java, haciendo un programa que dado un sudoku lo resuelva :) (intentandolo ya que esa parte aun no esta XD ).
 
 Quiero poner un boton que borre el sudoku y ponga todas las casilla a "-" , pero no veo manera de hacerlo. podeis hecharme una mano por favor? adjunto el codigo poniendo en negro el codigo del boton BORRAR. Habia pensado eliminar con remove el panel p o hacer un removeAll sobre p para quitar las "casillas" y luego volver a ponerlas, pero no funciona, se me queda sin opcion a clickarlas.
 
 
 package calc;
 
 import java.awt.*;
 import java.awt.event.*;
 import javax.swing.*;
 
 
 public class aplicacion extends JFrame implements ActionListener {
 
 private JTextField t;
 String labelTexts[] = {"-","-","-","-","-","-","-","-","-", "-","-","-","-","-","-","-","-","-", "-","-","-","-","-","-","-","-","-", "-","-","-","-","-","-","-","-","-",
 "-","-","-","-","-","-","-","-","-", "-","-","-","-","-","-","-","-","-", "-","-","-","-","-","-","-","-","-", "-","-","-","-","-","-","-","-","-",
 "-","-","-","-","-","-","-","-","-"} ;
 JPanel p = new JPanel();
 JPanel cp = (JPanel) this.getContentPane();
 
 public aplicacion() {
 super("Sudoku Finish 0.1");
 String labelButtons[] = {"Resolver", "Borrar"};
 JPanel cp = (JPanel) this.getContentPane();
 // cp.setLayout(new BorderLayout());
 //  JPanel p = new JPanel();
 p.setLayout(new GridLayout(10,9));
 //Numeros del Sudoku
 for (int i = 0; i < labelTexts.length; ++i) {
 JTextField casilla = new JTextField(labelTexts[i]);
 //casilla.addActionListener(this);
 
 
 
 casilla.addFocusListener(new FocusListener()
 {
 public void focusLost(FocusEvent e)
 {
 //      System.out.println("Perdido foco");
 //      System.out.println(((JTextField)e.getSource()).get  Text());
 String s = ((JTextField)e.getSource()).getText();
 char ar[] = s.toCharArray();
 
 if ((ar[0] != '-'))
 {
 if ((ar[0] == '1') || (ar[0] == '2')  || (ar[0] == '3') || (ar[0] == '4') || (ar[0] == '5') || (ar[0] == '6') || (ar[0] == '7') || (ar[0] == '8') || (ar[0] == '9'))
 {
 ((JTextField)e.getSource()).setText(s);
 t.setText("Numero Introducido Correctamente");
 }
 else
 {
 ((JTextField)e.getSource()).setText("-");
 t.setText("Error al introducir un numero");
 }
 }
 else
 {
 ((JTextField)e.getSource()).setText("-");
 t.setText("Error al introducir un numero");
 }
 
 }
 
 public void focusGained(FocusEvent e) {
 // No hacemos nada
 }
 });
 
 p.add(casilla);
 
 
 
 }
 JPanel pz = new JPanel();
 //Botones del sudoku
 for (int i = 0; i < labelButtons.length; ++i) {
 JButton button = new JButton(labelButtons[i]);
 button.addActionListener(this);
 pz.add(button);
 }
 t = new JTextField();
 t.setHorizontalAlignment(JTextField.RIGHT);
 t.setText("0");
 cp.add(t, BorderLayout.PAGE_START);
 cp.add(p, BorderLayout.CENTER);
 cp.add(pz, BorderLayout.SOUTH);
 this.setSize(500, 500);
 this.setVisible(true);
 this.setDefaultCloseOperation(aplicacion.EXIT_ON_C  LOSE);
 
 
 
 
 
 
 }
 
 public static void main(String[] args) {
 new aplicacion();
 }
 
 
 
 
 
 public void actionPerformed(ActionEvent e) {
 char c = ((JButton) e.getSource()).getText().charAt(0);
 switch (c)
 {
 case 'B':
 t.setText("Sudoku Borrado con Exito");
 cp.remove(p);
 cp.validate();
 
 break;
 
 
 }
 
 
 //  System.out.print(" ");
 
 }
 }
     |