Could you tell me what methods are called upon a JFrame/JDialog after you resize it manually?
( after you resize it using the mouse cursor, while the frame is visible on the screen). I noticed that my JDialog is not valid eventhough I call validate()
or revalidate()
upon it, but after I resize it a bit, my frame becomes valid.
Asked
Active
Viewed 1,124 times
2
-
2Your question is not clear. What do you mean by "frame becomes valid"? Also if you can provide sscce – Ashwinee K Jha Apr 01 '12 at 09:48
-
1As I see you would like to make your JDialog be valid as it becomes valid after resize. Look at this thread about validating o JComponent: http://stackoverflow.com/questions/8362484/why-cant-i-validate-a-jcomponent – dexametason Apr 01 '12 at 09:53
-
Becomes vaild means that the frame.isValid() returns true ... I don't think this is so ambiguous. – Teo Apr 01 '12 at 10:10
-
sounds like something is wrong with the code you are not showing ... usually, validation is handled automatically – kleopatra Apr 01 '12 at 14:07
2 Answers
1
I think it is java.awt.event.ComponentListener
The listener interface for receiving component events. When the component's size, location, or visibility changes, the relevant method in the listener object is invoked, and the ComponentEvent is passed to it.
For example:
public class MyFrame extends JFrame implements ComponentListener {
@Override
public void componentResized(ComponentEvent e) {
// re compute?
repaint();
}
}

Pau Kiat Wee
- 9,485
- 42
- 40
-
shouldn't be necessary ... usually repaints are handled automatically if necessary – kleopatra Apr 01 '12 at 14:08
0
With this code I am able to resize the width, height of 3 tables.
container.addControlListener(new ControlAdapter() {
@Override
public void controlResized(ControlEvent e) {
tableJobs.setBounds(20, 143,container.getBounds().width-40, container.getBounds().height-20);
tableMessages.setBounds(20, 143,container.getBounds().width-40, container.getBounds().height-20);
tableSplfs.setBounds(20, 143,container.getBounds().width-40, container.getBounds().height-20);
}
});

Brian Tompsett - 汤莱恩
- 5,753
- 72
- 57
- 129