X-Git-Url: http://source.jalview.org/gitweb/?p=jalviewjs.git;a=blobdiff_plain;f=src%2Fjavajs%2Fswing%2FAbstractButton.java;fp=src%2Fjavajs%2Fswing%2FAbstractButton.java;h=3ea6ab9ea947636fdac7520b126e20a0a279cd08;hp=388f44ee548f4dfa578e750af8f8c205416514a9;hb=b9b7a352eee79b7764c3b09c9d19663075061d8c;hpb=7301a2415adab88038b291fc54caeeb3a5a47a44 diff --git a/src/javajs/swing/AbstractButton.java b/src/javajs/swing/AbstractButton.java index 388f44e..3ea6ab9 100644 --- a/src/javajs/swing/AbstractButton.java +++ b/src/javajs/swing/AbstractButton.java @@ -1,118 +1,118 @@ -package javajs.swing; - -import javajs.awt.Component; - -import javajs.api.SC; - -public abstract class AbstractButton extends JComponent implements SC { - - Object itemListener; - Object applet; - String htmlName; - boolean selected; - - private SC popupMenu; - - private String icon; - - protected AbstractButton(String type) { - super(type); - enabled = true; - } - - @Override - public void setSelected(boolean selected) { - this.selected = selected; - /** - * @j2sNative - * - * SwingController.setSelected(this); - * - */ - { - } - } - - @Override - public boolean isSelected() { - return selected; - } - - @Override - public void addItemListener(Object listener) { - itemListener = listener; - } - - @Override - public Object getIcon() { - return icon; - } - - @Override - public void setIcon(Object icon) { - this.icon = (String) icon; - } - - @Override - public void init(String text, Object icon, String actionCommand, SC popupMenu) { - this.text = text; - this.icon = (String) icon; - this.actionCommand = actionCommand; - this.popupMenu = popupMenu; - /** - * @j2sNative - * - * SwingController.initMenuItem(this); - * - */ - { - } - } - - public SC getTopPopupMenu() { - // note that JMenu.getPopupMenu refers to ITSELF, not the main one) - return popupMenu; - } - - @Override - public void add(SC item) { - addComponent((Component) item); - } - - @Override - public void insert(SC subMenu, int index) { - // JMenu, JPopupMenu only, but implemented here as well - // for simplicity - insertComponent((Component) subMenu, index); - } - - @Override - public Object getPopupMenu() { - // JMenu only - return null; - } - - protected String getMenuHTML() { - String label = (this.icon != null ? this.icon - : this.text != null ? this.text - : null); - String s = (label == null ? "" : "
  • " + label + "" - + htmlMenuOpener("ul")); - int n = getComponentCount(); - if (n > 0) - for(int i = 0; i < n; i++) - s += getComponent(i).toHTML(); - if (label != null) - s += "
  • "; - return s; - } - - protected String htmlMenuOpener(String type) { - return "<" + type + " id=\"" + this.id + "\"" + (this.enabled ? "" : getHtmlDisabled()) + ">"; - } - - protected String getHtmlDisabled() { - return " disabled=\"disabled\""; - } - -} +package javajs.swing; + +import javajs.awt.Component; + +import javajs.api.SC; + +public abstract class AbstractButton extends JComponent implements SC { + + Object itemListener; + Object applet; + String htmlName; + boolean selected; + + private SC popupMenu; + + private String icon; + + protected AbstractButton(String type) { + super(type); + enabled = true; + } + + @Override + public void setSelected(boolean selected) { + this.selected = selected; + /** + * @j2sNative + * + * SwingController.setSelected(this); + * + */ + { + } + } + + @Override + public boolean isSelected() { + return selected; + } + + @Override + public void addItemListener(Object listener) { + itemListener = listener; + } + + @Override + public Object getIcon() { + return icon; + } + + @Override + public void setIcon(Object icon) { + this.icon = (String) icon; + } + + @Override + public void init(String text, Object icon, String actionCommand, SC popupMenu) { + this.text = text; + this.icon = (String) icon; + this.actionCommand = actionCommand; + this.popupMenu = popupMenu; + /** + * @j2sNative + * + * SwingController.initMenuItem(this); + * + */ + { + } + } + + public SC getTopPopupMenu() { + // note that JMenu.getPopupMenu refers to ITSELF, not the main one) + return popupMenu; + } + + @Override + public void add(SC item) { + addComponent((Component) item); + } + + @Override + public void insert(SC subMenu, int index) { + // JMenu, JPopupMenu only, but implemented here as well + // for simplicity + insertComponent((Component) subMenu, index); + } + + @Override + public Object getPopupMenu() { + // JMenu only + return null; + } + + protected String getMenuHTML() { + String label = (this.icon != null ? this.icon + : this.text != null ? this.text + : null); + String s = (label == null ? "" : "
  • " + label + "" + + htmlMenuOpener("ul")); + int n = getComponentCount(); + if (n > 0) + for(int i = 0; i < n; i++) + s += getComponent(i).toHTML(); + if (label != null) + s += "
  • "; + return s; + } + + protected String htmlMenuOpener(String type) { + return "<" + type + " id=\"" + this.id + "\"" + (this.enabled ? "" : getHtmlDisabled()) + ">"; + } + + protected String getHtmlDisabled() { + return " disabled=\"disabled\""; + } + +}