jframe mittig positionieren code example
Example: jframe mittig positionieren
public class MyFrame {
public MyFrame(String title) {
JFrame frame = new JFrame(title);
frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
int windowWidth = 800;
int windowHeight = 600;
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
frame.setBounds((screenSize.width-windowWidth)/2, (screenSize.height-windowHeight)/2, windowWidth, windowHeight);
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new MyFrame("Byte-Welt.net");
}
});
}
}