Results 1 to 4 of 4
  1. #1
    AcousticBruce is offline Senior Member
    Join Date
    Dec 2010
    Location
    Indiana
    Posts
    202
    Rep Power
    3

    Default 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?!?

    Java 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.

    Java 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?

    Java 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();
        }
    }
    Last edited by AcousticBruce; 12-13-2010 at 05:41 PM.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,252
    Blog Entries
    1
    Rep Power
    24

  3. #3
    AcousticBruce is offline Senior Member
    Join Date
    Dec 2010
    Location
    Indiana
    Posts
    202
    Rep Power
    3

    Default

    Ahh... I thought that was needed once within { }.

    Thank you.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,252
    Blog Entries
    1
    Rep Power
    24

    Default

    Quote Originally Posted by AcousticBruce View Post
    Ahh... I thought that was needed once within { }.

    Thank you.
    It is only needed once, but it should be called only after the GUI has been set up.

Similar Threads

  1. Math tutor, no errors, nothing appears when run!
    By Reiyn in forum New To Java
    Replies: 6
    Last Post: 11-11-2010, 10:28 AM
  2. Replies: 23
    Last Post: 12-22-2009, 08:33 PM
  3. Replies: 11
    Last Post: 10-27-2009, 07:55 AM
  4. Grey Box
    By mja229 in forum New To Java
    Replies: 2
    Last Post: 12-24-2008, 07:24 PM
  5. Replies: 3
    Last Post: 07-19-2007, 11:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •