Urgent!Please help me!

Hey!

i wanna creat a border around year_panel.i have the lines of code(in my programe) for creating the border but they are not working properly.

If somebody could also tell me how to put month names (Jan to Dec)on the month_panel(the third panel in my programe),Even for this one i wrote in the code in my programe but somehow it is not functioning properly.

Please have a look at booth of them

thnks!

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

import java.util.*;

import java.text.SimpleDateFormat;

//import javax.swing.border.CompoundBorder;

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

year_panel.setBorder(BorderFactory.createCompoundBorder(

BorderFactory.createTitledBorder(title),

BorderFactory.createEmptyBorder(5,5,5,5)));

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

date_panel.add(new JLabel(time));

day_panel.setLayout(new BorderLayout());

day_panel.add(framesPerSecond);

year_panel.setLayout(new BorderLayout());

year_panel.add(framesPerSecond2);

month_panel.setLayout(new BorderLayout());

// month_panel.add(framesPerSecond3);

// JSlider framesPerSecond = new JSlider(JSlider.HORIZONTAL,

// 0, 31, FPS_INIT);

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

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

}

}

[3670 byte] By [shahzad5] at [2007-9-26 1:24:21]
# 1
Okay, so you showed us a line of code that is "not functioning properly" and about 200 others. Now tell us in what way is it malfunctioning?(By the way, this is actually not urgent at all.)
DrClap at 2007-6-29 1:04:20 > top of Java-index,Archived Forums,Java Programming...
# 2

Boy don't you hate it when people try to be jerks

on these forums--these forums generaly being the only place on the web people aren't jerks.

Anyway,

I too sometimes have these kind if GUI problems and am convinced it has to do with order of statements.

try working with one component at a time or a really nice way to do it is:

private JPanel createYear_Panel() {

JPanel year_panel = new JPanel

//the rest

}

contentPane.add(createYear_Panel());

this way you kind of encapsulate the panel creation proccess

you can of course add other createPanel()

statements within eace one like:

year_panel.add(createAnotherPanel());

anyway I hope this helps.

garyjones32 at 2007-6-29 1:04:20 > top of Java-index,Archived Forums,Java Programming...
# 3
Drclap!Don't be a fucking pain in ass.I am just too busy to answer a piece of shit like u so next time don't bother replying my questions.......understand.
shahzad5 at 2007-6-29 1:04:20 > top of Java-index,Archived Forums,Java Programming...