How to get the JFrame of a component?
This demo give an example on how to get the
JFrame of a component. In this example we try to get the
JFrame from a button action listener event. To get the
JFrame we utilize the
SwingUtilities.getRoot() method and this will return the root component of the component tree in out small program below which is a
Beside getting the
JFrame, in this program we also do small stuff like changing the frame background color by a random color every time a user presses the Change Frame Color button.