How to set JFrame to appear centered, regardless of monitor resolution?

Use setLocationRelativeTo(null) This method has a special effect when you pass it a null. According to the Javadoc: If the component is null, or the GraphicsConfiguration associated with this component is null, the window is placed in the center of the screen. This should be done after setting the size or calling pack(), but before … Read more

How to programmatically close a JFrame

If you want the GUI to behave as if you clicked the X close button then you need to dispatch a window closing event to the Window. The ExitAction from Closing An Application allows you to add this functionality to a menu item or any component that uses Actions easily. frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)