TP 2 - LIPN, Paris 13

Exercice n°1 : import javax.swing.*; ... getScreenSize();. awindow.setBounds(
wndSize.width/4, wndSize.height/4,. wndSize.width/2, wndSize.height/2);.
awindow.

Part of the document


C. Recanati
Java Graphique
AIR2, 2015
Eléments pour la feuille de TP n° 2
Exercice n°1 :
import javax.swing.*;
import java.awt.*; public class TryFlowLayout {
static JFrame awindow= new JFrame("Ceci est un FlowLayout");
public static void main(String[] args) { Toolkit leKit = awindow.getToolkit();
Dimension wndSize = leKit.getScreenSize();
awindow.setBounds(wndSize.width/4, wndSize.height/4,
wndSize.width/2, wndSize.height/2);
awindow.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container content = awindow.getContentPane();
FlowLayout flow = new FlowLayout();
content.setLayout(flow); // Ajoutons six boutons
// avec des fontes de tailles différentes
Font fonts[]= {new Font("Arial", Font.BOLD, 24),
new Font("serif", Font.ITALIC, 14),
};
JButton bt;
for ( int i=1; i