X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=unused%2Fappletgui%2FTitledPanel.java;h=a1adb146cb6eb7f48ed715cc95175d9691058fe7;hb=6319110ce33faa76ee6cf9832e78faa224510fed;hp=05f0a4f30ea1a562e6b8253b78e4b1bfc470bd5d;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44;p=jalviewjs.git diff --git a/unused/appletgui/TitledPanel.java b/unused/appletgui/TitledPanel.java index 05f0a4f..a1adb14 100644 --- a/unused/appletgui/TitledPanel.java +++ b/unused/appletgui/TitledPanel.java @@ -1,75 +1,75 @@ -package jalview.appletgui; - -import javax.swing.JFrame; -import java.awt.Graphics; -import java.awt.Insets; -import javax.swing.JLabel; -import javax.swing.JPanel; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; - -public class TitledPanel extends JPanel -{ - - private String title; - - private Insets insets = new Insets(10, 10, 10, 10); - - public TitledPanel() - { - this(""); - } - - public TitledPanel(String title) - { - this.setTitle(title); - } - - public Insets getInsets() - { - return insets; - } - - public void paint(Graphics g) - { - super.paint(g); - g.setColor(getForeground()); - g.drawRect(5, 5, getWidth() - 10, getHeight() - 10); - int width = g.getFontMetrics().stringWidth(getTitle()); - g.setColor(getBackground()); - g.fillRect(10, 0, width, 10); - g.setColor(getForeground()); - g.drawString(getTitle(), 10, 10); - } - - public static void main(String[] args) - { - JFrame f = new JFrame("TitledPanel Tester"); - - TitledPanel p = new TitledPanel("Title of Panel"); - p.add(new JLabel("Label 1")); - p.add(new JLabel("Label 2")); - p.add(new JLabel("Label 3")); - f.add(p); - - f.addWindowListener(new WindowAdapter() - { - public void windowClosing(WindowEvent e) - { - System.exit(0); - } - }); - f.setBounds(300, 300, 300, 300); - f.setVisible(true); - } - - public String getTitle() - { - return title; - } - - public void setTitle(String title) - { - this.title = title; - } +package jalview.appletgui; + +import javax.swing.JFrame; +import java.awt.Graphics; +import java.awt.Insets; +import javax.swing.JLabel; +import javax.swing.JPanel; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +public class TitledPanel extends JPanel +{ + + private String title; + + private Insets insets = new Insets(10, 10, 10, 10); + + public TitledPanel() + { + this(""); + } + + public TitledPanel(String title) + { + this.setTitle(title); + } + + public Insets getInsets() + { + return insets; + } + + public void paint(Graphics g) + { + super.paint(g); + g.setColor(getForeground()); + g.drawRect(5, 5, getWidth() - 10, getHeight() - 10); + int width = g.getFontMetrics().stringWidth(getTitle()); + g.setColor(getBackground()); + g.fillRect(10, 0, width, 10); + g.setColor(getForeground()); + g.drawString(getTitle(), 10, 10); + } + + public static void main(String[] args) + { + JFrame f = new JFrame("TitledPanel Tester"); + + TitledPanel p = new TitledPanel("Title of Panel"); + p.add(new JLabel("Label 1")); + p.add(new JLabel("Label 2")); + p.add(new JLabel("Label 3")); + f.add(p); + + f.addWindowListener(new WindowAdapter() + { + public void windowClosing(WindowEvent e) + { + System.exit(0); + } + }); + f.setBounds(300, 300, 300, 300); + f.setVisible(true); + } + + public String getTitle() + { + return title; + } + + public void setTitle(String title) + { + this.title = title; + } } \ No newline at end of file