FileDocCategorySizeDatePackage
HeaderPanel.javaAPI DocExample2415Mon 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 Drag n' Ghost 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("Try to drag the pictures and the buttons to drop them over the table."));
        police = titreEnTete.getFont().deriveFont(Font.PLAIN);
        titre.setFont(police);
        titre.setBorder(new EmptyBorder(0, 24, 0, 0));
        titres.add(titre = new JLabel("You can also try to drag the gray area below the table rows."));
        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);