JAL-1807 Bob's JalviewJS prototype first commit
[jalviewjs.git] / bin / jalview / appletgui / TitledPanel.js
1 Clazz.declarePackage ("jalview.appletgui");\r
2 Clazz.load (["awt2swing.Panel", "java.awt.Insets"], "jalview.appletgui.TitledPanel", null, function () {\r
3 c$ = Clazz.decorateAsClass (function () {\r
4 this.title = null;\r
5 this.$insets = null;\r
6 Clazz.instantialize (this, arguments);\r
7 }, jalview.appletgui, "TitledPanel", awt2swing.Panel);\r
8 Clazz.prepareFields (c$, function () {\r
9 this.$insets =  new java.awt.Insets (10, 10, 10, 10);\r
10 });\r
11 Clazz.makeConstructor (c$, \r
12 function () {\r
13 this.construct ("");\r
14 });\r
15 Clazz.makeConstructor (c$, \r
16 function (title) {\r
17 Clazz.superConstructor (this, jalview.appletgui.TitledPanel, []);\r
18 this.setTitle (title);\r
19 }, "~S");\r
20 Clazz.defineMethod (c$, "getInsets", \r
21 function () {\r
22 return this.$insets;\r
23 });\r
24 Clazz.defineMethod (c$, "paintComponent", \r
25 function (g) {\r
26 Clazz.superCall (this, jalview.appletgui.TitledPanel, "paintComponent", [g]);\r
27 g.setColor (this.getForeground ());\r
28 g.drawRect (5, 5, this.getWidth () - 10, this.getHeight () - 10);\r
29 var width = g.getFontMetrics ().stringWidth (this.getTitle ());\r
30 g.setColor (this.getBackground ());\r
31 g.fillRect (10, 0, width, 10);\r
32 g.setColor (this.getForeground ());\r
33 g.drawString (this.getTitle (), 10, 10);\r
34 }, "java.awt.Graphics");\r
35 Clazz.defineMethod (c$, "getTitle", \r
36 function () {\r
37 return this.title;\r
38 });\r
39 Clazz.defineMethod (c$, "setTitle", \r
40 function (title) {\r
41 this.title = title;\r
42 }, "~S");\r
43 });\r