39 lines
3.1 KiB
Java
39 lines
3.1 KiB
Java
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
|
||
|
public class exo5 {
|
||
|
public static void main(String[] args) {
|
||
|
// un objet pour servir de fenetre
|
||
|
JFrame fenetre = new JFrame();
|
||
|
|
||
|
// on configure la fenetre
|
||
|
fenetre.setSize(1200, 1000);
|
||
|
fenetre.setLocation(100, 100);
|
||
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||
|
|
||
|
// On crée un champ de texte
|
||
|
JTextArea zoneDeTexte = new JTextArea("Zone de texte (faut écrire ici en gros)");
|
||
|
zoneDeTexte.setForeground(Color.green); /*ou new Color(255,255,255) */
|
||
|
zoneDeTexte.setBackground(Color.black); /*ou new Color(255,255,255) */
|
||
|
zoneDeTexte.setLineWrap(true);
|
||
|
JScrollPane scrollPane = new JScrollPane(zoneDeTexte);
|
||
|
scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
|
||
|
|
||
|
|
||
|
|
||
|
// On crée une zone de texte
|
||
|
JTextField champTexte = new JTextField("Bonjour, veuillez écrire des trucs en dessous svp ! \n Pourquoi écrire un truc en bas ? La réponse est la suivante : \n Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, \nbut also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown\n printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic \ntypesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. \nIt has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum. ");
|
||
|
champTexte.setForeground(Color.green); /*ou new Color(255,255,255) */
|
||
|
champTexte.setBackground(new Color(153,153,153));
|
||
|
champTexte.setEditable(false);
|
||
|
|
||
|
|
||
|
// on ajoute le composant dans la fenetre, au milieu
|
||
|
fenetre.add(scrollPane, BorderLayout.SOUTH);
|
||
|
fenetre.add(champTexte, BorderLayout.CENTER);
|
||
|
|
||
|
|
||
|
// et on montre le resultat
|
||
|
fenetre.setVisible(true);
|
||
|
}
|
||
|
}
|