Following are the techniques of the ComponentListener Interface:
componentHidden(ComponentEvent) - method is called after the listened-to component is hidden.
componentMoved(ComponentEvent) - method is called after the listened-to component moves.
componentResized(ComponentEvent) - method is called when the listened-to component's size changes.
The following is the method of the ComponentEvent Class:
Component getComponent() - method returns the component that fired the event.
Use the code given below which is helpful for you:
Code:
private static void createAndShowGUI() {
frame = new JFrame("TrialComponentEvent");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JComponent newContentPane = new ComponentEventDemo();
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);
frame.pack();
frame.setVisible(true);
}
Bookmarks