36 lines
1.2 KiB
Java
36 lines
1.2 KiB
Java
import javax.swing.*;
|
|
import java.awt.*;
|
|
|
|
public class Contingence{
|
|
|
|
public static void main(String[] args){
|
|
JFrame fenetre = new JFrame(); //Objet representant la fenetre
|
|
fenetre.setSize(500, 300); //taille de la fenetre
|
|
fenetre.setLocation(0, 0); //position de la fenetre dans l'ecran
|
|
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
|
|
|
Color vert = new Color(0,255,0);
|
|
Color noir = new Color(0,0,0);
|
|
Color gris = new Color(100,100,100);
|
|
|
|
JTextField champDeTexte = new JTextField("Champ de texte");
|
|
champDeTexte.setHorizontalAlignment(JTextField.CENTER);
|
|
champDeTexte.setBackground(gris);
|
|
champDeTexte.setForeground(vert);
|
|
fenetre.add(champDeTexte, BorderLayout.SOUTH);
|
|
|
|
JTextArea zoneDeTexte = new JTextArea("Zone de texte");
|
|
zoneDeTexte.setBackground(noir);
|
|
zoneDeTexte.setForeground(vert);
|
|
zoneDeTexte.setLineWrap(true);
|
|
|
|
JScrollPane scrollView = new JScrollPane(zoneDeTexte);
|
|
scrollView.createHorizontalScrollBar();
|
|
scrollView.setVerticalScrollBarPolicy(scrollView.VERTICAL_SCROLLBAR_ALWAYS);
|
|
fenetre.add(scrollView, BorderLayout.CENTER);
|
|
|
|
fenetre.setVisible(true);
|
|
|
|
}
|
|
}
|