This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes Truncated text in Label Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Truncated text in Label" Watch "Truncated text in Label" New topic
Author

Truncated text in Label

iyappan sankaran
Ranch Hand

Joined: Aug 11, 2003
Posts: 58
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

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Oct 18, 2000
Posts: 4121

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 ]

-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Brian Mozhdehi
Ranch Hand

Joined: Aug 17, 2006
Posts: 81
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

Joined: Jul 05, 2006
Posts: 25
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

Joined: Aug 11, 2003
Posts: 58
Thanks Guys.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Truncated text in Label