Hope you are all well!
Hope you understand my Java question... I have created a JFrame window with text to display, but it doesn't display at run-time (as it should) unless I maximise the Frame window.
Can't understand it?
Here's some code:
package test;
import javax.swing.*;
class Test{
private String x;
private Test() {
x="150";
}
public static void main(String[] args) {
Test o1 = new Test();
JTextField l = new JTextField(o1.x, JTextField.CENTER);
l.setAlignmentX(0);
l.setAlignmentY(0);
JFrame window = new JFrame("Hello World!");
window.setSize(800, 600);
window.setResizable(true);
window.setVisible(true);
window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
window.add(l);
}
}
Altering the size of the frame (by maximising it) will cause it to be repainted. The reason it needs to be repainted is that you added content to it after you already made it visible.
Instead, you could move window.setVisible(true);
to the end, so you don't show the window until you've added everything to it.