Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

window in java swing

import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.io.IOException;
//ww  w .  j  a  v a  2s.  c  o  m
import javax.swing.JFrame;

public class Main {
  public static void main(String[] args) throws IOException {
    JFrame frame = new JFrame();
    frame.addWindowListener(new WindowListener() {
      @Override
      public void windowOpened(WindowEvent e) {
        System.out.println("JFrame has  been  made visible first  time");
      }

      @Override
      public void windowClosing(WindowEvent e) {
        System.out.println("JFrame is closing.");
      }

      @Override
      public void windowClosed(WindowEvent e) {
        System.out.println("JFrame is closed.");
      }

      @Override
      public void windowIconified(WindowEvent e) {
        System.out.println("JFrame is  minimized.");
      }

      @Override
      public void windowDeiconified(WindowEvent e) {
        System.out.println("JFrame is restored.");
      }

      @Override
      public void windowActivated(WindowEvent e) {
        System.out.println("JFrame is activated.");
      }

      @Override
      public void windowDeactivated(WindowEvent e) {
        System.out.println("JFrame is deactivated.");
      }
    });

    // Use the WindowAdapter class to intercept only the window closing event
    frame.addWindowListener(new WindowAdapter() {
      @Override
      public void windowClosing(WindowEvent e) {
        System.out.println("JFrame is closing.");
      }
    });

  }
}
Comment

PREVIOUS NEXT
Code Example
Java :: tableau deux dimensions java 
Java :: latest android version 
Java :: convert date to localdate java 
Java :: how to plus two numbers in java 
Java :: long to int java 
Java :: online java code fixer 
Java :: spring valid request body custom message 
Java :: java comparing-two-csv-files-in-java 
Java :: android iterate through radio group java 
Java :: scala vs java 
Java :: java hash map 
Java :: how to initialize char in java 
Java :: remove whitespaces 
Java :: write file java 
Java :: input using stringbuffer 
Java :: how to do annotation configuration in spring 
Java :: method parameters in java 
Java :: java convert ip to long 
Java :: initialize mocks 
Java :: how to convert a string of characters to a stream of binary characters binary 
Java :: difference between stringbuffer and stringbuilder 
Java :: linked list vs array list vs vector 
Java :: java class in dataweave 
Java :: using java stream filter to find the sum of property 
Java :: How to make a Java Main Menu Loop after using a case 
Java :: netbeans android sdk location 
Java :: how to get the memory location of an object in java 
Java :: java list newline 
Java :: /setblock 
Java :: android send fragment context 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =