Example usage for java.awt Container addFocusListener

List of usage examples for java.awt Container addFocusListener

Introduction

In this page you can find the example usage for java.awt Container addFocusListener.

Prototype

public synchronized void addFocusListener(FocusListener l) 

Source Link

Document

Adds the specified focus listener to receive focus events from this component when this component gains input focus.

Usage

From source file:com.projity.pm.graphic.frames.GraphicManager.java

/**
 * @param projectUrl TODO/*from ww  w .  ja va 2s.  c  om*/
 * @param server TODO
 * @throws java.awt.HeadlessException
 */
public GraphicManager(/*String[] projectUrl,*/ String server, Container container) throws HeadlessException {
    graphicManagers.add(this);
    lastGraphicManager = this;
    container.addFocusListener(new FocusListener() {

        public void focusGained(FocusEvent e) {
            //            System.out.println("GainFocus " + GraphicManager.this.hashCode());
            setMeAsLastGraphicManager();
        }

        public void focusLost(FocusEvent e) {
            //            System.out.println("LostFocus " + GraphicManager.this.hashCode());
        }
    });

    projectFactory = ProjectFactory.getInstance();
    projectFactory.getPortfolio().addObjectListener(this);

    //this.projectUrl = projectUrl;
    GraphicManager.server = server;
    this.container = container;
    if (container instanceof Frame)
        frame = (Frame) container;
    else if (container instanceof JApplet)
        frame = JOptionPane.getFrameForComponent(container);
    if (container instanceof FrameHolder)
        ((FrameHolder) container).setGraphicManager(this);
    //      else if (container instanceof BootstrapApplet){
    else {
        try {
            FrameHolder holder = (FrameHolder) Class.forName("com.projity.bootstrap.BootstrapApplet")
                    .getMethod("getObject", null).invoke(container, null);
            holder.setGraphicManager(this);
        } catch (Exception e) {
        }
    }
    registerForMacOSXEvents();
}