Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Swing Character Support above 127


  • From: jshirah@xxxxxxx (Joe Sam Shirah)
  • Subject: Swing Character Support above 127
  • Date: Tue, 30 Nov 1999 13:17:53 -0500

This is a multi-part message in MIME format.

------=_NextPart_000_014F_01BF3B35.4EDB65D0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit


    Hi John,

    There are actually several considerations here.  This will generally
address Windows, comments/clarifications on other OSes and in general are
welcome.

    First, Swing knows little or nothing about fonts, these are AWT
creatures, so this aspect has nothing to do with Swing support.

    Next, standard ASCII is 128 characters.  The 256 generally expected in
PC land is due to IBM's extensions.  Incidentally, in this set, 153 ( 0x99 )
is a capital O with an umlaut.

    Windows, which I suspect you are using, uses ANSI, not ASCII.  Here 153
is (TM) which you are expecting.  NT actually uses Unicode under the covers
and translates between Unicode and ANSI as necessary.  Win 95 is ANSI only,
I don't know about Win 98.

    Java uses Unicode.  In Unicode, the first 128 characters coincide with
ASCII ( what a coincidence! ) from there through 159 (9F) are more control
characters.    TM doesn't occur untill \u2122  ( decimal 8482 ).

    Whenever you see boxes or question marks, your first thought should be,
"the current font doesn't support this character."  I'm attaching a program
that shows the Unicode characters from 0 through 255 ( when possible ) using
default available fonts.  Toolkit.getFontList(), while deprecated in 1.2, is
used here so the program will also run under 1.1.


                                                        Joe Sam


Joe Sam Shirah
Autumn Software
What you don't know DOES hurt you...and your business
___________________________________________

-----Original Message-----
From: John Ragan <jragan@xxxxxxxxxxxxxx>
To: Advanced Java <advanced-java@xxxxxxxxxxxxxxxx>
Date: Tuesday, November 30, 1999 9:10 AM
Subject: Swing Character Support above 127


>I ran some tests where JDialog could display characters assigned integer
>values up to 127, but 128 or higher displayed a question mark.  I am
>tracking a JTextBox problem, where it is displaying squares for a character
>value of 153 (TM).  I suspect Swing only support character values up to
>127 - am I correct?
>
>WE'RE HIRING!
>
>John Ragan
>Senior Software Developer
>webMethods, Inc.
>3877 Fairfax Ridge Road, 4th Floor
>Fairfax, VA  22030   USA
>Email: jragan@xxxxxxxxxxxxxx
>http://www.webmethods.com/company/employment/index.html
>



------=_NextPart_000_014F_01BF3B35.4EDB65D0
Content-Type: application/octet-stream;
	name="jta256.java"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="jta256.java"

// jta256 - Show 256 Unicode values with basic fonts
// Compiled under NT 4.0, SP5; JDK 1.2.2
// Tested under
// NT 4.0, SP5; JDK 1.2.2 and JRE 1.1.8, Swing 1.1.1
//
//  Joe Sam Shirah    jshirah@xxxxxxx
//  Autumn Software


import javax.swing.*;
import javax.swing.event.*;
import java.awt.*;
import java.awt.event.*;


public class jta256 extends JFrame
                    implements ListSelectionListener,
                               WindowListener
{
  int         iChars = 256,
              iSize,
              iStyle;

  JList       jl;
  JPanel      jpCenter,
              jpSouth;
  JTextArea   jta;
  JScrollPane jspChars;


  public jta256()
  {
    super("jta256");

    jl = new JList( Toolkit.getDefaultToolkit().getFontList() );
    jl.addListSelectionListener( this );

    jta = new JTextArea( 10, 20 );
    appendChars();
    jspChars = new JScrollPane( jta );
    jpCenter = new JPanel();
    jpCenter.add( jspChars );

    jpSouth = new JPanel();
    jpSouth.add( jl );

    Container cp = getContentPane();
    cp.add( jpCenter, BorderLayout.CENTER );
    cp.add( jpSouth,  BorderLayout.SOUTH );

    addWindowListener( this );
    pack();
    show();

    Font f = jta.getFont();
    iSize = f.getSize();
    iStyle = f.getStyle();

  } // end constructor


  public void appendChars()
  {
    char theChar = 0;

    jta.setText("");

    for( int index = 0; index < iChars; index++, theChar++ )
    {
      jta.append( "Char " + (int)theChar + ": " + 
                   String.valueOf( theChar ) + ".\n" );
    }

    jta.append( "256 characters presented.\n\n" );
    jta.append( "Font Info :\n" + jta.getFont() + "\n" );
    return;

  } // end appendChars


  public void valueChanged(ListSelectionEvent e)
  {
    Font theFont = new Font( 
                      (String)jl.getSelectedValue(),
                       iStyle, iSize );
    jta.setFont( theFont );
    appendChars();
  }  // end valueChanged


// Window Listener Implementation
    public void windowOpened(WindowEvent e) {}
     public void windowClosing(WindowEvent e)
     {
       dispose();
       System.exit(0);
     }
    public void windowClosed(WindowEvent e) {}
    public void windowIconified(WindowEvent e) {}
    public void windowDeiconified(WindowEvent e) {}
    public void windowActivated(WindowEvent e) {}
    public void windowDeactivated(WindowEvent e) {}
// End Window Listener Implementation


  public static void main(String[] args)
  {
    new jta256();

  } // end main

} // end class jta256

------=_NextPart_000_014F_01BF3B35.4EDB65D0--


---
To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx