1 package javajs.swing;
\r
3 import javajs.awt.Color;
\r
4 import javajs.awt.Container;
\r
5 import javajs.util.SB;
\r
9 * There is really no need here for awt.Dialog.
\r
10 * We would not use FileDialog in an HTML5 context anyway.
\r
13 public class JDialog extends Container {
\r
15 private static final int headerHeight = 25;
\r
16 private int defaultWidth = 600;
\r
17 private int defaultHeight = 300;
\r
19 private JContentPane contentPane;
\r
20 private String title;
\r
21 private String html;
\r
22 private int zIndex = 9000;
\r
24 public void setZIndex(int zIndex) {
\r
25 this.zIndex = zIndex;
\r
32 add(contentPane = new JContentPane());
\r
33 setBackground(Color.get3(210, 210, 240));
\r
34 contentPane.setBackground(Color.get3(230, 230, 230));
\r
37 public void setLocation(int[] loc) {
\r
41 public JContentPane getContentPane() {
\r
45 public void setTitle(String title) {
\r
49 public void pack() {
\r
53 public void validate() {
\r
58 public void setVisible(boolean tf) {
\r
59 if (tf && html == null)
\r
61 super.setVisible(tf);
\r
64 public void dispose() {
\r
70 * SwingController.dispose(this);
\r
80 public void repaint() {
\r
85 * Set it into DOM, but don't show it yet.
\r
86 * this.loc, this.manager, this.id, etc.
\r
89 private void setDialog() {
\r
94 * SwingController.setDialog(this);
\r
99 System.out.println(html);
\r
104 public String toHTML() {
\r
105 renderWidth = getSubcomponentWidth();
\r
106 if (renderWidth == 0)
\r
107 renderWidth = defaultWidth;
\r
108 renderHeight = contentPane.getSubcomponentHeight();
\r
109 if (renderHeight == 0)
\r
110 renderHeight = defaultHeight;
\r
111 int h = renderHeight - headerHeight;
\r
113 sb.append("\n<div id='" + id + "' class='JDialog' style='" + getCSSstyle(0, 0) + "z-index:" + zIndex + ";position:relative;top:0px;left:0px;reize:both;'>\n");
\r
114 sb.append("\n<div id='" + id + "_title' class='JDialogTitle' style='width:100%;height:25px;padding:5px 5px 5px 5px;height:"+headerHeight+"px'>"
\r
115 +"<span style='text-align:center;'>" + title + "</span><span style='position:absolute;text-align:right;right:1px;'>"
\r
116 + "<input type=button id='" + id + "_closer' onclick='SwingController.windowClosing(this)' value='x' /></span></div>\n");
\r
117 sb.append("\n<div id='" + id + "_body' class='JDialogBody' style='width:100%;height:"+h+"px;"
\r
118 +"position: relative;left:0px;top:0px'>\n");
\r
119 sb.append(contentPane.toHTML());
\r
120 sb.append("\n</div></div>\n");
\r
121 return sb.toString();
\r