Question:
edit the unreadable send it back to me... let me see how u do it...?
mark79_24
2006-07-28 00:20:49 UTC
import java.awt.Color;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

/*
* Created on 2003/12/02
*
* To change the template for this generated file go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/

/**
* @author ljdina
*
* To change the template for this generated type comment go to
* Window>Preferences>Java>Code Generation>Code and Comments
*/

class CalendarPanel extends JPanel { //calendar‚ð•\Ž¦‚·‚éƒpƒlƒ‹
int firstday;
int lastday;
JPanel panel1;
JPanel panel2;
JLabel thismonth;
JLabel thisyear;
JTable calendartable;
JTable daystable;
JLabel weekdays[] = new JLabel[7];
JLabel[][] tabledata;
int length = 5;
String days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };

public final int DaysInMonth[] =
{ 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };


CalendarPanel(int month, int year) {
super();
thismonth = new JLabel(Integer.toString(month) + "ŒŽ");
thisyear = new JLabel(Integer.toString(year) + "”N");
Font monthfont = new Font("MS P–¾’©", Font.BOLD, 18);
thismonth.setFont(monthfont);
thismonth.setForeground(Color....
thisyear.setFont(monthfont);
thisyear.setForeground(Color.b...
panel2 = new JPanel();
panel2.setSize(238, 180);
FirstDay(month, year);
LastDay(month, year);

if (firstday == 6 && lastday == 0) length = 6;
if(DaysInMonth[month-1]==31 && firstday == 5 && lastday == 0)length = 6;
tabledata = new JLabel[length][7];
panel2.setLayout(new GridLayout(length,7));
PutInData(month,year,length);

panel1 = new JPanel();
panel1.setSize(238, 30);
panel1.setBackground(Color.gra...
panel1.setLayout(new GridLayout(1, 7));
for (int i = 0; i < 7; i++) {
weekdays[i] = new JLabel(days[i]);
weekdays[i].setSize(34, 30);
weekdays[i].setBackground(Colo...
weekdays[i].setBorder(BorderFa...
weekdays[i].setFont(monthfont)...
panel1.add(weekdays[i]);
}


setSize(280, 260);
setLayout(null);
thismonth.setSize(70, 26);
thismonth.setLocation(145, 10);
thisyear.setSize(80, 26);
thisyear.setLocation(45, 10);
add(thisyear);
add(thismonth);

panel1.setLocation(20, 40);
add(panel1);


panel2.setLocation(20, 70);
panel2.setBackground(Color.gra...
add(panel2);
setBackground(Color.gray);

}

public void FirstDay(int month, int year) {

firstday =
(year
+ year / 4
- year / 100
+ year / 400
+ (13 * month + 8) / 5
+ 1)
% 7;

}
public void LastDay(int month, int year) {
lastday =
(year
+ year / 4
- year / 100
+ year / 400
+ (13 * month + 8) / 5
+ DaysInMonth[month
- 1])
% 7;
}
public void PutInData(int month, int year,int length) {
if (month == 2 && isLeapYear(year))
DaysInMonth[1] = 29;
for (int i = 0; i < length; i++) {
for (int j = 0; j < 7; j++) {
tabledata[i][j] = new JLabel();
tabledata[i][j].setSize(34, 30);
tabledata[i][j].setBorder(Bord...
if (i == 0) {
if (j < (firstday))
tabledata[i][j].setText("");
else{
tabledata[i][j].setText(Intege... - firstday) + 1));

}
} else if (i == length) {
if(j <= lastday)tabledata[i][j].setTex... * 7) - firstday +1+ j));
else tabledata[i][j].setText("");
} else {
if (((i * 7) - firstday+1 + j) > DaysInMonth[month - 1]) {
tabledata[i][j].setText("");
} else {
tabledata[i][j].setText(Intege... * 7) - firstday +1+ j));

}
}
if(j==0)tabledata[i][j].setFor...
if(j==6)tabledata[i][j].setFor...

tabledata[i][j].setHorizontalA...
panel2.add(tabledata[i][j]);

}
}
}
public boolean isLeapYear(int year) {
return (year % 4 == 0 && year % 100 != 0 || year % 400 == 0);
}
}

public class CalendarFrame extends JFrame implements ActionListener {

JLabel yearlabel;
JTextField useryear;
JLabel monthlabel;
JComboBox monthlist;
JButton userCalendar;
JButton lastmonth;
JButton nextmonth;
JButton lastyear;
JButton nextyear;
JButton recover;

public CalendarFrame(CalendarPanel panel) {
super();
yearlabel = new JLabel("”N");
useryear = new JTextField();
monthlabel = new JLabel("ŒŽ");
String monthitem;
monthlist = new JComboBox();
for (int i = 0; i < 12; i++) {
monthitem = Integer.toString(i + 1);
monthlist.addItem(monthitem);
}
userCalendar = new JButton("");

lastmonth = new JButton("æŒŽ");
nextmonth = new JButton("—ˆŒŽ");
lastyear = new JButton("‹Ž”N");
nextyear = new JButton("—ˆ”N");
recover = new JButton("–ß‚é");

yearlabel.setHorizontalAlignme...
monthlabel.setHorizontalAlignm...
userCalendar.setHorizontalAlig...
userCalendar.setVerticalAlignm...
lastmonth.setHorizontalAlignme...
lastmonth.setVerticalAlignment...
nextmonth.setHorizontalAlignme...
nextmonth.setVerticalAlignment...
lastyear.setHorizontalAlignmen...
lastyear.setVerticalAlignment(...
nextyear.setHorizontalAlignmen...
nextyear.setVerticalAlignment(...
recover.setHorizontalAlignment...
recover.setVerticalAlignment(S...

getContentPane().setLayout(nul... //ƒŒƒCƒAƒEƒgƒ}ƒl[ƒWƒƒ‚ðŽg—p‚µ...
setSize(400, 400);
setLocation(200, 200);
setResizable(false);
getContentPane().setBackground...
setDefaultCloseOperation(EXIT_...

yearlabel.setSize(50, 26);
yearlabel.setLocation(10, 10);
useryear.setSize(80, 26);
useryear.setLocation(62, 10);
monthlabel.setSize(50, 26);
monthlabel.setLocation(150, 10);
monthlist.setSize(50, 26);
monthlist.setLocation(202, 10);
userCalendar.setSize(80, 26);
userCalendar.setLocation(300, 10);
panel.setLocation(50, 65);

getContentPane().add(yearlabel...
getContentPane().add(useryear)...
getContentPane().add(monthlabe...
getContentPane().add(monthlist...
getContentPane().add(userCalen...
getContentPane().add(panel);

userCalendar.addActionListener...

lastmonth.setSize(65, 26);
lastmonth.setLocation(20, 330);
nextmonth.setSize(65, 26);
nextmonth.setLocation(90, 330);
lastyear.setSize(65, 26);
lastyear.setLocation(160, 330);
nextyear.setSize(65, 26);
nextyear.setLocation(230, 330);
recover.setSize(65, 26);
recover.setLocation(300, 330);

getContentPane().add(lastmonth...
getContentPane().add(nextmonth...
getContentPane().add(lastyear)...
getContentPane().add(nextyear)...
getContentPane().add(recover);

lastmonth.addActionListener(th...
nextmonth.addActionListener(th...
lastyear.addActionListener(thi...
nextyear.addActionListener(thi...
recover.addActionListener(this...

if(panel.thismonth.getText().e...
JOptionPane.showMessageDialog(
this,
"9ŒŽ24“ú‰F’Ö؈©‚Ì’a¶“ú‚Å‚·‚æ...
"Œxƒ_ƒCƒAƒƒO",
JOptionPane.WARNING_MESSAGE);
}
}

public static void main(String[] args) { //ƒƒCƒ“ƒƒ\ƒbƒh
Calendar todaydate = Calendar.getInstance();
int month = todaydate.get(Calendar.MONTH) + 1;
int year = todaydate.get(Calendar.YEAR);
CalendarPanel todaypanel = new CalendarPanel(month, year);
CalendarFrame frame = new CalendarFrame(todaypanel);
frame.setVisible(true);
}

public void actionPerformed(ActionEvent e) {
if (e.getSource().equals(userCale... {
if (useryear.getText() != null
&& useryear.getText().length() != 0) {
int year = Integer.parseInt(useryear.getT...
int month =
Integer.parseInt((String) monthlist.getSelectedItem());
calendarDisplay(month, year);
} else {
JOptionPane.showMessageDialog(
this,
"”N‚Ì’l‚ð“ü—Í‚µ‚ĉº‚³‚¢B",
"Œxƒ_ƒCƒAƒƒO",
JOptionPane.WARNING_MESSAGE);
}
} else if (e.getSource().equals(lastmont... {
Calendar date = Calendar.getInstance();
int month = date.get(Calendar.MONTH) + 1;
int year = date.get(Calendar.YEAR);
if (month == 1) {
month = 12;
year = year - 1;
} else
month = month - 1;
calendarDisplay(month, year);
} else if (e.getSource().equals(nextmont... {
Calendar date = Calendar.getInstance();
int month = date.get(Calendar.MONTH) + 1;
int year = date.get(Calendar.YEAR);
if (month == 12) {
month = 1;
year = year + 1;
} else
month = month + 1;
calendarDisplay(month, year);
} else if (e.getSource().equals(lastyear... {
Calendar date = Calendar.getInstance();
int month = date.get(Calendar.MONTH) + 1;
int year = date.get(Calendar.YEAR) - 1;
calendarDisplay(month, year);
} else if (e.getSource().equals(nextyear... {
Calendar date = Calendar.getInstance();
int month = date.get(Calendar.MONTH) + 1;
int year = date.get(Calendar.YEAR) + 1;
calendarDisplay(month, year);
} else if (e.getSource().equals(recover)... {
Calendar date = Calendar.getInstance();
int month = date.get(Calendar.MONTH) + 1;
int year = date.get(Calendar.YEAR);
calendarDisplay(month, year);
}
}

public void calendarDisplay(int month, int year) {

CalendarPanel newpanel = new CalendarPanel(month, year);
CalendarFrame frame = new CalendarFrame(newpanel);

dispose();
frame.useryear.setText(Integer...
frame.monthlist.setSelectedIte...
frame.setVisible(true);

}

}
Three answers:
Alex B.
2006-07-28 00:25:13 UTC
Dunno....Beginner in C++. i don't make it in school so i'm trying to learn it myself...i'm onlly 14 :)
Aaron
2006-07-28 07:23:05 UTC
NO ONE WILL

THAT IS TOO LONG
2006-07-28 07:27:52 UTC
i think your gay


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...