CREATING A JSLIDER AND PUTTING NAMES OF THE MONTHS ON IT!
hey!
i wanna creat a Jslider and put the names of the months on it (starting from Jan to Dec) .i tried but all in vain.
i want some body to please help me.(it is the third slider in my code)
thanks!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import java.text.SimpleDateFormat;
public class Grid extends JFrame /*implements ActionListener*/
{
static final int FPS_INIT = 15;//initial frames per second
static final int FPS_INIT2=2000;
//THIS LINE
static final double FPS_INIT3=Aug;
int intframeNumber = 0;
int delay;
boolean frozen = false;
private JPanel date_panel,year_panel, month_panel,day_panel;
private String time=new String("");
private Date date=new Date();
public Grid() {
time=time + new Date().toString();
SimpleDateFormat formatter = new SimpleDateFormat("E, MMMM d, yyyy") ;
time = formatter.format(date) ;
date_panel=new JPanel();
year_panel=new JPanel();
month_panel=new JPanel();
day_panel=new JPanel();
JSlider framesPerSecond = new JSlider(JSlider.HORIZONTAL,
1, 31, FPS_INIT);
JSlider framesPerSecond2 = new JSlider(JSlider.HORIZONTAL,
1990, 2010, FPS_INIT2);
//THIS LINE
JSlider framesPerSecond3 = new JSlider(JSlider.HORIZONTAL,
Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec, FPS_INIT3);
date_panel.setLayout(new FlowLayout());
date_panel.add(new JLabel(time));
day_panel.setLayout(new FlowLayout());
day_panel.add(framesPerSecond);
year_panel.setLayout(new FlowLayout());
year_panel.add(framesPerSecond2);
month_panel.setLayout(new FlowLayout());
month_panel.add(framesPerSecond3);
//JSlider framesPerSecond = new JSlider(JSlider.HORIZONTAL,
// 0, 31, FPS_INIT);
//framesPerSecond.addChangeListener(new SliderListener());
//Turn on labels at major tick marks.
framesPerSecond.setMajorTickSpacing(5);
framesPerSecond.setMinorTickSpacing(1);
framesPerSecond.setPaintTicks(true);
framesPerSecond.setPaintLabels(true);
framesPerSecond.setBorder(
BorderFactory.createEmptyBorder(0,0,10,0));
framesPerSecond2.setMajorTickSpacing(5);
framesPerSecond2.setMinorTickSpacing(1);
framesPerSecond2.setPaintTicks(true);
framesPerSecond2.setPaintLabels(true);
framesPerSecond2.setBorder(
BorderFactory.createEmptyBorder(0,0,10,0));
framesPerSecond3.setMajorTickSpacing(2);
framesPerSecond3.setMinorTickSpacing(1);
framesPerSecond3.setPaintTicks(true);
framesPerSecond3.setPaintLabels(true);
framesPerSecond3.setBorder(
BorderFactory.createEmptyBorder(0,0,10,0));
//JPanel contentPane = new JPanel();
//Create the label for the animation.
//picture = new JLabel(new ImageIcon("images/doggy/T"
//+ frameNumber
//+ ".gif"),
// JLabel.CENTER);
Container contentPane = getContentPane();
contentPane.setLayout(new GridLayout(4,4));
contentPane.add(date_panel);
contentPane.add(year_panel);
contentPane.add(day_panel);
contentPane.add(month_panel);
}
public static void main(String args[]) {
Grid gw = new Grid();
gw.setTitle("Date Slider");
gw.setSize(400,200);
gw.setVisible(true);
}
}

