Files
oop/lab/lab10/Question1/Start.java
2022-05-01 23:24:00 +08:00

48 lines
1.7 KiB
Java

/**
* Answer to question.
*
* - Q: In the constructor of the MyFrame class, comment out the call to the
* setTitle method. Run the program. What happens? Then undo the commenting out.
*
* - A: The title will become empty.
*
* - Q: Comment out the call to the setSize method. Run the program. What
* happens? Then undo the commenting out
*
* - A: Yes the program is still running. Because the "close windows" event is
* not linked to the program ended event. So the program won't known the windows
* is closed and will continue running.
*
* - Q: Comment out the call to the setVisible method. Run the program. What
* happens?
*
* - A: Frame will not show and program will end.
*
* - Q: In a line before the call to the setVisible method, add a call to the
* setLocationRelativeTo method of the frame and give it an argument of null.
* Run the program. What happens?
*
* - A: The frame will show in the center of the screen. But did not work as
* expected while using mutiple screen and x11-wayland or wayland platform.
*
* - Q: In the run method of the anonymous class inside the Start class, add a
* second MyFrame object. Run the program. What happens? (Use the mouse to move
* the frame to check what happens!) What happens when you close one of the
* two frames? Then undo the change in the run method.
*
* - A: Two frame will show in the screen. If one of the frame is closed, the
* both frame will be closed. Because they are connnect to the same event.
*
*/
public class Start {
public static void main(String[] args) {
// Dispather
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new MyFrame();
}
});
}
}