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

    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,316
    Blog Entries
    1
    Rep Power
    26

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

    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,316
    Blog Entries
    1
    Rep Power
    26

    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. Replies: 26
    Last Post: 12-03-2013, 02:55 PM
  2. 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
  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
  •