X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=src%2Fjavajs%2Fswing%2FJSplitPane.java;fp=src%2Fjavajs%2Fswing%2FJSplitPane.java;h=3662cf96c68d4b4ff5e2558973faa67869c4dd1f;hp=b236d88f525003ace64116860c238772782b79c6;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/src/javajs/swing/JSplitPane.java b/src/javajs/swing/JSplitPane.java index b236d88..3662cf9 100644 --- a/src/javajs/swing/JSplitPane.java +++ b/src/javajs/swing/JSplitPane.java @@ -1,88 +1,88 @@ -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("
"); - if (isH) - sb.append("
"); - else - sb.append("
"); - sb.append(left.getComponents()[0].toHTML()); - if (isH) - sb.append("
"); - else - sb.append("
"); - sb.append(right.getComponents()[0].toHTML()); - sb.append("
\n"); - return sb.toString(); - } - - -} +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("
"); + if (isH) + sb.append("
"); + else + sb.append("
"); + sb.append(left.getComponents()[0].toHTML()); + if (isH) + sb.append("
"); + else + sb.append("
"); + sb.append(right.getComponents()[0].toHTML()); + sb.append("
\n"); + return sb.toString(); + } + + +}