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
|
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.print.PrinterException;
import javax.swing.*;
public class Imprimante extends JFrame {
private JLabel bonjour = new JLabel("Bonjour ");
private JToolBar barre = new JToolBar();
private Container contenu3 = getContentPane() ;
public Imprimante() {
super("Impression");
barre.add(new AbstractAction("Imprimer") {
public void actionPerformed(ActionEvent e) {
try{
contenu3.print();
}catch (Exception ev) {
// TODO: handle exception
}
}
});
add(barre, BorderLayout.NORTH);
add(new JScrollPane(contenu3));
contenu3.setLayout (null) ;
contenu3.add(bonjour);
add(bonjour);
//
setSize(300, 250);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
} |
Partager