Home • ECDL • Algoritmi • Java • Basi di dati • Seconda prova • Eccetera • Cerca nel sito

Eventi: Window... 1

Precedente
SUPERIORE
Successiva

WindowListener

Apertura, chiusura, ... di una finestra

import java.awt.Frame;
import java.awt.event.WindowListener;
import java.awt.event.WindowEvent;

public class WindowListenerTest extends    Frame
                                implements WindowListener
{
   public WindowListenerTest()
   {
      this.setTitle("Prova WindowListener!");
      this.addWindowListener(this);
      this.setSize(400, 400);
      this.setVisible(true);
   }

   public void windowActivated(WindowEvent we)   { System.out.println("Activated" );   }
   public void windowDeactivated(WindowEvent we) { System.out.println("Deactivated" ); }
   public void windowOpened(WindowEvent we)      { System.out.println("Opened" );      }
   public void windowClosing(WindowEvent we)     { System.out.println("Closing" );     }
   public void windowClosed(WindowEvent we)      { System.out.println("Closed" );      }
   public void windowIconified(WindowEvent we)   { System.out.println("Iconified" );   }
   public void windowDeiconified(WindowEvent we) { System.out.println("Deiconified" ); }

   public static void main(String args[])
   {
      WindowListenerTest f=new WindowListenerTest(); 
   }
}

WindowFocusListener, WindowStateListener

Esistono altri due ascoltatori per lo stato e il fuoco della finestra

import java.awt.Frame;
import java.awt.event.*;

public class WindowTest extends    Frame
                        implements WindowListener,
                                   WindowStateListener,
                                   WindowFocusListener
{
   public WindowTest()
   {
      this.setTitle("Prova i listener di Frame!");
      this.addWindowListener(this);
      this.addWindowStateListener(this);
      this.addWindowFocusListener(this);
      this.setSize(400, 400);
      this.setVisible(true); 
   }

   public void windowActivated(WindowEvent we)    { System.out.println("Activated" );   } 
   public void windowDeactivated(WindowEvent we)  { System.out.println("Deactivated" ); }
   public void windowOpened(WindowEvent we)       { System.out.println("Opened" );      }
   public void windowClosing(WindowEvent we)      { System.out.println("Closing" );     }
   public void windowClosed(WindowEvent we)       { System.out.println("Closed" );      }
   public void windowIconified(WindowEvent we)    { System.out.println("Iconified" );   }
   public void windowDeiconified(WindowEvent we)  { System.out.println("Deiconified" ); }
   public void windowGainedFocus(WindowEvent we)  { System.out.println("GainedFocus" ); }
   public void windowLostFocus(WindowEvent we)    { System.out.println("LostFocus" );   }
   public void windowStateChanged(WindowEvent we) { System.out.println("StateChanged"); } 

   public static void main(String args[])
   { 
      WindowTest f=new WindowTest(); 
   } 
}

Eventi: Window... 1 - ApPuNtIdIuNiNfOrMaTiCo

Home • ECDL • Algoritmi • Java • Basi di dati • Seconda prova • Eccetera • Cerca nel sito

Precedente
SUPERIORE
Successiva