HOW TO ADD MORE THAN ONE SLIDER IN A GRID?

hey!

i wanna include three Jslider in the grid .After i created the second one(the one i included in year_panel)and tried to run the programe,i got a run time error.i tried but could not fix it.

could sombody please help me.

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

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_INIT);

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());

//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));

//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(1,4));

contentPane.add(date_panel);

contentPane.add(year_panel);

//contentPane.add(framesPerSecond);

contentPane.add(day_panel);

//contentPane.add(month_panel);

//contentPane.add(day_panel);

}

public static void main(String args[]) {

Grid gw = new Grid();

gw.setTitle("Date Slider");

gw.setSize(400,200);

gw.setVisible(true);

}

}

[3065 byte] By [shahzad5] at [2007-9-26 1:19:29]
# 1
Your problem is with the line:JSlider framesPerSecond2 = new JSlider(JSlider.HORIZONTAL, 1990, 2010, FPS_INIT);FPS_INIT is the value 15, which isn't between the min(1990) and max(2010).
ghempseed at 2007-6-29 0:52:02 > top of Java-index,Archived Forums,Java Programming...