View Javadoc

1   /**
2    * Copyright 2008 WebPhotos
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package net.sf.webphotos.util.legacy;
17  
18  import java.awt.event.WindowEvent;
19  import java.awt.event.WindowFocusListener;
20  import javax.swing.JFrame;
21  
22  /**
23   * Ajusta o modo de aparição da janela quando ganha ou perde o foco.
24   * Utilizada na classe FtpClient.
25   * @author guilherme
26   */
27  public class Modal implements WindowFocusListener {
28      private JFrame frame;
29  
30      /**
31       * Recebe um frame e seta o frame da classe.
32       * @param f Frame.
33       */
34      public Modal(JFrame f) { frame=f; }
35      /**
36       * Implementa o método windowGainedFocus(WindowEvent e) da interface {@link java.awt.event.WindowFocusListener WindowFocusListener}.
37       * @param e Evento de janela.
38       */
39      @Override
40      public void windowGainedFocus(WindowEvent e) {}
41      /**
42       * Implementa o método windowLostFocus(WindowEvent e) da interface {@link java.awt.event.WindowFocusListener WindowFocusListener}.
43       * @param e Evento de janela.
44       */
45      @Override
46      public void windowLostFocus(WindowEvent e) {
47          frame.toFront();
48      }
49  }