FileDocCategorySizeDatePackage
Sort.javaAPI DocExample1007Fri Mar 30 00:14:30 BST 2001None

Sort.java

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

public class Sort extends JPanel {
  static JFrame frame;
  public Sort() {
    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[]) {
    Sort panel = new Sort();
    frame = new JFrame("Sort");
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {System.exit(0);}
    });
    frame.getContentPane().add("Center", panel);
    frame.pack();
    frame.setVisible(true);
  }
}