All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.noos.xing.yasaf.plaf.view.ComponentView Maven / Gradle / Ivy

There is a newer version: 1.6.0
Show newest version
package org.noos.xing.yasaf.plaf.view;

import org.noos.xing.yasaf.view.View;
import org.noos.xing.yasaf.view.ViewContext;

import java.awt.*;
import java.awt.event.HierarchyListener;
import java.awt.event.HierarchyEvent;

/**
 * @author Angelo De Caro ([email protected])
 */
public abstract class ComponentView implements View {
    protected Component component;
    protected ViewContext viewContext;
    protected boolean first = false;

    protected ComponentView() {
        this(new MapViewContext());
    }

    protected ComponentView(ViewContext viewContext) {
        this.viewContext = viewContext;
        this.component = initComponent();
        this.component.addHierarchyListener(new HierarchyListener() {
            public void hierarchyChanged(HierarchyEvent e) {
                if ((e.getChangeFlags() & HierarchyEvent.SHOWING_CHANGED) != 0) {
                    if (!first) {
                        onFirstVisible();
                        first = true;
                    }
                }
            }
        });
        initListeners();
    }

    public Component getComponent() {
        return component;
    }

    protected abstract Component initComponent();

    protected void initListeners() {
    }

    protected void onFirstVisible() {
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy