1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| public class monprog extends JFrame implements MouseListener
{
.
.
static JButton cases[][] = new JButton[10][10];
initialisation();
.
.
public static void initialisation()
{
.
.
cases[ ligne ][ col ] = new JButton();
.
.
}
.
.
public void mousePressed(MouseEvent e)
{
String val_texte = null;
float val = 0;
while( val<=0 || val>9 )
{val_texte = javax.swing.JOptionPane.showInputDialog( "Valeur : ", "Valeur");
if( val_texte != "" && val_texte!="Valeur") val = Float.parseFloat( val_texte );
}
JButton choix = ( JButton ) e.getSource();
choix.setBackground( Color.white);
if( val != 0 )
{ choix.setText( val_texte );
choix.setFont( new Font("LucidaBrightDemiBold",Font.ITALIC,60) );
choix.setForeground( Color.black );
}
}; |
Partager