The MyBean JavaBean Component : Customized Component « Swing JFC « Java

The MyBean JavaBean Component

import java.awt.Point;
import java.beans.XMLEncoder;

public class MyBean {
  private String names[];

  private Point p;

  private int length;

  public String[] getNames() {
    return names;

  public Point getPoint() {
    return p;

  public int getLength() {
    return length;

  public void setNames(String newValue[]) {
    names = newValue;

  public void setPoint(Point newValue) {
    p = newValue;

  public void setLength(int newValue) {
    length = newValue;

  public static void main(String args[]) throws IOException {
    // Create
    MyBean saveme = new MyBean();
    saveme.setNames(new String[] { "one", "two", "three" });
    saveme.setPoint(new Point(15, 27));
    // Save
    XMLEncoder encoder = new XMLEncoder(new BufferedOutputStream(
        new FileOutputStream("saveme.xml")));



Related examples in the same category

1.FontChooser dialogFontChooser dialog
2.Oval Panel
3.Customized componentCustomized component
4.Ploygon ButtonPloygon Button
5.Demonstrating the Box ComponentDemonstrating the Box Component
6.The TrafficLight Component
7.Alias BeanAlias Bean