import java.text.Collator;
import java.util.Collections;
import java.util.Locale;
import java.util.Vector;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
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.getContentPane().add("Center", panel);
frame.pack();
frame.setVisible(true);
}
}
|