Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / August 2005

Tip: Looking for answers? Try searching our database.

Unicode - UGLY GUI

Thread view: 
ravi.k.sinha@gmail.com - 28 Jun 2005 11:41 GMT
Hi,

I m working on a GUI app. which uses Indian langage input methods, in
short it makes use of Unicode.

I run the app with the following command line

java -Dfile.encoding="UTF-8" package.myClass

Doing this results in puffed up visual widgets, for e.g., the buttons
height is increased, the same for labels, fields, text area. All the
GUI looks totally bloated.

How can we correct this problem?

Thank you.
Andrew Thompson - 28 Jun 2005 12:05 GMT
> java -Dfile.encoding="UTF-8" package.myClass
>
> Doing this results in puffed up visual widgets,

Are they 'puffed up' to accommodate the font size?

Perhaps it would help provide a short example.

Signature

Andrew Thompson
http://www.PhySci.org/codes/  Web & IT Help
http://www.PhySci.org/  Open-source software suite
http://www.1point1C.org/  Science & Technology
http://www.LensEscapes.com/  Images that escape the mundane

Thomas Weidenfeller - 28 Jun 2005 12:14 GMT
> I run the app with the following command line
>
[quoted text clipped - 3 lines]
> height is increased, the same for labels, fields, text area. All the
> GUI looks totally bloated.

The file encoding - which is for file I/O - has nothing to do with what
happens inside Java or the GUI. Java always used Unicode characters
internally and for the GUI. Changing the file I/O encoding has no impact
on the encoding used in Java or the GUI per-se.

There is something else going wrong in your code. Maybe you read data
from a file which is later displayed. By changing the file encoding the
data in the file gets already misinterpreted when it is read. You later
display the data. Since it got misinterpreted when it was read it refers
to other characters. These other characters might force the layout
managers in the GUI to dynamically adapt the GUI to accommodate
different character sizes.

Very likely there is nothing wrong in the GUI, and everything wrong in
the way you do file I/O. It is already a bad idea to require that a file
encoding needs to be specified on the command line. You could revise
your code.

> How can we correct this problem?

Follow this advice

<http://www.physci.org/codes/sscce.jsp>

and show us code demonstrating the problem. Not any code, but code which
is in line with the above referred advice.

/Thomas

Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

ravi.k.sinha@gmail.com - 28 Jun 2005 12:45 GMT
Hi Thomas,

I would have loved to give some code, but there is nothing special in
the code. We are using a set of input methods that enables us to
provide input in Indian languages. These are in the form of jar files,
which specify the input characteristics of various Indian Languages.
All these Jar files lie in extention directory inside the JRE.

Now if i don't explicitly set the file encoding, there is no problem
locally. But when the same data comes on the Java socket (Application
is distributed, needs to send messages in local languages some times)
then the data is all garbled, questions marks or usual rectangles, in
the GUI.

In the system menu, a item gets installed automatically when an app is
run giving access to various input methods.

In our application when an item is selected in the menu, we just change
the input method, and which is taken care of those classes lying in the
extention.

I have a hunch that some other setting is required which will dictate
the display of widgets.

I have two installations
1.  1.4.2_08 (Jars in extention)
2. 1.5.0_03 (No Jars)

With [1] the description remains same, but with [2] the same app is ok

Thanks everyone for the replies, but unfortunately I am still in the
haze.
Roedy Green - 29 Aug 2005 08:16 GMT
>Very likely there is nothing wrong in the GUI, and everything wrong in
>the way you do file I/O. It is already a bad idea to require that a file
>encoding needs to be specified on the command line. You could revise
>your code.

Normally you specify the encoding in your i/o code. See
http://mindprod.com/applets/fileio.html
for how to do it.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Thomas Kellerer - 28 Jun 2005 12:20 GMT
> Hi,
>
[quoted text clipped - 4 lines]
>
> java -Dfile.encoding="UTF-8" package.myClass

AFAIK file.encoding does not have any impact on the Swing classes.
This is (only?) used by Reader and Writer implementations as the default encoding.

Thomas
Thomas Fritsch - 28 Jun 2005 14:46 GMT
>>Hi,
>>
[quoted text clipped - 9 lines]
>
> Thomas
Yes, the constructors
  InputStreamReader(InputStream)
  OutputStreamReader(OutputStream)
  FileReader(...)
  FileWriter(...)
  -and may be some more?-
do so.

But furthermore the constructors
  String(byte[])
  String(byte[], int, int)
and the methods of String class
  byte[] getBytes()
  void getBytes(int, byte[], int, int)
depend on the default encoding, too.

I recommend to avoid these constructors/methods altogether.
Most of them have sister constructors/methods which take an encoding
name as an additional String argument.

Signature

"Thomas:Fritsch$ops:de".replace(':','.').replace('$','@')

Roedy Green - 29 Aug 2005 08:19 GMT
On 28 Jun 2005 03:41:35 -0700, ravi.k.sinha@gmail.com wrote or quoted

>java -Dfile.encoding="UTF-8" package.myClass

I tried this with one of my own Applications and I noticed no
difference in the GUI. Is there anything else you are changing at the
same time?

What is the default file.encoding ?

Perhaps for us to see a shrinking effect we have to set your file
default file encoding.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.