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 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156
|
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.*;
public class EcrireImage {
public static void main (String [] arg) throws IOException {
//BufferedImage image = new BufferedImage(256, 256,
//BufferedImage.TYPE_INT_RGB);
BufferedImage image = ImageIO.read(new File("outlook.png"));
Graphics2D g1 = image.createGraphics();
g1.create();
g1.setColor(Color.green);
g1.drawString("crazy" , 10, 10);
g1.drawString("Votre Nom est", 20, 20);
//System.getProperty("line.separator");
g1.drawString("Votre Prénom est ", 20, 30);
g1.drawString("Votre Pôle est ", 20, 40);
//g1.clearRect(50, 50, 50, 50);
g1.drawString("Votre téléphone fixe est ", 20, 50);
//g1.clearRect(50, 50, 50, 50);
g1.drawString("Votre téléphone mobile est ", 20, 60);
g1.drawString("Votre Fax est ", 20, 70);
g1.drawString("Votre Email est ", 20, 80);
Font font = new Font(Font.SERIF, Font.BOLD, 40);
g1.setBackground(Color.white);
g1.setFont(font);
g1.dispose();
try {
ImageIO.write( image, "png", new File( "./toto.png" ) );
} catch(Exception ex) {
ex.printStackTrace();
}
}
public void formulaire(){
JTextField txtNom = new JTextField(10);
JTextField txtPrenom = new JTextField(10);
JTextField txtPole = new JTextField(10);
JTextField txtTelF = new JTextField(10);
JTextField txtTelM = new JTextField(10);
JTextField txtFax = new JTextField(10);
//JTextField txtAdresse = new JTextField(10);
//JTextField txtVille = new JTextField(10);
//JTextField txtPays = new JTextField(10);
JTextField txtEmail = new JTextField(10);
// Création des labels avec mnémoniques
JLabel lblNom = new JLabel("Nom", JLabel.RIGHT);
lblNom.setDisplayedMnemonic('N'); // Définir le mnémonique
lblNom.setLabelFor(txtNom); // Définir le composant qui es labelé
//JLabel lblAdresse = new JLabel("Adresse:", JLabel.RIGHT);
//lblAdresse.setDisplayedMnemonic('s');
//lblAdresse.setDisplayedMnemonicIndex(5);
//lblAdresse.setLabelFor(txtAdresse);
JLabel lblPrenom = new JLabel("Prenom:", JLabel.RIGHT);
lblPrenom.setDisplayedMnemonic('P');
lblPrenom.setDisplayedMnemonicIndex(5);
lblPrenom.setLabelFor(txtPrenom);
JLabel lblPole = new JLabel("Pole:", JLabel.RIGHT);
lblPrenom.setDisplayedMnemonic('O');
lblPrenom.setDisplayedMnemonicIndex(5);
lblPrenom.setLabelFor(txtPole);
JLabel lblTel = new JLabel("Tél:", JLabel.RIGHT);
lblPrenom.setDisplayedMnemonic('T');
lblPrenom.setDisplayedMnemonicIndex(5);
lblPrenom.setLabelFor(txtPole);
JLabel lblTelM = new JLabel("Tél mobile:", JLabel.RIGHT);
lblPrenom.setDisplayedMnemonic('M');
lblPrenom.setDisplayedMnemonicIndex(5);
lblPrenom.setLabelFor(txtTelM);
JLabel lblFax = new JLabel("Fax:", JLabel.RIGHT);
lblPrenom.setDisplayedMnemonic('F');
lblPrenom.setDisplayedMnemonicIndex(5);
lblPrenom.setLabelFor(txtFax);
//JLabel lblVille = new JLabel("Ville", JLabel.RIGHT);
//lblVille.setDisplayedMnemonic('V');
//lblVille.setLabelFor(txtVille);
//JLabel lblPays = new JLabel("Pays", JLabel.RIGHT);
//lblPays.setDisplayedMnemonic('P');
//lblPays.setLabelFor(txtPays);
JLabel lblEmail = new JLabel("Email", JLabel.RIGHT);
lblEmail.setDisplayedMnemonic('E');
lblEmail.setLabelFor(txtEmail);
JButton envoi = new JButton("Validation");
//envoi.setHorizontalAlignment(SwingConstants.RIGHT);
envoi.setHorizontalAlignment(JButton.RIGHT);
JPanel p = new JPanel( );
p.setLayout(new GridLayout(10, 4, 7, 7));
p.add(lblNom);
p.add(txtNom);
p.add(lblPrenom);
p.add(txtPrenom);
p.add(lblPole);
p.add(txtPole);
p.add(lblTel);
p.add(txtTelF);
p.add(lblTelM);
p.add(txtTelM);
p.add(lblFax);
p.add(txtFax);
//p.add(lblAdresse);
//p.add(txtAdresse);
//p.add(lblVille);
//p.add(txtVille);
//p.add(lblPays);
//p.add(txtPays);
p.add(lblEmail);
p.add(txtEmail);
p.add(envoi);
JFrame f = new JFrame("Signature Outlook");
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setContentPane(p);
f.pack( );
f.setVisible(true);
}
} |