Java JSpinner create from String list of week day names

Description

Java JSpinner create from String list of week day names

import java.awt.FlowLayout;
import java.text.DateFormatSymbols;
import java.util.Locale;

import javax.swing.JFrame;
import javax.swing.JSpinner;
import javax.swing.SpinnerListModel;
import javax.swing.SpinnerModel;

public class Main extends JFrame {
   public Main() {
      super("java2s.com");

      setDefaultCloseOperation(EXIT_ON_CLOSE);
      setLayout(new FlowLayout());

      DateFormatSymbols symbols = new DateFormatSymbols(Locale.FRENCH);

      String days[] = symbols.getWeekdays();
      SpinnerModel model = new SpinnerListModel(days);
      JSpinner spinner = new JSpinner(model);

      getContentPane().add(spinner);/*from   www  . j a v a 2  s .  c  o m*/
   }

   public static void main(String[] args) {
      Main frame = new Main();
      frame.pack();
      frame.setVisible(true);
   }
}



PreviousNext

Related