GUI appears grey until resize randomly. Why?
I have about 2 questions.
1) If I add certain text lengths to JTextField() the GUI appears gray until I resize it. "Hi" verses "Hello Java" makes all the difference. Only does this sometimes?!?
Code:
JTextField pageAddress = new JTextField("Hello Java", 20);
It also makes a difference messing with the boolean value of JCheckBox() making it true vs leaving it out changes the issue above.
Code:
JCheckBox jumboSize = new JCheckBox("Jumbo Size");
2) JLabel.LEFT CENTER or RIGHT doesnt seem to do anything. Why is this?
Here is all my code for my test program. Perhaps I am missing something?
Code:
import javax.swing.*;
import java.awt.*;
public class Playback extends JFrame {
public Playback() {
setTitle("Note Trainer");
setSize(370,360);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setVisible(true);
FlowLayout flo = new FlowLayout();
setLayout(flo);
JLabel pageLabel = new JLabel("Web page address: ", JLabel.LEFT);
JTextField pageAddress = new JTextField("He", 20);
add(pageLabel);
add(pageAddress);
JButton A = new JButton("A");
JButton B = new JButton("B");
JButton C = new JButton("C");
JButton D = new JButton("D");
JButton E = new JButton("E");
JButton F = new JButton("F");
JButton G = new JButton("G");
add(A);
add(B);
add(C);
add(D);
add(E);
add(F);
add(G);
JCheckBox jumboSize = new JCheckBox("Jumbo Size");
add(jumboSize);
}
public static void main(String[] args) {
Playback pb = new Playback();
}
}