Scribd Upload a Document

þÿ

Search Documents

Explore Sign Up | Log In
• • •
þÿ

/ 127
þÿ

Download this Document for Free represented by a nonpublic instance variable. It can be read-write, read-only, or write-only. There are four different types of properties:  Simple As the name implies, simple properties

represent the simplest of thefour. To create a property, define a pair of set/get routines. Whatever name usedin the pair of routines, becomes the property name  Indexed An indexed property is for when a single property can hold an array of values. The design pattern for

int position) public PropertyType[] getPropertyName () public PropertyType getPropertyName (int position)  Bound – .these properties is: public void setPropertyName (PropertyType[] list) public void setPropertyName (PropertyType element.

A bean that has the bound property generates an event when the property is changed. Inorder for the notific ation to happen. you . The event is of type propertyChangeEvent and is sent toobjects that previously registered an interest in receiveing such notifications.

you have to create a list of listeners to maintain: private PropertyChangeSuppor t changes =new PropertyChangeSuppor t (this).And then. First. you have to maintain the list: public void .need to maintain a w atch list for PropertyChangeEvent s via the PropertyChangeSuppor t class.

removePrope rtyChangeListener (p).addPropertyChangeList ener (PropertyChangeListen er p) {changes.} public void removePropertyChange Listener (PropertyChangeListen er p) {changes.addProperty ChangeListener (p).}  Constrained - .

the Bean maintains a list of Prasad V. In additionto maintaining a list of PropertyChangeList eners. Potluri Siddhartha Institute of Technology36 VetoableChangeListene r .Constrained properties are similar to bound properties.

Then. the listener thr ows a PropertyVetoException . it asks the VetoableChangeLi steners if its okay.s. If i t isn't. which you declare the set routine tothrow.  Methods Bean methods are av ailable for anyone to . prior to the Bean changing a propertyvalue.

However.call by just making e ach public. you can restrict which methods are visible to the Bean builder/integration tool by providing a getMethodDescriptor s method along with your Bean's BeanInfo. EveryBean can provide a supporting BeanInfo class to customize a .

Procedural Steps to create a Java-Bean: 1)Creating a directory.Create a new directory in C:\b eans\demo\sunw\dem o witha new folder name colors2)Create a java source file3)Compile the java source file4)Create a manifest file colors.mft in the .Bean's appearance to anintegration tool.

.directory called as C:\beans\demo5)Creat e a jar file.to create a jar file type the following command in the command prompt jar cfm . .\jars\colors.mft sunw\demo\ colors\*.jar colors.class6 ) S t a r t t h e B D K 7)Check whether the colors bean is placed in toolbox or not.

colors.awt.*.impo rt java.event.*.public class Colors extends Canvas{transient private Color color.private boolean rectangular.demo.public Colors() Prasad V.import java.awt.PROGRAM: package sunw. Potluri Siddhartha Institute of Technology37 .

setSize(100.}public boolean getRectangular() {return rectangular. }}).{addMouseListener(ne w MouseAdapter() {public void mousePressed(MouseE vent me) {change(). 100).rectang ular=false.}public void setRectangular(boolean .change().

repaint().r eturn new .random()).}public void change() {color=randomColor().}private Color randomColor(){int r=(i nt) (255*Math.r epaint().random()).in t g=(int) (255*Math.in t b=(int) (255*Math.random()).flag) {this.rectangular=flag.

0.}public void paint(Graphics g) Prasad V.Color(r.g.}}} OUTPUT: .width.h-1). Potluri Siddhartha Institute of Technology38 {Dimension d=getSize(). w-1.fillRect(0.height.setColor(c olor).w-1.if(rectangular) {g.0.h1).int h=d.fillOval(0.int w=d.b).g.}else{g.

Prasad V. Potluri Siddhartha Institute of Technology39 RESULT: Thus the colors bean is created successfully. Program 2:Visual Beans (program .

0.publ ic class convert extends Canvas{private double dollars=0.awt.demo.private double dollarvalue=0.*.javapackag e sunw.0.import java.i mport java.publi .convert.2)Convert.private double rupees=0.*.event.0.awt.

c convert() {setSize(100.1000). Potluri Siddhartha Institute of Technology40 .} public double getDollars() Prasad V.

dollars=value.repaint().} public void setRupees(double value) {this.}public void change() {dollarvalue= value().rupees=value.{return dollars.}public void setDollars(double value) {this.} public double getRupees(){return rupees.}pri .

g.}publi c void paint(Graphics g) {g.setColor(Color.valueOf(dollarvalue).red ).10).}}Convert. 10.drawString(String .mf Name: sunw/demo/convert/c onvert.classJavaBean: True ( press Enter)(Carriage return compulsory) .vate double value() {return rupees*dollars.

Potluri Siddhartha Institute of Technology41 JNTU WT RECORD LAB MANUAL Download this Document for FreePrintMobileCollections Report Document Info and Rating WT Follow syam_5491983 .Prasad V.

Share & Embed Related Documents PreviousNext 1. . p. p. p.

3. p. p.2. p. p. .

4. p. p. p. p. .p.

5. p. . p. p. 6. p.

p. 7.p. p. p. . p.

p. p. p.8. . 3 p. More from this user PreviousNext 1.

28 p. 22 p.36 p. 3 p. . 2.

Recent Readcasters Add a Comment .127 p.

com/scribd About Press Blog þÿ • • • • • • • .com/scribd twitter.Upload a Document Search Documents Follow Us! scribd.com/scribd facebook.

Language: • • • • • • • • • • .Partners Scribd 101 Web Stuff Support FAQ Developers / API Jobs Terms Copyright Privacy Copyright © 2011 Scribd Inc.

English .

Sign up to vote on this title
UsefulNot useful

Master Your Semester with Scribd & The New York Times

Special offer for students: Only $4.99/month.

Master Your Semester with a Special Offer from Scribd & The New York Times

Cancel anytime.