|
-
Java Beans
Hai all,
I have just started to learn Java beans . Actually I am not able to understand its basics. I searched in net and found many tutorials but not able to capture the starting point. I got the following code from net and when I tried to run it it showed an information box "The bean does not have a main method". When I added a main() methode to it it is running but not executing the paint method so nothing is displayed in the output! Can anyone help me?
import java.awt.*;
import java.io.Serializable;
public class SimpleBean extends Canvas
implements Serializable{
private Color color = Color.green;
//property getter method
public Color getColor(){
return color;
}
//property setter method. Sets new SimpleBean
//color and repaints.
public void setColor(Color newColor){
color = newColor;
repaint();
}
public void paint(Graphics g) {
g.setColor(color);
g.fillRect(20, 5, 20, 30);
}
//Constructor sets inherited properties
public SimpleBean(){
setSize(60,40);
setBackground(Color.red);
}
}
Also if anyone knows a site for learning Java beans programming in simple steps please let me know.
Thanks in advance,
Arya.
Similar Threads
-
Replies: 2
Last Post: 06-14-2006, 03:16 PM
-
Replies: 1
Last Post: 05-13-2005, 06:46 AM
-
By Mike Tsakiris in forum .NET
Replies: 11
Last Post: 10-04-2002, 05:32 PM
-
By JJ in forum Enterprise
Replies: 1
Last Post: 07-06-2000, 04:50 AM
-
Replies: 2
Last Post: 04-08-2000, 08:13 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks