CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: JLabel question

  1. #1
    Join Date
    Mar 2000
    Location
    Kaysville, UT
    Posts
    228

    JLabel question

    Is there any reason you can't use a JLabel more than once in the same JPanel? I can't seem to. For example:

    JLabel testLabel = new JLabel("T");
    testLabel.setForeground(Color.black);
    testLabel.setFont(stdFont);
    this.add(testLabel);

    //I add a JTextField here

    this.add(testLabel);

    //I add a JTextField here

    this.add(testLabel);



    doesn't work. Only the last added JLabel will appear. Does anyone know a way around this?


    "There's nothing more dangerous than a resourceful idiot." ---Dilbert
    BWAHAHAHAHAHAHA! ---Murray

  2. #2
    Join Date
    Sep 2000
    Location
    Texas
    Posts
    22

    Re: JLabel question

    make a second jLabel

    "There are no facts, only interpretations."
    -Friedrich Nietzsche

  3. #3
    Join Date
    Sep 2000
    Location
    Texas
    Posts
    22

    Re: JLabel question

    I just realized that I didn't give you any explaination..
    You'll need a different JLabel for each label you put on the GUI. It is because each item on the GUI is an object w/ specific properties (such as size, position on screen, etc.) And you can't have one object in more than one place at any time.. that is why you need to have the extra jLabels, even if they say the same thing

    "There are no facts, only interpretations."
    -Friedrich Nietzsche

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured