Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.gui > #2693

Re: JLebel as a container

Path csiph.com!x330-a1.tempe.blueboxinc.net!feeder1.hal-mli.net!news.glorb.com!news-out.readnews.com!transit3.readnews.com!news-out.news.tds.net!newsreading01.news.tds.net!86597e80!not-for-mail
From "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this>
Subject Re: JLebel as a container
Message-ID <7a42e8aa4e8ca@uwe> (permalink)
X-Comment-To comp.lang.java.gui
Newsgroups comp.lang.java.gui
In-Reply-To <1193388915.336894.268240@d55g2000hsg.googlegroups.com>
References <1193388915.336894.268240@d55g2000hsg.googlegroups.com>
Content-Type text/plain; charset=IBM437
Content-Transfer-Encoding 8bit
X-Gateway time.synchro.net [Synchronet 3.15a-Win32 NewsLink 1.92]
Lines 56
Date Wed, 27 Apr 2011 15:40:37 GMT
NNTP-Posting-Host 96.60.20.240
X-Complaints-To news@tds.net
X-Trace newsreading01.news.tds.net 1303918837 96.60.20.240 (Wed, 27 Apr 2011 10:40:37 CDT)
NNTP-Posting-Date Wed, 27 Apr 2011 10:40:37 CDT
Organization TDS.net
Xref x330-a1.tempe.blueboxinc.net comp.lang.java.gui:2693

Show key headers only | View raw


  To: comp.lang.java.gui
Chanchal wrote:
..
>I'm trying to add a JLable 'jLable2 to another JLabel 'jLabel1'. 

Why?

>..But
>jLabel2 is not getting displayed.

Try this variant that adds both JLabels directly to the JFrame.
If that is not the effect you are after, there are many alternatives,
including adding them both to a JPanel that is itself added to 
one particular area of the BorderLayout of the JFrame.

<sscce>
import java.awt.BorderLayout;
import javax.swing.*;

public class LabelTest extends JFrame {

  public LabelTest(){

    setDefaultCloseOperation(
      WindowConstants.EXIT_ON_CLOSE);
    JLabel jLabel1 = new JLabel();
    jLabel1.setText("jLabel1");
    JLabel jLabel2 = new JLabel();
    jLabel2.setText(" TEXT ");
    //jLabel1.add(jLabel2);
    getContentPane().add(
      jLabel1, BorderLayout.CENTER);
    getContentPane().add(
      jLabel2, BorderLayout.EAST);
    pack();
  }

  public static void main(String args[]) {
    LabelTest lTest = new LabelTest ();
    lTest.setSize(400,300);
    lTest.setVisible(true);
  }
}
</sscce>

-- 
Andrew Thompson
http://www.athompson.info/andrew/

Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-gui/200710/1

---
 * Synchronet * The Whitehouse BBS --- whitehouse.hulds.com --- check it out free usenet!
--- Synchronet 3.15a-Win32 NewsLink 1.92
Time Warp of the Future BBS - telnet://time.synchro.net:24

Back to comp.lang.java.gui | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

JLebel as a container "Chanchal" <chanchal@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000
  Re: JLebel as a container "Andrew Thompson" <andrew.thompson@THRWHITE.remove-dii-this> - 2011-04-27 15:40 +0000

csiph-web