1 21 24 package org.lobobrowser.html.renderer; 25 26 import java.awt.event.ActionEvent ; 27 import java.awt.event.ActionListener ; 28 29 import org.lobobrowser.html.domimpl.*; 30 import org.lobobrowser.util.gui.WrapperLayout; 31 import javax.swing.*; 32 33 class InputButtonControl extends BaseInputControl { 34 private final JButton widget; 35 36 public InputButtonControl(final HTMLBaseInputElement modelNode) { 37 super(modelNode); 38 this.setLayout(WrapperLayout.getInstance()); 39 JButton widget = new JButton(); 40 this.widget = widget; 41 this.add(widget); 42 widget.addActionListener(new ActionListener () { 43 public void actionPerformed(ActionEvent event) { 44 HtmlController.getInstance().onPressed(InputButtonControl.this.controlElement, null, 0, 0); 45 } 46 }); 47 } 48 49 public void reset(int availWidth, int availHeight) { 50 super.reset(availWidth, availHeight); 51 HTMLInputElementImpl element = (HTMLInputElementImpl) this.controlElement; 52 String text = element.getAttribute("value"); 53 if(text == null || text == "") { 54 String type = element.getType(); 55 if("submit".equalsIgnoreCase(type)) { 56 text = "Submit Query"; 57 } 58 else if("reset".equalsIgnoreCase(type)) { 59 text = "Reset"; 60 } 61 else { 62 text = ""; 63 } 64 } 65 this.widget.setText(text); 66 } 67 68 71 public void click() { 72 this.widget.doClick(); 73 } 74 75 78 public String getValue() { 79 return this.widget.getText(); 80 } 81 82 public void setDisabled(boolean disabled) { 83 super.setDisabled(disabled); 84 this.widget.setEnabled(!disabled); 85 } 86 87 90 public void setValue(String value) { 91 this.widget.setText(value); 92 } 93 94 public void resetInput() { 95 } 97 } 98 | Popular Tags |