JtextArea Affichage du flux de sortie
Bonjour,
Je souhaite afficher dans un JtextArea par exemple le résultat en sortie d'une requête sql.
Tout marche bien avec la fonction append() si la sortie ne fait que quelques lignes au-dela l'affichage est illisble.
J'ai essayé un repaint() mais cela ne marche pas.
Quelqu'un a t'il une idée ?
voici le code :
Code:
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
|
import javax.swing.*;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.Dimension;
import java.awt.Color;
//import java.awt.List;
import java.util.Vector ;
import javax.swing.event.*;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseListener;
import java.util.EventListener;
import java.awt.* ;
import java.io.*;
import java.sql.*;
//
class InstPkg extends JPanel {
//Variables
JTextArea topTextArea ;
ClientSsh ssh1 ;
//
public InstPkg() {
//Zone affichage
topTextArea = new JTextArea();
topTextArea.setEditable(false);
JScrollPane topScrollPane = new JScrollPane(topTextArea);
Dimension preferredSize = new Dimension(1100, 400);
topScrollPane.setPreferredSize(preferredSize);
//Ajout au niveau du panel
this.add(topScrollPane) ;
ClientSsh ssh1= new ClientSsh(topTextArea) ;
ssh1.Lecture_Fic_Cnx("/cadnat/script/java/outils/ssh/cmd.txt") ;
topScrollPane.repaint() ;
}
private static void showgui()
{
JFrame bt = new JFrame("Installation de Package Version 1.0 ") ;
bt.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = bt.getContentPane() ;
c.setLayout(new BorderLayout()) ;
InstPkg ma = new InstPkg () ;
c.add(ma) ;
bt.setSize(1200,800) ;
bt.setVisible(true) ;
}
public static void main (String [] args)
{
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
showgui() ;
}
});
}
} |