1 package jalview.appletgui;
3 import awt2swing.Frame;
4 import java.awt.Graphics;
5 import java.awt.Insets;
6 import awt2swing.Label;
7 import awt2swing.Panel;
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 paintComponent(Graphics g)
35 super.paintComponent(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 awt2swing.Util.drawString(g, getTitle(), 10, 10);
50 public static void main(String[] args)
52 Frame f = new Frame("TitledPanel Tester");
54 TitledPanel p = new TitledPanel("Title of Panel");
55 p.add(new Label("Label 1"));
56 p.add(new Label("Label 2"));
57 p.add(new Label("Label 3"));
60 f.addWindowListener(new WindowAdapter()
62 public void windowClosing(WindowEvent e)
67 f.setBounds(300, 300, 300, 300);
71 public String getTitle()
76 public void setTitle(String title)