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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.Color;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Font;
import java.util.Random;
import javax.swing.JToolBar;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;
public class Aire_disquz extends JFrame {
private JPanel contentPane;
private JLabel TextInfo;
private JTextField TextSaisie;
private JButton BoutonCalcul;
/**
* Launch the application.
*/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Aire_disquz frame = new Aire_disquz();
frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the frame.
*/
public Aire_disquz() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 686, 397);
contentPane = new JPanel();
contentPane.setForeground(Color.BLUE);
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
contentPane.add(getTextInfo(z));
contentPane.add(getBoutonCalcul());
}
//détermination de la valeur z aléaoire qui sera le nombre à écrire
private int calcul(int z) {
String [] vingt = {"zéro","un","deux","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quinze","seize","dix-sept","dix-huit","dix-neuf","vingt"};
String [] dizaine = {"vingt","trente","quarante","cinquante","soixante","soixante","quatre-vingt","quatre-vingt"};
String [] centaine = {"cent","deux cents","trois cents","quatre cents","cinq cents","six cents","sept cents","huit cents","neuf cents"};
String [] mille = {"mille","deux milles","trois milles","quatre milles","cinq mille","six mille","sept mille","huit milles","neuf milles"};
Random r = new Random();
int z1 = r.nextInt(1000);
int n = z1 % 1000;
int a = n % 100;
int v = a % 10;
if (z1 <= 1000); {
}
int m = z1/ 1000;
int c = n / 100;
int d = a / 10 ;
String h = mille[m] + centaine[c] + dizaine[d] + vingt[v];
}
if (z1 >= 100){
int d = z1 / 10 ;
int c = z1 / 100;
String h = centaine[c] + dizaine[d] + vingt[v];
}
else {
if (z1>= 20) ; {
int d = z1 / 10 ;
int g = z1 % 10;
String h = dizaine[d] + vingt[g];
}
{
String h = vingt[z1];
}
}
return h;
//private
}
private JLabel getTextInfo(string h) {
if (TextInfo == null) {
TextInfo = new JLabel("Ecrivez en lettre le nombre qui s'affiche :"+ h);
TextInfo.setFont(new Font("Curlz MT", Font.PLAIN, 24));
TextInfo.setForeground(new Color(199, 21, 133));
TextInfo.setBounds(51, 11, 609, 64);
}
return TextInfo;
}
private JButton getBoutonCalcul() {
if (BoutonCalcul == null) {
BoutonCalcul = new JButton("V\u00E9rification");
BoutonCalcul.setFont(new Font("Curlz MT", Font.PLAIN, 18));
BoutonCalcul.setForeground(new Color(199, 21, 133));
BoutonCalcul.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
});
BoutonCalcul.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
}
});
BoutonCalcul.setBounds(220, 221, 233, 43);
}
return BoutonCalcul;
}
} |
Partager