FileDocCategorySizeDatePackage
HeaderPanel.javaAPI DocExample2381Mon Jan 09 11:02:00 GMT 2006None

HeaderPanel

public class HeaderPanel extends JPanel

Fields Summary
private ImageIcon
icone
Constructors Summary
public HeaderPanel()

        super(new BorderLayout());

        this.icone = UIHelper.readImageIcon("accueil.png");

        JPanel titres = new JPanel(new GridLayout(3, 1));
        titres.setOpaque(false);
        titres.setBorder(new EmptyBorder(12, 0, 12, 0));

        JLabel titreEnTete = new JLabel("Welcome to the Spotlights demo.");
        Font police = titreEnTete.getFont().deriveFont(Font.BOLD);
        titreEnTete.setFont(police);
        titreEnTete.setBorder(new EmptyBorder(0, 12, 0, 0));
        titres.add(titreEnTete);

        JLabel titre;
        titres.add(titre = new JLabel("Search for sci-fi, books, adams or pratchett"));
        police = titreEnTete.getFont().deriveFont(Font.PLAIN);
        titre.setFont(police);
        titre.setBorder(new EmptyBorder(0, 24, 0, 0));
        titres.add(titre = new JLabel("When spotlights appear, click to shed the light again."));
        police = titreEnTete.getFont().deriveFont(Font.PLAIN);
        titre.setFont(police);
        titre.setBorder(new EmptyBorder(0, 24, 0, 0));

        titre = new JLabel(this.icone);
        titre.setBorder(new EmptyBorder(0, 0, 0, 12));

        add(BorderLayout.WEST, titres);
        add(BorderLayout.EAST, titre);

        setPreferredSize(new Dimension(500, this.icone.getIconHeight() + 24));
    
Methods Summary
public voidpaintComponent(java.awt.Graphics g)

        super.paintComponent(g);
        if (!isOpaque()) {
            return;
        }

        Color control = UIManager.getColor("control");
        int width = getWidth();
        int height = getHeight();

        Graphics2D g2 = (Graphics2D) g;
        Paint storedPaint = g2.getPaint();
        g2.setPaint(new GradientPaint(this.icone.getIconWidth(), 0, Color.white, width, 0, control));
        g2.fillRect(0, 0, width, height);
        g2.setPaint(storedPaint);