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
|
public class Tony_big extends PlainDocument{
// variables *********************
static JDialog dial;
final HashMap m = new HashMap();
JTextArea jtaPourUneBig;
// Constructeur *******************
public Tony_big() {
super.createDefaultRoot();
this.getDefaultRootElement();
int i=0;
long deb = System.currentTimeMillis();
// Crée la map pour test
while(i++ < 90000) {
String cle = "test_" + i;
String objet = "dflgjdflgjldfjl56456464:5:646456;:4:4k64";
m.put(cle, objet);
}
long fin = System.currentTimeMillis();
String detailChargement =
"chargement en " + (fin - deb) + " millisecondes";
deb = fin;
String uneLigne = detailChargement + "\n";
for(Iterator I = m.keySet().iterator();I.hasNext();) {
Object tmp = I.next();
uneLigne = " " + tmp + "\t" + m.get(I.next()) ;
try {
this.getDefaultRootElement().getDocument().
insertString(this.getLength(), uneLigne + "\n",null);
}catch(BadLocationException ble) {
/* */ System.out.println("Erreur maBigMap : " + ble);}
}
fin = System.currentTimeMillis();
uneLigne = " DetailDocument insertion " +
(fin - deb) + "millisecondes" ;
try {
this.getDefaultRootElement().getDocument().
insertString(this.getLength(), uneLigne + "\n",null);
}catch (BadLocationException ble) {
/* */ System.out.println("Erreur maBigMap : " + ble);}
// initialise un dialog ********
dial = new JDialog(new JFrame());
initGUI();
dial.setTitle("jtaPourUneBig");
dial.setVisible(true);
// place le contenu de la map. **
jtaPourUneBig.setDocument(this);
}// fin constructeur
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
new Tony_big();
}
private void initGUI() {
dial.setSize (600,400);
dial.getContentPane().setLayout(null);
dial.setTitle("");
try {
{
// ********** Boutton Quitter
JButton jbQuitter= new JButton("Quitter");
jbQuitter.setBounds(10, 10, 80, 20);
jbQuitter.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});
dial.getContentPane().add(jbQuitter);
}
{
JPanel panel = new JPanel();
dial.getContentPane().add(panel);
panel.setBounds(10, 40, 500, 350);
panel.setVisible(true);
panel.setLayout(null);
panel.setBorder(
BorderFactory.createBevelBorder(
BevelBorder.LOWERED, null, null, null, null));
{
JScrollPane jspSaisie = new JScrollPane();
jspSaisie.setAutoscrolls(true);
panel.add(jspSaisie);
jspSaisie.setBounds(0, 0, 500, 350);
{
jtaPourUneBig = new JTextArea();
jtaPourUneBig.setBounds(20,20, 550, 380);
jspSaisie.setViewportView(jtaPourUneBig);
jtaPourUneBig.setEditable(true);
jtaPourUneBig.setEnabled(true);
}
}
}
} catch (Exception e) {
e.printStackTrace();System.out.println("Erreur initGuy:"); }
}// fin init
}// fin de classe |