Hola me gustaria ayudarte, mi forma de programar es un poco mas personal y muchos de los programas las realizo para mi uso, a mi estilo. Te envio este fracmento de codigo para que lo revises y si tienes dudas me consultas a mi correo (
[email protected]), hago mis propias Ventanas con botones, JTextfield, JLabel y demas.......
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Buscaminas extends JFrame implements MouseListener
{ public JPanel panel;
JButton[][] boton;
int x,y;
public Buscaminas(int fila,int columna)
{ setTitle(".:: BUSCAMINAS ::.");
x=fila; y=columna;
boton=new JButton[x][y];
setResizable(false);
setBounds(550,100,x*30,y*30);
setDefaultCloseOperation(EXIT_ON_CLOSE);
panel=new JPanel();
panel.setLayout(new GridLayout(fila,columna));
for(int i=0;i<x;i++)
{ for(int j=0;j<y;j++)
{ boton[i][j]=new JButton(getImageIconSize(/*
*/new ImageIcon("imagen/button_normal.jpg"),25,20));
boton[i][j].addMouseListener(this);
panel.add(boton[i][j]);
}
}
getContentPane().add(panel, BorderLayout.CENTER);
SwingUtilities.updateComponentTreeUI(this);
show();
}
//Falta crear la lógica.
public void mouseReleased(MouseEvent e){}
public void mousePressed(MouseEvent e){}
public void mouseExited(MouseEvent e)
{ Object oo=e.getSource();
for(int i=0;i<x;i++)
{ for(int j=0;j<y;j++)
{ if(oo==boton[i][j])
{ boton[i][j].setIcon(getImageIconSize(/*
*/new ImageIcon("imagen/button_normal.jpg"),25,20));
}
}
}
}
public void mouseEntered(MouseEvent e)
{ Object oo=e.getSource();
for(int i=0;i<x;i++)
{ for(int j=0;j<y;j++)
{ if(oo==boton[i][j])
{ boton[i][j].setIcon(getImageIconSize(/*
*/new ImageIcon("imagen/button_pressed.jpg"),25,20));
}
}
}
}
public void mouseClicked(MouseEvent e)
{ Object oo=e.getSource();
Sonido s2=new Sonido();
s2.Music("pulsar.wav");
for(int i=0;i<x;i++)
{ for(int j=0;j<y;j++)
{ if(oo==boton[i][j])
{ boton[i][j].removeMouseListener(this);
boton[i][j].setIcon(getImageIconSize(/*
*/new ImageIcon("imagen/bomba.gif"),18,15));
}
}
}
}
public ImageIcon getImageIconSize(ImageIcon icono,int ancho,int alto)
{ icono.setImage(icono.getImage().getScaledInstance(/*
*/ancho,alto,Image.SCALE_REPLICATE));
return icono;
}
public static void main(String Blad[])
{ new Buscaminas(8,8);
}
}