Unicode sorting : Code Unicode : Development Class : Java examples (example source code) Organized by topic

Java
C++
PHP
Java Home »  Development Class   » [  Code Unicode  ]  Screenshots 
 



Unicode sorting




/*
Java Internationalization
By Andy Deitsch, David Czarnecki

ISBN: 0-596-00019-7
O'Reilly
*/

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

public class JavaSort extends JPanel {
  static JFrame frame;
  public JavaSort() {
    Vector list = new Vector();
    list.add("\u00e4pple");
    list.add("banan");
    list.add("p\u00e4ron");
    list.add("orange");

    // Obtain a Swedish collator
    Collator collate = Collator.getInstance(new Locale("sv"""));
    Collections.sort(list, collate);

    StringBuffer result = new StringBuffer();
    for (int i= 0;i < list.size(); i++) {
      result.append(list.elementAt(i));
      result.append(" ");
    }
    add(new JLabel(result.toString()));
  }

  public static void main(String s[]) {
    JavaSort panel = new JavaSort();
    frame = new JFrame("JavaSort");
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {System.exit(0);}
    });
    frame.getContentPane().add("Center", panel);
    frame.pack();
    frame.setVisible(true);
  }
}



           
       
Related examples in the same category
1.  Unicode: Fonts and Text Rendering Unicode: Fonts and Text Rendering
2.  Unicode: TrueType Font Test Unicode: TrueType Font Test
3.  Unicode: test layout Unicode: test layout
4.  Conversion between Unicode characters and Strings Conversion between Unicode characters and Strings
5.  Convert among Unicode, ASCII and byte/int Convert among Unicode, ASCII and byte/int
6.  Unicode - show a page of Unicode characters
7.  Vis - make special characters visible
8.  Demonstrate creating readers and writers with a specific encoding
9.  TextArea with Unicode TextArea with Unicode
10.  Unicode display Unicode display
11.  Internationalized Graphical User Interfaces: unicode cut and paste Internationalized Graphical User Interfaces: unicode cut and paste
12.  Stream Converter Unicode Stream Converter Unicode
13.  String Converter Unicode String Converter Unicode
























Home| Contact Us
Copyright 2003 - 04 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.