I am developing a java swing desktop application with NetBeans and I want to set the JFrame to the center of the screen.
from the network I understand that I can use
setLocationRelativeTo(null);
to set the frame to the center But I canβt paste the code into the NetBeans IDE because
frame.pack()
and frame.setVisible()
NetBeans 7 IDE codes are generated and this will prevent code from being entered between these two methods. to get the following:
frame.pack()
setLocationRelativeTo(null);
frame.setVisible()
Any suggestions to fix the problem.
source
share