View Javadoc
1 /*** 2 * $Header: /cvsroot/ebxmlrr/jaxr/src/com/sun/xml/registry/client/browser/StringBufferPanel.java,v 1.3 2003/07/30 23:39:11 farrukh_najmi Exp $ 3 */ 4 package com.sun.xml.registry.client.browser; 5 6 import java.awt.*; 7 import java.awt.event.*; 8 import java.util.*; 9 import javax.xml.registry.*; 10 import javax.xml.registry.infomodel.*; 11 import javax.swing.*; 12 import javax.swing.event.*; 13 14 /*** 15 * Panel for String 16 * 17 * @author <a href="mailto:Farrukh.Najmi@Sun.COM">Farrukh S. Najmi</a> 18 */ 19 public class StringBufferPanel extends JBPanel { 20 21 JTextField strText = null; 22 23 /*** 24 * Used for displaying objects 25 */ 26 public StringBufferPanel() { 27 GridBagLayout gbl = new GridBagLayout(); 28 GridBagConstraints c = new GridBagConstraints(); 29 setLayout(gbl); 30 31 JLabel strLabel = new JLabel("String value:", SwingConstants.LEFT); 32 c.gridx = 0; 33 c.gridy = 0; 34 c.gridwidth = 1; 35 c.gridheight = 1; 36 c.weightx = 0.0; 37 c.weighty = 0.0; 38 c.fill = GridBagConstraints.NONE; 39 c.anchor = GridBagConstraints.WEST; 40 c.insets = new Insets(4, 4, 0, 4); 41 gbl.setConstraints(strLabel, c); 42 add(strLabel); 43 44 strText = new JTextField(); 45 c.gridx = 0; 46 c.gridy = 1; 47 c.gridwidth = 1; 48 c.gridheight = 1; 49 c.weightx = 0.75; 50 c.weighty = 0.0; 51 c.fill = GridBagConstraints.BOTH; 52 c.anchor = GridBagConstraints.WEST; 53 c.insets = new Insets(4, 4, 0, 4); 54 gbl.setConstraints(strText, c); 55 add(strText); 56 57 } 58 59 public StringBuffer getStringBuffer() throws JAXRException { 60 StringBuffer str = null; 61 62 if (model != null) { 63 str = (StringBuffer)getModel(); 64 } 65 return str; 66 } 67 68 public void setStringBuffer(StringBuffer str) throws JAXRException { 69 setModel(str); 70 } 71 72 public void setModel(Object obj) throws JAXRException { 73 if (!(obj instanceof StringBuffer)) { 74 throw new InvalidRequestException("Expecting a StringBuffer. Got a " + obj.getClass().getName()); 75 } 76 super.setModel(obj); 77 78 StringBuffer str = (StringBuffer)obj; 79 80 if (str != null) { 81 strText.setText(str.toString()); 82 } 83 } 84 85 public Object getModel() throws JAXRException { 86 super.getModel(); 87 88 if (model != null) { 89 StringBuffer str = (StringBuffer)model; 90 91 str.replace(0, str.length(), strText.getText()); 92 93 RegistryBrowser.getInstance().getRootPane().updateUI(); 94 } 95 96 return model; 97 } 98 99 protected void validateInput() throws JAXRException { 100 super.validateInput(); 101 } 102 103 public void clear() throws JAXRException { 104 super.clear(); 105 strText.setText(""); 106 } 107 108 }

This page was automatically generated by Maven