Swing: Définir la position d’affichage d’une fenêtre

Author:

 set, swing, awt, JFrame
{filelink=172}

import java.awt.*;




public class WindowsCenter {

    /** Définir la position d'affichage d'une fenêtre de type Frame, JFrame, Dialog, etc. */

    public static void centre(Window w) {

        Dimension windowsSize = w.getSize( ), 
        screenSize = Toolkit.getDefaultToolkit( ).getScreenSize( );

        int x = (screenSize.width - windowsSize.width) / 2;

        int y = (screenSize.height- windowsSize.height)/ 2;

        w.setLocation(x, y);

    }
    public static void center(Window w) {

        WindowsCenter.centre(w);

    }

}

A Voir sur le même Sujet:

  • animation texte en jframe
  • exemple de code swing java
  • size JButton

Leave a Reply

Your email address will not be published. Required fields are marked *