Hi I am doing a lab where I have to print out all of the locales when the JButton is pressed but when I run the program all it does is show the Vietnamese locale anyone any suggestions how to show them ALL ?
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.text.SimpleDateFormat;
import java.util.*;
public class LocalesList extends JFrame implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
JButton LocaleButton = new JButton("LocaleList");
JTextArea LocaleList1 = new JTextArea(20 , 20);
public LocalesList(){
super("Locale list");//build the gui
Container GuiCont = getContentPane();
JPanel LocalePanel = new JPanel();
LocalePanel.add(LocaleButton);
LocalePanel.add(LocaleList1);
GuiCont.add(LocalePanel);
setSize(600, 600);
setVisible(true);
LocaleButton.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == LocaleButton){
Locale list[] = SimpleDateFormat.getAvailableLocales();
Set set = new TreeSet();
for (int i = 0; i < list.length; i++) {
set.add(list[i].getDisplayName() +"\t\t\t:\t"+ list[i].toString());
}
Iterator it = set.iterator();
while (it.hasNext()) {
LocaleList1.setText((String) it.next() );
}
}
}
public static void main(String[]args){
LocalesList tryit = new LocalesList();
}
}