1 package javajs.swing;
\r
3 public class JMenuItem extends AbstractButton {
\r
5 public final int btnType;
\r
7 public static final int TYPE_SEPARATOR = 0;
\r
8 public static final int TYPE_BUTTON = 1;
\r
9 public static final int TYPE_CHECKBOX = 2;
\r
10 public static final int TYPE_RADIO = 3;
\r
11 public static final int TYPE_MENU = 4;
\r
14 public JMenuItem(String text) {
\r
17 btnType = (text == null ? 0 : 1);
\r
20 public JMenuItem(String type, int i) {
\r
26 public String toHTML() {
\r
27 return htmlMenuOpener("li")
\r
28 + (text == null ? "" : "<a>" + htmlLabel() + "</a>") + "</li>";
\r
32 protected String getHtmlDisabled() {
\r
33 return " class=\"ui-state-disabled\"";
\r
36 private String htmlLabel() {
\r
37 return (btnType == TYPE_BUTTON ? text
\r
38 : "<label><input id=\"" + id + "-" + (btnType == TYPE_RADIO ? "r" : "c")
\r
40 + (btnType == TYPE_RADIO ? "radio\" name=\"" + htmlName : "checkbox")
\r
41 + "\" " + (selected ? "checked" : "") + " />"
\r
42 + text + "</label>");
\r