1 package jalview.appletgui;
4 import java.awt.Graphics;
5 import java.awt.Insets;
8 import java.awt.event.WindowAdapter;
9 import java.awt.event.WindowEvent;
11 public class TitledPanel extends Panel
16 private Insets insets = new Insets(10, 10, 10, 10);
23 public TitledPanel(String title)
28 public Insets getInsets()
33 public void paint(Graphics g)
36 g.setColor(getForeground());
37 g.drawRect(5, 5, getWidth() - 10, getHeight() - 10);
38 int width = g.getFontMetrics().stringWidth(getTitle());
39 g.setColor(getBackground());
40 g.fillRect(10, 0, width, 10);
41 g.setColor(getForeground());
42 g.drawString(getTitle(), 10, 10);
45 public static void main(String[] args)
47 Frame f = new Frame("TitledPanel Tester");
49 TitledPanel p = new TitledPanel("Title of Panel");
50 p.add(new Label("Label 1"));
51 p.add(new Label("Label 2"));
52 p.add(new Label("Label 3"));
55 f.addWindowListener(new WindowAdapter()
57 public void windowClosing(WindowEvent e)
62 f.setBounds(300, 300, 300, 300);
66 public String getTitle()
71 public void setTitle(String title)