IHM - Swing
JFrame - un exemple (2)
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class HelloPanel extends JPanel {
public void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawString("Bonjour", 75, 100);
} }
class Terminator extends WindowAdapter {
public void windowClosing(WindowEvent e) {
System.exit(0);
} }
8- C. Bertelle @ Universit´e du Havre
IHM - Swing
class HelloFrame extends JFrame {
public HelloFrame() {
setTitle("HelloInFrame"); setSize(300, 200);
addWindowListener(new Terminator());
Container HelloContainer = getContentPane();
HelloContainer.add(new HelloPanel());
} }
public class HelloInFrame {
public static void main(String[] args) {
JFrame frame = new HelloFrame();
frame.show();
} }
9- C. Bertelle @ Universit´e du Havre