Knowledge Byte In this section, you will learn about:

Slides:



Advertisements
Similar presentations
Introduction to Visual Basic.NET Uploaded By: M.Sheraz anjum.
Advertisements

Copyright © 2001 Qusay H. Mahmoud JavaBeans An introduction to component-based development in general Introduction to JavaBeans – Java components – client-side.
LAB SESSION 7 Graphical user interface Applet fundamentals Methods in applets Execution of an applet Graphics class.
Using JavaServer Pages Harry R. Erwin, PhD CIT304/CSE301.
JavaBeans: Introspection and Customization Umer Farooq CS6704: Design Patterns & Component FrameworksJanuary 30, 2002.
© by Pearson Education, Inc. All Rights Reserved.
Visual Basic 2010 How to Program. © by Pearson Education, Inc. All Rights Reserved.2.
Visual Basic 2010 How to Program Reference: Instructor: Maysoon Bin Duwais slides Visual Basic 2010 how to program by Deitel © by Pearson Education,
Java Beans & Serialization CS-328 Dick Steflik. Java Beans Java based component technology –originally developed to provide java with a component technology.
Java Programming, 3e Concepts and Techniques Chapter 3 Manipulating Data Using Methods.
1 Applets Chapter 1 To understand:  why applets are used to extend the capabilities of Web pages  how an applet is executed and know about the restrictions.
By Dr. Jiang B. Liu 12. The Java Beans. Java Beans n JavaBeans is a portable, platform-independent software component model written in Java. It enables.
JAVA BEANS By Madhuri Kakumanu. What is a Java Bean? “ A Java Bean is a reusable software component that can be visually manipulated in builder tools.”
Eyad Alshareef 1 Creating Custom Forms Part A. 2Eyad Alshareef Data Block and Custom Forms Data block form Data block form Based on data blocks that are.
1 Introduction to the Visual Studio.NET IDE Powerpoint slides modified from Deitel & Deitel.
JAVA BEANS (Unit-V) K.Phani Sirisha.
Introducing JavaBeans Lesson 2A / Slide 1 of 30 JDBC and JavaBeans Pre-assessment Questions 1.Which of the given symbols is used as a placeholder for PreparedStatement.
Introducing JavaBeans Identify the features of a JavaBean Create and add a bean to an application Manipulate bean properties using accessor and mutator.
Java Beans.  Java offers software component development through java Beans  Java Beans are based on a software component model for java.  The model.
Java Programming, 2E Introductory Concepts and Techniques Chapter 2 Creating a Java Application and Applet.
Applets Java API.
Java Programming, 2E Introductory Concepts and Techniques Chapter 3 Manipulating Data Using Methods.
Java Programming, 3e Concepts and Techniques Chapter 2 - Part 2 Creating a Java Application and Applet.
Java Programming, 3e Concepts and Techniques Chapter 3 Section 65 – Manipulating Data Using Methods – Java Applet.
An Introduction to Visual Basic
Using JavaBeans and Custom Tags in JSP Lesson 3B / Slide 1 of 37 J2EE Web Components Pre-assessment Questions 1.The _____________ attribute of a JSP page.
SWE 316: Software Design and Architecture Objectives Lecture # 19 Java Beans SWE 316: Software Design and Architecture  Understand  what JavaBeans (“Beans”)
Java Programming: From Problem Analysis to Program Design, Second Edition1  Learn about basic GUI components.  Explore how the GUI components JFrame,
TM Introduction to JavaBeans™ Dimitrios Psarros Questra Consulting (716) x225.
© 2005 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. Data Structures for Java William H. Ford William R. Topp Appendix E The EZJava.
Java Programming: Advanced Topics 1 JavaBeans Chapter 8.
Introduction to Component-Based Engineering Howard Abrams
Components Components are specialized self contained Software entities that can be replicated, Customized and inserted into applications. Components come.
Java Bean Definition “A Java Bean is a reusable software component that can be manipulated visually in a builder tool.”
Chapter 2 – Introduction to the Visual Studio .NET IDE
First Bean Compose SimpleBean Demo Simple Bean Discuss Manifest and Jar Add Properties to SimpleBean.
First Bean Compose SimpleBean Demo Simple Bean Discuss Manifest and Jar Add Properties to SimpleBean.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 27 JavaBeans and.
Java Beans. Definitions A reusable software component that can be manipulated visually in a ‘builder tool’. (from JavaBean Specification) The JavaBeans.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
Introduction to Java Beans by Anders Børjesson. Introduction to JavaBeans2 JavaBeans components JavaBeans are the components in the Java environment –COM.
Creating a Java Application and Applet
Introduction to Java Beans From Anders Børjesson.
Java Beans THETOPPERSWAY.COM. Contents What is a Java Bean? Advantages Properties Bean Developers Kit (BDK) What makes Bean possible? Support for Java.
Java Beans - Basics CIS 421 Web-based Java Programming.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
CSC 205 Programming II Lecture 5 AWT - I.
Dive Into® Visual Basic 2010 Express
Visual Basic .NET BASICS
Running a Forms Developer Application
Chapter 2: The Visual Studio .NET Development Environment
Working in the Forms Developer Environment
Microsoft Visual Basic 2005 BASICS
Chapter 2 – Introduction to the Visual Studio .NET IDE
Java Programming: From Problem Analysis to Program Design,
Introduction to the Visual C# 2005 Express Edition IDE
Knowledge Byte In this section, you will learn about:
Java Programming: Guided Learning with Early Objects
Chapter 2 – Introduction to the Visual Studio .NET IDE
Hands-on Introduction to Visual Basic .NET
UNIT-5.
Knowledge Byte In this section, you will learn about:
Constructors, GUI’s(Using Swing) and ActionListner
Pre-assessment Questions
Java IDE Dwight Deugo Nesa Matic Portions of the notes for this lecture include excerpts from.
Pre-assessment Questions
Java Programming: Advanced Topics
Knowledge Byte In this section, you will learn about:
JAVA APPLET PREPARED BY Mr. Jahanzaib Ahmed
Presentation transcript:

Knowledge Byte In this section, you will learn about: Property Sheets and Property Editor The PropertyEditorSupport and PropertyDescriptor Class The BeanInfo Interface Collaborate

Property Sheets and Property Editor Property sheets and property editors enable easy access to the exposed JavaBean properties. Property sheet or the Properties window of BDK displays a list of all the exposed properties of a JavaBean. A property editor window is used to edit the values of JavaBean properties, which cannot be edited in property sheets. The property editor is always associated with a specific JavaBean property. The property editor is displayed whenever an attempt is made to modify the value of the associated JavaBean property during the build phase. Collaborate

The PropertyEditorSupport and PropertyDescriptor Class The PropertyEditorSupport Class: Enables you to create a text-based or a GUI based customized property editor. Implements the PropertyEditor interface of the java.beans package. Is extended by a class to create a customized property editor. Collaborate

The PropertyEditorSupport and PropertyDescriptor Class (Contd.) The following table lists some methods of the PropertyEditorSupport Class: Method Description void addPropertyChangeListener( PropertyChangeListener pcl) Registers a new PropertyChangeListener to handle the PropertyChange events. The method accepts an object of PropertyChangeListener interface. void firePropertyChange() Informs all the listeners when there is a change in the JavaBean property. Collaborate

The PropertyEditorSupport and PropertyDescriptor Class (Contd.) The methods of PropertyEditorSupport class: (Contd.) Method Description void paintValue(Graphics g, Rectangle rec) Paints a graphics object in a rectangle on the screen area. The graphics to paint and the area in which the graphics is painted are passed as parameters to the paintValue() method. boolean isPaintable() Returns a boolean value that specifies if the JavaBean supports the paintValue() method. void removePropertyChangeListener(PropertyChangeListener plist) Removes a registered PropertyChangeListener from the list of listeners for the PropertyChange events. Collaborate

The PropertyEditorSupport and PropertyDescriptor Class (Contd.) The methods of PropertyEditorSupport class: (Contd.) Method Description boolean supportsCustomEditor() Returns a boolean value that determines whether the property editor object supports the custom editor or not. String getAsText() Returns the string value of a JavaBean property. Component getCustomEditor() Returns a custom property editor as a component that enables you to edit the value of JavaBean properties. void setAsText(String text) Sets the value of a property to the string passed as a parameter to this method. Collaborate

The PropertyEditorSupport and PropertyDescriptor Class (Contd.) The methods of PropertyEditorSupport class: (Contd.) Method Description String[] getTags() Returns an array of tag values that consists of all the possible values for a JavaBean property. void setValue(Object value) Sets the value of a JavaBean property to the value passed as parameter. Object getValue() Enables you to retrieve the value of a JavaBean property. Collaborate

The PropertyEditorSupport and PropertyDescriptor Class (Contd.) The PropertyDescriptor Class The PropertyDescriptor Class restricts the JavaBean properties that are displayed in the Properties window. To create customized properties window, you need to create an information class that contains information about the properties, events, and methods of a JavaBean. The information class extends the SimpleBeanInfo class and have a name ending with BeanInfo. For example, class PropBeanInfo extends SimpleBeanInfo { //Class body } Collaborate

The PropertyEditorSupport and PropertyDescriptor Class (Contd.) You also need to override the getPropertyDescriptors() method that returns an array of PropertyDescriptor objects in the PropBeanInfo class. For example, public PropertyDescriptor[] getPropertyDescriptors() { //Method_body } Collaborate

The BeanInfo Interface The BeanInfo interface provides the methods that enable you to specify and retrieve the information about a JavaBean. The following table lists some of the methods of BeanInfo interface: Method Description MethodDescriptor[] getMethodDescriptors() Returns an array of the method descriptor objects of a JavaBean. The method descriptor objects are used to determine information about the various methods defined in a JavaBean. EventDescriptor[] getEventDescriptors() Returns an array of the event descriptor objects of a JavaBean. The event descriptor objects determine the information about the events associated with a JavaBean. Collaborate

The BeanInfo Interface(Contd.) The methods of BeanInfo interface: (Contd.) Method Description PropertyDescriptor[] getPropertyDescriptors() Returns an array of the property descriptor objects of a JavaBean. The property descriptor objects are used to determine information about the various custom properties of a JavaBean. Image getIcon( int icon_type ) Returns a corresponding image object for one of the fields of the BeanInfo interface passed as a parameter to this method. The BeanInfo interface defines int fields, such as ICON_COLOR_32x32 and ICON_MONO_32x32 to represent icons. Collaborate

From the Expert’s Desk In this section, you will learn: Tips on: Using the sample JavaBeans of BDK1.1 in Java 2 SDKv1.4.x Creating a single manifest file that contains entries for multiple JavaBeans FAQs on JavaBeans Collaborate

Tips Using the Sample JavaBeans of BDK1.1 in Java 2 SDK v 1.4.x The steps to use the sample JavaBeans of BDK in Java 2 SDK 1.4.x are: Open the C:\BDK1.1\beans\demo\sunw\demo\buttons folder using the Windows Explorer. Open the folder for the sample JavaBean, for example, open the folder for ExplicitButton JavaBean that is not supported by Java 2 SDK 1.4.x. Collaborate

Tips Using the Sample JavaBeans of BDK1.1 in Java 2 SDK v 1.4.x (Contd.) Change the code in the public EventSetDescriptor[] getEventSetDescriptors() method. For example, to load the ExplicitButton JavaBean, you need to change the following code: EventSetDescriptor push = new EventSetDescriptor(beanClass, "actionPerformed", java.awt.event.ActionListener.class, "actionPerformed"); The preceding code should be changed to the following code: EventSetDescriptor push = new EventSetDescriptor(beanClass, "action", java.awt.event.ActionListener.class, "actionPerformed"); Collaborate

Tips Using the Sample JavaBeans of BDK1.1 in Java 2 SDK v 1.4.x (Contd.) Compile all files of C:\BDK1.1\beans\demo\sunw\demo\buttons directory. Download Microsoft nmake utility to the C:\BDK1.1\beans\beanbox directory from the following url: ftp://ftp.microsoft.com/Softlib/MSLFILES/nmake15.exe Add the C:\BDK1.1\beans\beanbox directory path to your system path. Go to C:\BDK1.1\beans\demo and type: nmake buttons.mk Run BDK. The ExplicitButton JavaBean will get loaded in the BDK. Collaborate

Tips Creating Manifest File for Multiple JavaBeans The syntax to define the entries for multiple JavaBean files in the same manifest file is: Name: <beanFile1.class> Java-Bean: <status>   Name: <beanFile2.class> Name: <file3.gif> In the preceding syntax, a blank line is left between each of the file declarations. Collaborate

FAQs What type of JavaBean will you use to display the current time in an application? You can display the current time in a Java application using a control JavaBean. The control JavaBean adds a new feature to an existing Java application. How can you count the number of hits for a particular Web page using JavaBeans? You can count the number of hits for a Web page using an invisible runtime JavaBean. This JavaBean performs a hidden background function. Collaborate

FAQs (Contd.) How would you change the foreground color of a component using JavaBeans? The foreground color of a component can be changed using the JavaBean properties. You need to create a JavaBean for the component and define a property, foreground color for the component. The setForegroundColor() method for the JavaBean property can be used to specify and change the value of the foreground color for the JavaBean component. Collaborate

FAQs (Contd.) What is introspection? Introspection is the process of examining the class structure of a JavaBean and determining the properties, methods, and events supported by the JavaBean. Introspection helps you to find only the list of methods and the method signatures of a JavaBean. It does not help you to find the source code of the methods and how the JavaBean functionality has been implemented. The introspection technique is used by a programmer during the design and build phases to identify the JavaBean functionality. The end user will not be interested in knowing the internal functionalities of a JavaBean. Collaborate

FAQs (Contd.) Where is the manifest file of a JavaBean stored in the JAR file? The manifest file is stored inside the directory, META-INF inside the JAR file. How does the compiler recognize the file to execute while running a JAR file? When a JAR file is executed, the Main-Class entry in the manifest file instructs the java -jar command about the class to execute. The java -jar command enables you to execute a runnable JAR file on the command prompt. The -jar option enables the Java Runtime Environment (JRE) to recognize that the specified file is a runnable JAR file. The command to execute a runnable JAR file, SampleJar.jar, on the command prompt is: java -jar SampleJar.jar Collaborate

Challenge Select the option that allows you to view the sequence of method invocation in BDK 1.1: ToolBox Window BeanBox Window Method Tracer Window Properties Window What is the use of the addPropertyChangeListener() method of the PropertyEditorSupport class? Select the class that you need to use for implementing bound properties in JavaBeans: PropertyChangeSupport class VetobaleChangeSupport class ProperyChangeEvent class PropertyDescriptor class Collaborate

Challenge (Contd.) The PropertyEditorSupport class implements the __________interface. What is the purpose of implementing the BeanInfo interface for a JavaBean? The ___________enables you to modify the JavaBean properties that are displayed in the property sheet. Collaborate

Solutions to Challenge c. Method Tracer Window The addPropertyChangeListener() method registers a new listener to handle the PropertyChange events. a. PropertyChangeSupport class PropertyEditor The BeanInfo interface enables you to provide the information about the properties, events, and methods of a JavaBean in the JavaBean information class. Property Editors Collaborate