Java Code Examples for java.awt.event.WindowStateListener

The following are top voted examples for showing how to use java.awt.event.WindowStateListener. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: GameSetup   File: GameFrame.java   View source code 7 votes vote down vote up
public void init(String title) {
	w = new JFrame(title);
	w.addKeyListener(this);
	w.addMouseListener(this);
	w.addMouseMotionListener(this);
	w.addMouseWheelListener(this);
	w.addWindowStateListener(new WindowStateListener() {
		
		@Override
		public void windowStateChanged(WindowEvent e) {
			w.setExtendedState(JFrame.NORMAL);
		}
	});
	w.setBackground(Color.black);
	w.setForeground(Color.white);
	w.getContentPane().setBackground(Color.black);
	w.getContentPane().setIgnoreRepaint(true);
	
	w.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	
	frames = 0;
	start = 0;
	layers = new CopyOnWriteArrayList<>();
	
	initGame();
}
 
Example 2
Project: j2se_for_android   File: Window.java   View source code 6 votes vote down vote up
protected void processWindowStateEvent(WindowEvent e) {
	try{
	WindowStateListener[] wl = getWindowStateListeners();
	if(wl == null){
		return;
	}
       switch (e.getID()) {
           case WindowEvent.WINDOW_STATE_CHANGED:
           	DebugLogger.log("fire WindowListener.windowStateChanged.");
			for (int i = 0; i < wl.length; i++) {
				wl[i].windowStateChanged(e);
			}
               break;
           default:
               break;
       }
	}catch (Throwable ex) {
		ex.printStackTrace();
	}
}
 
Example 3
Project: aTunes   File: VisualHandler.java   View source code 6 votes vote down vote up
public WindowStateListener getWindowStateListener() {
		if (fullFrameStateListener == null) {
			fullFrameStateListener = new WindowAdapter() {
				public void windowStateChanged(WindowEvent e) {
					if ((e.getNewState() & java.awt.Frame.ICONIFIED) == java.awt.Frame.ICONIFIED) {
						if (kernel.state.isShowSystemTray())
							frame.setVisible(false);
					}
				}
//				public void windowClosing(WindowEvent e) {
//					if (kernel.state.isShowSystemTray())
//						frame.setVisible(false);
//				}
			};
		}
		return fullFrameStateListener;
	}
 
Example 4
Project: openwonderland   File: LoginOptionsFrame.java   View source code 6 votes vote down vote up
/**
 * @param args the command line arguments
 */
public static void main(String args[]) {
    java.awt.EventQueue.invokeLater(new Runnable() {

        public void run() {
            LoginOptionsFrame lfe = new LoginOptionsFrame();
            lfe.addWindowStateListener(new WindowStateListener() {

                public void windowStateChanged(WindowEvent evt) {
                    if (evt.getNewState() == WindowEvent.WINDOW_CLOSED) {
                        System.exit(0);
                    }
                }
            });

            lfe.setVisible(true);
        }
    });
}
 
Example 5
Project: javify   File: Window.java   View source code 5 votes vote down vote up
/**
 * Returns an array of all the window state listeners registered on this
 * window.
 *
 * @since 1.4
 */
public synchronized WindowStateListener[] getWindowStateListeners()
{
  return (WindowStateListener[])
    AWTEventMulticaster.getListeners(windowStateListener,
                                     WindowStateListener.class);
}
 
Example 6
Project: javify   File: Window.java   View source code 5 votes vote down vote up
/**
 * Adds the specified listener to this window.
 *
 * @since 1.4
 */
public void addWindowStateListener (WindowStateListener wsl)
{
  if (wsl != null)
    {
      newEventsOnly = true;
      windowStateListener = AWTEventMulticaster.add (windowStateListener,
                                                     wsl);
    }
}
 
Example 7
Project: jvm-stm   File: Window.java   View source code 5 votes vote down vote up
/**
 * Returns an array of all the window state listeners registered on this
 * window.
 *
 * @since 1.4
 */
public synchronized WindowStateListener[] getWindowStateListeners()
{
  return (WindowStateListener[])
    AWTEventMulticaster.getListeners(windowStateListener,
                                     WindowStateListener.class);
}
 
Example 8
Project: jvm-stm   File: Window.java   View source code 5 votes vote down vote up
/**
 * Adds the specified listener to this window.
 *
 * @since 1.4
 */
public void addWindowStateListener (WindowStateListener wsl)
{
  if (wsl != null)
    {
      newEventsOnly = true;
      windowStateListener = AWTEventMulticaster.add (windowStateListener,
                                                     wsl);  
    }
}
 
Example 9
Project: AppWoksUtils   File: ExtJFrame.java   View source code 5 votes vote down vote up
/**
 * 
 */
private void macSpecials() {
    if (CrossSystem.isMac()) {
        addWindowStateListener(new WindowStateListener() {

            private boolean oldVisibleState = true;

            @Override
            public void windowStateChanged(WindowEvent e) {

                if ((getExtendedState() & JFrame.ICONIFIED) == JFrame.ICONIFIED) {
                    // there is a bug that caused MAC OS 10.9 under java
                    // 1.7.0_25-b15 to popup the iconified owner. the
                    // visible owner
                    // cannot be used or accessed in any way.
                    // workaround: setting the frame invisible in iconified
                    // state should do the job
                    oldVisibleState = isVisible();
                    setVisible(false);
                } else {
                    setVisible(oldVisibleState);
                }

            }
        });
    }

}
 
Example 10
Project: metasfresh   File: AWindowListener.java   View source code 5 votes vote down vote up
/**
 *	Constructor
 *
 * 	@param win Window
 * 	@param l Listener
 */
public AWindowListener (Window win, WindowStateListener l)
{
	m_window = win;
	m_listener = l;
	win.addWindowListener(this);
}
 
Example 11
Project: CommandGenerator   File: MainWindow.java   View source code 5 votes vote down vote up
/** The window of the program. */
public MainWindow()
{

	String title = Generator.translate("GUI:main.title");
	title = title.replaceAll("<version>", Resources.versions[Resources.versions.length - 1]);
	title = title.replaceAll("<minecraft>", Resources.versionMinecraft);

	setTitle(title);
	setSize(new Dimension(1000, 700));
	setVisible(true);
	setResizable(true);
	setLayout(new GridLayout());
	setDefaultCloseOperation(EXIT_ON_CLOSE);
	try
	{
		setIconImage(Generator.registry.getObjectFromId("command_block").getTexture().getImage());
	} catch (Exception e)
	{}

	panelGeneral = new PanelCommandSelection(true);
	panelGeneral.setSize(new Dimension(getSize().width - 10, getSize().height - 10));
	JScrollPane scrollpane = new JScrollPane(panelGeneral);
	scrollpane.getVerticalScrollBar().setUnitIncrement(20);
	menubar = new CGMenubar();

	add(scrollpane);
	setJMenuBar(menubar);

	addWindowStateListener(new WindowStateListener() {
		@Override
		public void windowStateChanged(WindowEvent arg0)
		{
			panelGeneral.setSize(new Dimension(getSize().width - 10, getSize().height - 10));
		}
	});
}
 
Example 12
Project: Emulator   File: Button.java   View source code 5 votes vote down vote up
public Button(Callback normal, Callback events, Callback callback, Window event) {
	this(normal, events, callback);
	
	Button instance = this;
	
	event.addWindowStateListener(new WindowStateListener() {
		@Override
		public void windowStateChanged(WindowEvent e) {
			if(events != null) {
    			events.run(instance);
    		}
		}
	});
}
 
Example 13
Project: AXmlSwing   File: AttributeTransfer.java   View source code 5 votes vote down vote up
public static WindowStateListener windowStateListener(final String value){
	return new WindowStateListener() {
		public void windowStateChanged(WindowEvent e) {
			actionEvent(e.getSource(), value);
		}
	};
}
 
Example 14
Project: cn1   File: AWTEventMulticaster.java   View source code 5 votes vote down vote up
public void windowStateChanged(WindowEvent e) {
    if ((a != null) && (a instanceof WindowStateListener)) {
        ((WindowStateListener) a).windowStateChanged(e);
    }
    if ((b != null) && (b instanceof WindowStateListener)) {
        ((WindowStateListener) b).windowStateChanged(e);
    }
}
 
Example 15
Project: cn1   File: Window.java   View source code 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (WindowFocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getWindowFocusListeners();
    } else if (WindowStateListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getWindowStateListeners();
    } else if (WindowListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getWindowListeners();
    } else {
        return super.getListeners(listenerType);
    }
}
 
Example 16
Project: cn1   File: Window.java   View source code 5 votes vote down vote up
protected void processWindowStateEvent(WindowEvent e) {
    for (Iterator<?> i = windowStateListeners.getUserIterator(); i.hasNext();) {
        WindowStateListener listener = (WindowStateListener) i.next();
        switch (e.getID()) {
            case WindowEvent.WINDOW_STATE_CHANGED:
                listener.windowStateChanged(e);
                break;
        }
    }
}
 
Example 17
Project: JamVM-PH   File: Window.java   View source code 5 votes vote down vote up
/**
 * Returns an array of all the window state listeners registered on this
 * window.
 *
 * @since 1.4
 */
public synchronized WindowStateListener[] getWindowStateListeners()
{
  return (WindowStateListener[])
    AWTEventMulticaster.getListeners(windowStateListener,
                                     WindowStateListener.class);
}
 
Example 18
Project: JamVM-PH   File: Window.java   View source code 5 votes vote down vote up
/**
 * Adds the specified listener to this window.
 *
 * @since 1.4
 */
public void addWindowStateListener (WindowStateListener wsl)
{
  if (wsl != null)
    {
      newEventsOnly = true;
      windowStateListener = AWTEventMulticaster.add (windowStateListener,
                                                     wsl);  
    }
}
 
Example 19
Project: classpath   File: Window.java   View source code 5 votes vote down vote up
/**
 * Returns an array of all the window state listeners registered on this
 * window.
 *
 * @since 1.4
 */
public synchronized WindowStateListener[] getWindowStateListeners()
{
  return (WindowStateListener[])
    AWTEventMulticaster.getListeners(windowStateListener,
                                     WindowStateListener.class);
}
 
Example 20
Project: classpath   File: Window.java   View source code 5 votes vote down vote up
/**
 * Adds the specified listener to this window.
 *
 * @since 1.4
 */
public void addWindowStateListener (WindowStateListener wsl)
{
  if (wsl != null)
    {
      newEventsOnly = true;
      windowStateListener = AWTEventMulticaster.add (windowStateListener,
                                                     wsl);
    }
}
 
Example 21
Project: freeVM   File: AWTEventMulticaster.java   View source code 5 votes vote down vote up
public void windowStateChanged(WindowEvent e) {
    if ((a != null) && (a instanceof WindowStateListener)) {
        ((WindowStateListener) a).windowStateChanged(e);
    }
    if ((b != null) && (b instanceof WindowStateListener)) {
        ((WindowStateListener) b).windowStateChanged(e);
    }
}
 
Example 22
Project: freeVM   File: Window.java   View source code 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (WindowFocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getWindowFocusListeners();
    } else if (WindowStateListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getWindowStateListeners();
    } else if (WindowListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getWindowListeners();
    } else {
        return super.getListeners(listenerType);
    }
}
 
Example 23
Project: freeVM   File: Window.java   View source code 5 votes vote down vote up
protected void processWindowStateEvent(WindowEvent e) {
    for (Iterator<?> i = windowStateListeners.getUserIterator(); i.hasNext();) {
        WindowStateListener listener = (WindowStateListener) i.next();
        switch (e.getID()) {
            case WindowEvent.WINDOW_STATE_CHANGED:
                listener.windowStateChanged(e);
                break;
        }
    }
}
 
Example 24
Project: freeVM   File: AWTEventMulticaster.java   View source code 5 votes vote down vote up
public void windowStateChanged(WindowEvent e) {
    if ((a != null) && (a instanceof WindowStateListener)) {
        ((WindowStateListener) a).windowStateChanged(e);
    }
    if ((b != null) && (b instanceof WindowStateListener)) {
        ((WindowStateListener) b).windowStateChanged(e);
    }
}
 
Example 25
Project: freeVM   File: Window.java   View source code 5 votes vote down vote up
@SuppressWarnings("unchecked")
@Override
public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
    if (WindowFocusListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getWindowFocusListeners();
    } else if (WindowStateListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getWindowStateListeners();
    } else if (WindowListener.class.isAssignableFrom(listenerType)) {
        return (T[]) getWindowListeners();
    } else {
        return super.getListeners(listenerType);
    }
}
 
Example 26
Project: freeVM   File: Window.java   View source code 5 votes vote down vote up
protected void processWindowStateEvent(WindowEvent e) {
    for (Iterator<?> i = windowStateListeners.getUserIterator(); i.hasNext();) {
        WindowStateListener listener = (WindowStateListener) i.next();
        switch (e.getID()) {
            case WindowEvent.WINDOW_STATE_CHANGED:
                listener.windowStateChanged(e);
                break;
        }
    }
}
 
Example 27
Project: cursus-ui   File: JFrameAutoPrefs.java   View source code 5 votes vote down vote up
public JFrameAutoPrefs(JFrame frame) {
	super(frame);
	this.frame = frame;
	prefState = makePrefName("/state"); //$NON-NLS-1$

	frame.addWindowStateListener(new WindowStateListener() {
		@Override
		public void windowStateChanged(WindowEvent we) {
			delayedSaveWindowPreference();
		}
	});
}
 
Example 28
Project: jdk8u-jdk   File: NormalToIconifiedTest.java   View source code 4 votes vote down vote up
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame testFrame = new Frame("Test Frame");
    testFrame.setSize(200, 200);
    testFrame.addWindowStateListener(new WindowStateListener() {
        @Override
        public void windowStateChanged(WindowEvent e) {
            listenerNotified.set(true);
            synchronized (listenerNotified) {
                listenerNotified.notifyAll();
            }
        }
    });
    testFrame.setVisible(true);

    Frame mainFrame = new Frame("Main Frame");
    mainFrame.setSize(200, 200);
    mainFrame.setLocationRelativeTo(null);
    mainFrame.setVisible(true);

    Util.waitForIdle(robot);

    try {
        Util.clickOnComp(mainFrame, robot);
        Util.waitForIdle(robot);

        // NORMAL -> ICONIFIED
        listenerNotified.set(false);
        testFrame.setExtendedState(Frame.ICONIFIED);
        Util.waitForIdle(robot);

        Util.waitForCondition(listenerNotified, 2000);
        if (!listenerNotified.get()) {
            throw new RuntimeException("Test FAILED! Window state listener was not notified during NORMAL to" +
                    "ICONIFIED transition");
        }
        if (testFrame.getExtendedState() != Frame.ICONIFIED) {
            throw new RuntimeException("Test FAILED! Frame is not in ICONIFIED state");
        }

        // ICONIFIED -> NORMAL
        listenerNotified.set(false);
        testFrame.setExtendedState(Frame.NORMAL);
        Util.waitForIdle(robot);

        Util.waitForCondition(listenerNotified, 2000);
        if (!listenerNotified.get()) {
            throw new RuntimeException("Test FAILED! Window state listener was not notified during ICONIFIED to" +
                    "NORMAL transition");
        }
        if (testFrame.getExtendedState() != Frame.NORMAL) {
            throw new RuntimeException("Test FAILED! Frame is not in NORMAL state");
        }
    } finally {
        testFrame.dispose();
        mainFrame.dispose();
    }
}
 
Example 29
Project: openjdk-jdk10   File: NormalToIconifiedTest.java   View source code 4 votes vote down vote up
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame testFrame = new Frame("Test Frame");
    testFrame.setSize(200, 200);
    testFrame.addWindowStateListener(new WindowStateListener() {
        @Override
        public void windowStateChanged(WindowEvent e) {
            listenerNotified.set(true);
            synchronized (listenerNotified) {
                listenerNotified.notifyAll();
            }
        }
    });
    testFrame.setVisible(true);

    Frame mainFrame = new Frame("Main Frame");
    mainFrame.setSize(200, 200);
    mainFrame.setLocationRelativeTo(null);
    mainFrame.setVisible(true);

    Util.waitForIdle(robot);

    try {
        Util.clickOnComp(mainFrame, robot);
        Util.waitForIdle(robot);

        // NORMAL -> ICONIFIED
        listenerNotified.set(false);
        testFrame.setExtendedState(Frame.ICONIFIED);
        Util.waitForIdle(robot);

        Util.waitForCondition(listenerNotified, 2000);
        if (!listenerNotified.get()) {
            throw new RuntimeException("Test FAILED! Window state listener was not notified during NORMAL to" +
                    "ICONIFIED transition");
        }
        if (testFrame.getExtendedState() != Frame.ICONIFIED) {
            throw new RuntimeException("Test FAILED! Frame is not in ICONIFIED state");
        }

        // ICONIFIED -> NORMAL
        listenerNotified.set(false);
        testFrame.setExtendedState(Frame.NORMAL);
        Util.waitForIdle(robot);

        Util.waitForCondition(listenerNotified, 2000);
        if (!listenerNotified.get()) {
            throw new RuntimeException("Test FAILED! Window state listener was not notified during ICONIFIED to" +
                    "NORMAL transition");
        }
        if (testFrame.getExtendedState() != Frame.NORMAL) {
            throw new RuntimeException("Test FAILED! Frame is not in NORMAL state");
        }
    } finally {
        testFrame.dispose();
        mainFrame.dispose();
    }
}
 
Example 30
Project: erp   File: AplicativoPD.java   View source code 4 votes vote down vote up
public AplicativoPD(String sIcone, String sSplash, int iCodSis, String sDescSis, int iCodModu, String sDescModu, String sDirImagem, final FPrincipal telaP, Class<? extends Login> cLogin) {

		if (sDirImagem != null) {
			Imagem.dirImages = sDirImagem;
			Icone.dirImages = sDirImagem;
		}
		if (System.getProperty("ARQLOG") != null)
			ligaLog(System.getProperty("ARQLOG"));
		strSplash = sSplash;
		Locale.setDefault(new Locale("pt", "BR"));
		vOpcoes = new Vector<JMenuItem>();
		vBotoes = new Vector<JButtonPad>();

		telaPrincipal = telaP;
		this.iCodSis = iCodSis;
		this.iCodModu = iCodModu;
		this.sDescSis = sDescSis;
		this.sDescModu = sDescModu;
		this.cLoginExec = cLogin;

		telaP.addWindowStateListener( new WindowStateListener() {
			
			@Override
			public void windowStateChanged(WindowEvent e) {
				System.out.println("redimensionou!");
				telaP.reposicionaImagens();
				
			}
		});
		
		
		
		imgIcone = Icone.novo(sIcone);
		telaPrincipal.setIconImage(imgIcone.getImage());

		setSplashName(sSplash);
		iniConexao();
		carregaCasasDec();
		carregaBuscaProd();
		createEmailBean();
		getMultiAlmox();
		buscaInfoUsuAtual();
		setaInfoTela();
		
		
	}
 
Example 31
Project: jdk8u_jdk   File: NormalToIconifiedTest.java   View source code 4 votes vote down vote up
public static void main(String[] args) {
    Robot robot = Util.createRobot();

    Frame testFrame = new Frame("Test Frame");
    testFrame.setSize(200, 200);
    testFrame.addWindowStateListener(new WindowStateListener() {
        @Override
        public void windowStateChanged(WindowEvent e) {
            listenerNotified.set(true);
            synchronized (listenerNotified) {
                listenerNotified.notifyAll();
            }
        }
    });
    testFrame.setVisible(true);

    Frame mainFrame = new Frame("Main Frame");
    mainFrame.setSize(200, 200);
    mainFrame.setLocationRelativeTo(null);
    mainFrame.setVisible(true);

    Util.waitForIdle(robot);

    try {
        Util.clickOnComp(mainFrame, robot);
        Util.waitForIdle(robot);

        // NORMAL -> ICONIFIED
        listenerNotified.set(false);
        testFrame.setExtendedState(Frame.ICONIFIED);
        Util.waitForIdle(robot);

        Util.waitForCondition(listenerNotified, 2000);
        if (!listenerNotified.get()) {
            throw new RuntimeException("Test FAILED! Window state listener was not notified during NORMAL to" +
                    "ICONIFIED transition");
        }
        if (testFrame.getExtendedState() != Frame.ICONIFIED) {
            throw new RuntimeException("Test FAILED! Frame is not in ICONIFIED state");
        }

        // ICONIFIED -> NORMAL
        listenerNotified.set(false);
        testFrame.setExtendedState(Frame.NORMAL);
        Util.waitForIdle(robot);

        Util.waitForCondition(listenerNotified, 2000);
        if (!listenerNotified.get()) {
            throw new RuntimeException("Test FAILED! Window state listener was not notified during ICONIFIED to" +
                    "NORMAL transition");
        }
        if (testFrame.getExtendedState() != Frame.NORMAL) {
            throw new RuntimeException("Test FAILED! Frame is not in NORMAL state");
        }
    } finally {
        testFrame.dispose();
        mainFrame.dispose();
    }
}
 
Example 32
Project: j2se_for_android   File: Window.java   View source code 4 votes vote down vote up
public synchronized void addWindowStateListener(WindowStateListener l) {
	if (l == null) {
		return;
	}
	list.add(WindowStateListener.class, l);
}
 
Example 33
Project: j2se_for_android   File: Window.java   View source code 4 votes vote down vote up
public synchronized void removeWindowStateListener(WindowStateListener l) {
	if (l == null) {
		return;
	}
	list.remove(WindowStateListener.class, l);
}
 
Example 34
Project: j2se_for_android   File: Window.java   View source code 4 votes vote down vote up
public synchronized WindowStateListener[] getWindowStateListeners() {
	return getListeners(WindowStateListener.class);
}
 
Example 35
Project: cn1   File: AWTEventMulticaster.java   View source code 4 votes vote down vote up
public static WindowStateListener add(WindowStateListener a, WindowStateListener b) {
    return (WindowStateListener) addInternal(a, b);
}
 
Example 36
Project: cn1   File: AWTEventMulticaster.java   View source code 4 votes vote down vote up
public static WindowStateListener remove(WindowStateListener l, WindowStateListener oldl) {
    return (WindowStateListener) removeInternal(l, oldl);
}
 
Example 37
Project: cn1   File: Window.java   View source code 4 votes vote down vote up
public void addWindowStateListener(WindowStateListener l) {
    windowStateListeners.addUserListener(l);
}
 
Example 38
Project: cn1   File: Window.java   View source code 4 votes vote down vote up
public WindowStateListener[] getWindowStateListeners() {
    return windowStateListeners.getUserListeners(new WindowStateListener[0]);
}
 
Example 39
Project: cn1   File: Window.java   View source code 4 votes vote down vote up
public void removeWindowStateListener(WindowStateListener l) {
    windowStateListeners.removeUserListener(l);
}
 
Example 40
Project: freeVM   File: AWTEventMulticaster.java   View source code 4 votes vote down vote up
public static WindowStateListener add(WindowStateListener a, WindowStateListener b) {
    return (WindowStateListener) addInternal(a, b);
}