Need Help Need Help PLZ PLZ

my problem is that i have made a calendar by using jtable and i can't highlight or put any sign to keep track on date, but the biggest problem is that i have to submit this project after two days, so i will appreciate any help or tips from you. Here is my code:

CODE

/*Contents of CalendarProgran.class */

//Import packages

import javax.swing.*;

import javax.swing.event.*;

import javax.swing.table.*;

import java.awt.*;

import java.awt.event.*;

import java.util.*;

public class CalendarProgram{

static JLabel lblMonth, lblYear;

static JButton btnPrev, btnNext;

static JTable tblCalendar;

static JComboBox cmbYear;

static JFrame frmMain;

static Container pane;

static DefaultTableModel mtblCalendar; //Table model

static JScrollPane stblCalendar; //The scrollpane

static JPanel pnlCalendar;

static int realYear, realMonth, currentYear, currentMonth;

public static void main (String args[]){

//Look and feel

try {UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());}

catch (ClassNotFoundException e) {}

catch (InstantiationException e) {}

catch (IllegalAccessException e) {}

catch (UnsupportedLookAndFeelException e) {}

//Prepare frame

frmMain = new JFrame ("Gestionnaire de clients"); //Create frame

frmMain.setSize(330, 375); //Set size to 400x400 pixels

pane = frmMain.getContentPane(); //Get content pane

pane.setLayout(null); //Apply null layout

frmMain.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //Close when X is clicked

//Create controls

lblMonth = new JLabel ("January");

lblYear = new JLabel ("Change year:");

cmbYear = new JComboBox();

btnPrev = new JButton ("<<");

btnNext = new JButton (">>");

mtblCalendar = new DefaultTableModel(){public boolean isCellEditable(int rowIndex, int mColIndex){return false;}};

tblCalendar = new JTable(mtblCalendar);

stblCalendar = new JScrollPane(tblCalendar);

pnlCalendar = new JPanel(null);

//Set border

pnlCalendar.setBorder(BorderFactory.createTitledBorder("Calendar"));

//Register action listeners

btnPrev.addActionListener(new btnPrev_Action());

btnNext.addActionListener(new btnNext_Action());

cmbYear.addActionListener(new cmbYear_Action());

//Add controls to pane

pane.add(pnlCalendar);

pnlCalendar.add(lblMonth);

pnlCalendar.add(lblYear);

pnlCalendar.add(cmbYear);

pnlCalendar.add(btnPrev);

pnlCalendar.add(btnNext);

pnlCalendar.add(stblCalendar);

//Set bounds

pnlCalendar.setBounds(0, 0, 320, 335);

lblMonth.setBounds(160-lblMonth.getPreferredSize().width/2, 25, 100, 25);

lblYear.setBounds(10, 305, 80, 20);

cmbYear.setBounds(230, 305, 80, 20);

btnPrev.setBounds(10, 25, 50, 25);

btnNext.setBounds(260, 25, 50, 25);

stblCalendar.setBounds(10, 50, 300, 250);

//Make frame visible

frmMain.setResizable(false);

frmMain.setVisible(true);

//Get real month/year

GregorianCalendar cal = new GregorianCalendar(); //Create calendar

realMonth = cal.get(GregorianCalendar.MONTH); //Get month

realYear = cal.get(GregorianCalendar.YEAR); //Get year

currentMonth = realMonth; //Match month and year

currentYear = realYear;

//Add headers

String[] headers = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"}; //All headers

for (int i=0; i<7; i++){

mtblCalendar.addColumn(headers);

}

tblCalendar.getParent().setBackground(tblCalendar.getBackground()); //Set background

//No resize/reorder

tblCalendar.getTableHeader().setResizingAllowed(false);

tblCalendar.getTableHeader().setReorderingAllowed(false);

//Single cell selection

tblCalendar.setColumnSelectionAllowed(true);

tblCalendar.setRowSelectionAllowed(true);

tblCalendar.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

//Set row/column count

tblCalendar.setRowHeight(38);

mtblCalendar.setColumnCount(7);

mtblCalendar.setRowCount(6);

//Populate table

for (int i=realYear-100; i<=realYear+100; i++){

cmbYear.addItem(String.valueOf(i));

}

//Refresh calendar

refreshCalendar (realMonth, realYear); //Refresh calendar

}

public static void refreshCalendar(int month, int year){

//Variables

String[] months = {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};

int nod, som; //Number Of Days, Start Of Month

//Allow/disallow buttons

btnPrev.setEnabled(true);

btnNext.setEnabled(true);

if (month == 0 && year <= realYear-10){btnPrev.setEnabled(false);} //Too early

if (month == 11 && year >= realYear+100){btnNext.setEnabled(false);} //Too late

lblMonth.setText(months[month]); //Refresh the month label (at the top)

lblMonth.setBounds(160-lblMonth.getPreferredSize().width/2, 25, 180, 25); //Re-align label with calendar

cmbYear.setSelectedItem(String.valueOf(year)); //Select the correct year in the combo box

//Clear table

for (int i=0; i<6; i++){

for (int j=0; j<7; j++){

mtblCalendar.setValueAt(null, i, j);

}

}

//Get first day of month and number of days

GregorianCalendar cal = new GregorianCalendar(year, month, 1);

nod = cal.getActualMaximum(GregorianCalendar.DAY_OF_MONTH);

som = cal.get(GregorianCalendar.DAY_OF_WEEK);

//Draw calendar

for (int i=1; i<=nod; i++){

int row = new Integer((i+som-2)/7);

int column = (i+som-2)%7;

mtblCalendar.setValueAt(i, row, column);

}

//Apply renderers

tblCalendar.setDefaultRenderer(tblCalendar.getColumnClass(0), new tblCalendarRenderer());

}

static class tblCalendarRenderer extends DefaultTableCellRenderer{

public Component getTableCellRendererComponent (JTable table, Object value, boolean selected, boolean focused, int row, int column){

if (column == 0 || column == 6){

setBackground(new Color(255, 220, 220));

}

else{

setBackground(new Color(255, 255, 255));

}

super.getTableCellRendererComponent(table, value, selected, focused, row, column);

return this;

}

}

static class btnPrev_Action implements ActionListener{

public void actionPerformed (ActionEvent e){

if (currentMonth == 0){ //Back one year

currentMonth = 11;

currentYear -= 1;

}

else{ //Back one month

currentMonth -= 1;

}

refreshCalendar(currentMonth, currentYear);

}

}

static class btnNext_Action implements ActionListener{

public void actionPerformed (ActionEvent e){

if (currentMonth == 11){ //Foward one year

currentMonth = 0;

currentYear += 1;

}

else{ //Foward one month

currentMonth += 1;

}

refreshCalendar(currentMonth, currentYear);

}

}

static class cmbYear_Action implements ActionListener{

public void actionPerformed (ActionEvent e){

if (cmbYear.getSelectedItem() != null){

String b = cmbYear.getSelectedItem().toString();

currentYear = Integer.parseInt(b);

refreshCalendar(currentMonth, currentYear);

}

}

}

}

[7537 byte] By [TheKingOfCodesa] at [2007-11-27 9:59:03]
# 1

Your subject line is very annoying and conveys zero information.

You provided too much code and not enough detail about the problem.

Your code is not between [code] and [/code] tags and is unreadable.

You tried to foist your urgency off on those who would help you.

For those reasons, I won't even consider your problem. Maybe somebody else will. Good luck.

jverda at 2007-7-13 0:29:57 > top of Java-index,Java Essentials,Java Programming...
# 2

Welcome to the forum. You will need to learn a couple things if you want to receive help and not get flamed to death:

1) All code needs to be posted within code tags. You can read up on them here:

http://forum.java.sun.com/help.jspa?sec=formatting

You want to make it as easy as possible for the volunteers here to help you. That means making your code readable.

2) Do not put "urgent" "need help" "hurry please" in your posts if you are smart. Definitely don't put them in the header of the post. The urgency is yours, not ours. Putting that stuff in there only turns people off. If you have a problem deemed worthwhile by the volunteers here, if you have put thought into your post so you make it easy as possible for others to help you, and if you show some effort on your own, you are almost guaranteed to get timely help.

3) List all error messages completely.

4) Keep all necessary code, get rid of all unnecessary code. Your code should be compilable on its own, but it should not contain anything that isn't necessary for demonstrating your problem.

5) Specifics:

Why are you throwing out all those exceptions?

Why is everything in one big huge GUI class? Break your code down into functional units. Make sure the logic works in a non-GUI way, THEN add a GUI class.

Why the huge main method? The main should be short and sweet.

Why the static inner classes? Do you know what is the difference between static inner classes and non-static inner classes?

Why all the static variables anyway? You are doing procedural programming with an OOP language. You should use OOP if you can with an OOP language.

Sorry, but this code looks like it was thrown together in a big hurry. I think that you have a lot of work to do. Good luck!

petes1234a at 2007-7-13 0:29:57 > top of Java-index,Java Essentials,Java Programming...
# 3
C'mon guys, you forgot the most important suggestion of all, "Swing related questions should be posted in the Swing forum" :)
camickra at 2007-7-13 0:29:57 > top of Java-index,Java Essentials,Java Programming...
# 4
> C'mon guys, you forgot the most important suggestion> of all, "Swing related questions should be posted in> the Swing forum" :)Hm,.... you sure you want this program over there?
petes1234a at 2007-7-13 0:29:57 > top of Java-index,Java Essentials,Java Programming...
# 5
> Hm,.... you sure you want this program over there? Not this program, but a well worded question with a valid SSCCE might get some attention.
camickra at 2007-7-13 0:29:57 > top of Java-index,Java Essentials,Java Programming...
# 6
> C'mon guys, you forgot the most important suggestion> of all, "Swing related questions should be posted in> the Swing forum" :)you forgot that code not between code tags isn't being read :)
jwentinga at 2007-7-13 0:29:57 > top of Java-index,Java Essentials,Java Programming...