JAL-1807 includes ?j2sdebug flag and DebugJS._(msg)
[jalviewjs.git] / bin / javajs / swing / JComboBox.js
1 Clazz.declarePackage ("javajs.swing");
2 Clazz.load (["javajs.swing.AbstractButton"], "javajs.swing.JComboBox", ["javajs.util.SB"], function () {
3 c$ = Clazz.decorateAsClass (function () {
4 this.info = null;
5 this.selectedIndex = 0;
6 Clazz.instantialize (this, arguments);
7 }, javajs.swing, "JComboBox", javajs.swing.AbstractButton);
8 Clazz.makeConstructor (c$, 
9 function (info) {
10 Clazz.superConstructor (this, javajs.swing.JComboBox, ["cmbJCB"]);
11 this.info = info;
12 }, "~A");
13 Clazz.defineMethod (c$, "setSelectedIndex", 
14 function (i) {
15 this.selectedIndex = i;
16 {
17 SwingController.setSelectedIndex(this);
18 }}, "~N");
19 Clazz.defineMethod (c$, "getSelectedIndex", 
20 function () {
21 return this.selectedIndex;
22 });
23 Clazz.defineMethod (c$, "getSelectedItem", 
24 function () {
25 return (this.selectedIndex < 0 ? null : this.info[this.selectedIndex]);
26 });
27 Clazz.overrideMethod (c$, "toHTML", 
28 function () {
29 var sb =  new javajs.util.SB ();
30 sb.append ("\n<select id='" + this.id + "' class='JComboBox' onchange='SwingController.click(this)'>\n");
31 for (var i = 0; i < this.info.length; i++) sb.append ("\n<option class='JComboBox_option'" + (i == this.selectedIndex ? "selected" : "") + ">" + this.info[i] + "</option>");
32
33 sb.append ("\n</select>\n");
34 return sb.toString ();
35 });
36 });