Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Truncated text in Label

 
iyappan sankaran
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i have a probelm :
In windows the text in Jlabel is displayed correctely like

HI Iyappan

while in solaris the text get truncated and displayed like this

HI Iyp. . .

i attach source
. . .
getContentPane().setLayout(null);
l1=new JLabel("HI Iyappan");
getContentPane().add(l1);
getContentPane().add(l2);
l1.setBounds(100,10,40,15);
. . .


urgent pls give solution .
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
you've posted this 4 times in 3 forums over 2 days
no replies

perhaps it is a solaris problem, rather than a java/swing problem?
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
getContentPane().setLayout(null);
l1=new JLabel("HI Iyappan");
getContentPane().add(l1);
getContentPane().add(l2);
l1.setBounds(100,10,40,15);


There's your problem - don't use null layout and expect components to be sized correctly.
[ August 23, 2006: Message edited by: Nathan Pruett ]
 
Brian Mozhdehi
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As a follow up to Nathan's post....if you want very explicit control over where your label appears on the screen, use GridBagLayout. Its the more complicated of all layouts, but its the only way you can essentially boss the jvm around and make your components appear where you want them to consistently. IMHO, the only other Layout class that has any value whatsoever is BoxLayout. The rest of them pretty much produce fairly amateur looking screens (again, in my opinion).

To Nathan's point.....NULL layout will work, but only on one screen dimension/resolution/platform. It also will cause issues on repaint, i.e. if the user minimizes and maximizes the screen (because it loses the setbounds property once the "bounds" no longer exist, which they wont on a minimize)
 
shansi raj
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even I have come across the same problem and I resolved it by making the frame size bigger and the length between the components is more ie... use gridbag layout and the length between the JLabel and Jtextfield should be more.Then it gets adjusted and the text of the label is displayed fully.
 
iyappan sankaran
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Guys.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic