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