-package javajs.swing;\r
-\r
-import javajs.awt.Container;\r
-import javajs.util.SB;\r
-\r
-public class JSplitPane extends JComponent {\r
-\r
- public static final int HORIZONTAL_SPLIT = 1;\r
- boolean isH = true;\r
- private int split = 1;\r
- private Container right;\r
- private Container left;\r
-\r
- public JSplitPane(int split) {\r
- super("JSpP");\r
- this.split = split;\r
- isH = (split == HORIZONTAL_SPLIT);\r
- }\r
- \r
- public void setRightComponent(JComponent r) {\r
- right = new JComponentImp(null);\r
- right.add(r); \r
- }\r
-\r
- public void setLeftComponent(JComponent l) {\r
- left = new JComponentImp(null);\r
- left.add(l);\r
- }\r
-\r
- @Override\r
- public int getSubcomponentWidth() {\r
- int w = this.width;\r
- if (w == 0) {\r
- int wleft = left.getSubcomponentWidth();\r
- int wright = right.getSubcomponentWidth();\r
- if (wleft > 0 && wright > 0) {\r
- if (isH)\r
- w = wleft + wright;\r
- else\r
- w = Math.max(wleft, wright);\r
- }\r
- }\r
- return w;\r
- }\r
- \r
- @Override\r
- public int getSubcomponentHeight() {\r
- int h = this.height;\r
- if (h == 0) {\r
- int hleft = left.getSubcomponentHeight();\r
- int hright = right.getSubcomponentHeight();\r
- if (hleft > 0 && hright > 0) {\r
- if (isH)\r
- h = Math.max(hleft, hright);\r
- else\r
- h = hleft + hright;\r
- }\r
- }\r
- return h;\r
- }\r
- \r
- @Override\r
- public String toHTML() {\r
- if (left == null || right == null)\r
- return "";\r
- boolean isH = (split == HORIZONTAL_SPLIT);\r
- if (width == 0)\r
- width = getSubcomponentWidth();\r
- if (height == 0)\r
- height = getSubcomponentHeight();\r
- SB sb = new SB();\r
- sb.append("<div id='" + id + "' class='JSplitPane' style='" + getCSSstyle(100, 100) + "'>");\r
- if (isH) \r
- sb.append("<div id='" + id + "_left' style='width:50%;height:100%;position:absolute;top:0%;left:0%'>");\r
- else\r
- sb.append("<div id='" + id + "_top' style='width:100%;height:50%;position:absolute;top:0%;left:0%'>");\r
- sb.append(left.getComponents()[0].toHTML());\r
- if (isH) \r
- sb.append("</div><div id='" + id + "_right' style='width:50%;height:100%;position:absolute;top:0%;left:50%'>");\r
- else\r
- sb.append("</div><div id='" + id + "_bottom' style='width:100%;height:50%;position:absolute;top:50%;left:0%'>");\r
- sb.append(right.getComponents()[0].toHTML());\r
- sb.append("</div></div>\n");\r
- return sb.toString();\r
- }\r
-\r
-\r
-}\r
+package javajs.swing;
+
+import javajs.awt.Container;
+import javajs.util.SB;
+
+public class JSplitPane extends JComponent {
+
+ public static final int HORIZONTAL_SPLIT = 1;
+ boolean isH = true;
+ private int split = 1;
+ private Container right;
+ private Container left;
+
+ public JSplitPane(int split) {
+ super("JSpP");
+ this.split = split;
+ isH = (split == HORIZONTAL_SPLIT);
+ }
+
+ public void setRightComponent(JComponent r) {
+ right = new JComponentImp(null);
+ right.add(r);
+ }
+
+ public void setLeftComponent(JComponent l) {
+ left = new JComponentImp(null);
+ left.add(l);
+ }
+
+ @Override
+ public int getSubcomponentWidth() {
+ int w = this.width;
+ if (w == 0) {
+ int wleft = left.getSubcomponentWidth();
+ int wright = right.getSubcomponentWidth();
+ if (wleft > 0 && wright > 0) {
+ if (isH)
+ w = wleft + wright;
+ else
+ w = Math.max(wleft, wright);
+ }
+ }
+ return w;
+ }
+
+ @Override
+ public int getSubcomponentHeight() {
+ int h = this.height;
+ if (h == 0) {
+ int hleft = left.getSubcomponentHeight();
+ int hright = right.getSubcomponentHeight();
+ if (hleft > 0 && hright > 0) {
+ if (isH)
+ h = Math.max(hleft, hright);
+ else
+ h = hleft + hright;
+ }
+ }
+ return h;
+ }
+
+ @Override
+ public String toHTML() {
+ if (left == null || right == null)
+ return "";
+ boolean isH = (split == HORIZONTAL_SPLIT);
+ if (width == 0)
+ width = getSubcomponentWidth();
+ if (height == 0)
+ height = getSubcomponentHeight();
+ SB sb = new SB();
+ sb.append("<div id='" + id + "' class='JSplitPane' style='" + getCSSstyle(100, 100) + "'>");
+ if (isH)
+ sb.append("<div id='" + id + "_left' style='width:50%;height:100%;position:absolute;top:0%;left:0%'>");
+ else
+ sb.append("<div id='" + id + "_top' style='width:100%;height:50%;position:absolute;top:0%;left:0%'>");
+ sb.append(left.getComponents()[0].toHTML());
+ if (isH)
+ sb.append("</div><div id='" + id + "_right' style='width:50%;height:100%;position:absolute;top:0%;left:50%'>");
+ else
+ sb.append("</div><div id='" + id + "_bottom' style='width:100%;height:50%;position:absolute;top:50%;left:0%'>");
+ sb.append(right.getComponents()[0].toHTML());
+ sb.append("</div></div>\n");
+ return sb.toString();
+ }
+
+
+}