Done with a calendar marking
Abstract: A marker used to do calendar
</ Td> </ tr> <tr> <td width="531" height="35" valign="top" class="ArticleTeitle"> This is what I learn from a 1.0 jDlog practice. Dlog.tld look at the document:
<? Xml version = "1.0" encoding = "GB2312?">
Taglib PUBLIC "- / / Sun Microsystems, Inc / / DTD JSP Tag Library 1.1 / / EN"
"Http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd">
<bodycontent> Empty </ body>
CalendarTag.java again, and from the property, or request access to parameters
/ *
* Created on 2004-2-6
* /
Package jdlog.tags;
Import java.text.SimpleDateFormat;
Import java.util.Calendar;
Import java.util.Locale;
Import javax.servlet.http.HttpServletRequest;
Import javax.servlet.jsp .*;
Import javax.servlet.jsp.tagext .*;
/ **
* @ Author Liudong
* Tag library calendar
* /
Public class CalendarTag extends TagSupport (
Protected int year = 2005;
Protected int month = 2;
Private final static SimpleDateFormat sdf =
New SimpleDateFormat ( "MMMMM yyyy" Locale.ENGLISH);
Public int doStartTag () (throws JspException
Calendar cal = Calendar.getInstance ();
PageContext.getOut JspWriter out = ();
Try (
If (pageContext.getRequest (). GetParameter ( "paramYear")! = Null) (
Year = Integer.parseInt (pageContext.getRequest (). GetParameter ( "paramYear"));)
If (year> 0)
Cal.set (Calendar.YEAR, year);
) Catch (Exception e) (System.out.println (e.toString ());}
Try (
If (pageContext.getRequest (). GetParameter ( "paramMonth")! = Null) (
Month =
Integer.parseInt (pageContext.getRequest (). GetParameter ( "paramMonth"));)
If (month> 0 & & month <13)
Cal.set (Calendar.MONTH, month-1);
Else if (month == 0) (
Cal.set (Calendar.MONTH, 11);
Cal.add (Calendar.YEAR, -1);
)
Else if (month == 13) (
Cal.set (Calendar.MONTH, 0);
Cal.add (Calendar.YEAR, 1);
)
) Catch (Exception e) ()
Int [] [] = buildCalendar datas (cal);
Try (
Out.print ( "<table border = Ɔ 'width =% Sou' align = 'center' cellspacing = Ƈ '
Cellpadding = Ƈ '> <tr> <td colspan=ƍ'> "+ year +" "+ month +" on </ td> </ tr> <tr> <td
Class = 'week'> Su </ td> <td class='week'> M </ td> <td class='week'> Tu </ td>
<td Class='week'> W </ td> <td
↑ Back Abstract: jsp Calendar </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> one can choose the month and year to view the calendar. </ Td> </ tr> <tr>
↑ Back Abstract: A calendar program </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> </ Td> <td width="355"> </ td> </ tr> </ table> ↑ Back Abstract: CALENDAR procedures </ Td> </ tr> <tr> <td height="35" valign="top" class="ArticleTeitle"> <table width = "100%" border = "0" cellspacing = "0" cellpadding = " 0 "> <tr> <td width="258" height="86" align="center" valign="top"> </ td> <td width="462" valign="top">
Diagram is as follows: / ** * * Summary Clock.java digital time display Created on 2005-8-14 * * * @ author high Queensland remark if changes please give me a code, the e-mail gkgklovelove@eyou.com * / package Clock; import javax.swing .*; import java.awt .*; import java.awt.event .*; import java.text .*; import java.util .*;
</ Td> </ tr> <tr> <td height="432" colspan="2">
Class Clock extends Canvas implements Runnable (MainFrame mf; Thread t; String time; Clock (MainFrame mf) (this.mf = mf; setSize (400,40); setBackground (Color.white); t = new Thread (this); / / examples of thread t.start ();// call threads) public void run () (while (true) (try (t.sleep (1000) / / 1 second dormancy) catch (InterruptedException e) (System.out.println ( "abnormal");) this.repaint (100);)) public void paint (Graphics g) (Font f = new Font ( "10 lines," Font.BOLD, 16); </ Td> </ tr> </ table>
/ ** * * Summary MainFrame.java calendar main categories Created on 2005-8-14 * * * @ author high Queensland remark if changes please give me a code, the e-mail gkgklovelove@eyou.com * / package Clock; import javax.swing .*; import java.awt .*; import java.awt.event .*; import java.text .*; import java.util .*; class MainFrame extends JFrame (JPanel panel = new JPanel (new BorderLayout ( )); JPanel panel1 = new JPanel (); JPanel panel2 = new JPanel (new GridLayout (7,7)); JPanel panel3 = new JPanel (); JLabel [] = new JLabel label [49]; JLabel y_label = new JLabel ( "Year"); JLabel m_label = new JLabel ( "in"); JComboBox com1 = new JComboBox (); JComboBox com2 = new JComboBox (); JButton button = new JButton ( "View"); int re_year, re_month; int x_size, y_size; String year_num; Calendar now = Calendar.getInstance ();// examples of Calendar MainFrame () (super ( "calendar"); setSize (300,350); x_size = (int) (Toolkit.getDefaultToolkit (). getScreenSize (). getWidth ()); y_size = (int) (Toolkit.getDefaultToolkit (). getScreenSize (). getHeight ()); setLocation ((x_size-300) / 2, (y_size-350) / 2); setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE); panel1.add (y_label); panel1.add (com1); panel1.add (m_label); panel1.add (com2); panel1.add (button); for (int i = 0; i <49 ; i + +) (label [i] = new JLabel ( "", JLabel.CENTER) / / set of characters will be displayed for the middle panel2.add (label [i]);) panel3.add (new Clock (this)) ; panel.add (panel1, BorderLayout.NORTH); panel.add (panel2, BorderLayout.CENTER); panel.add (panel3, BorderLayout.SOUTH); panel.setBackground (Color.white); panel1.setBackground (Color.white ); panel2.setBackground (Color.white); panel3.setBackground (Color.white); Init (); button.addActionListener (new ActionListener () (public void actionPerformed (ActionEvent e) (int c_year, c_month, c_week; c_year = Integer.parseInt (com1.getSelectedItem (). toString ());// selected by the current year c_month = Integer.parseInt (com2.getSelectedItem (). toString ()) -1; c_week = use (c_year, c_month); / / use function calls by several weeks Resetday (c_week, c_year, c_month) / / call functions Resetday))); setContentPane (panel); setVisible (true); setResizable (false);) public void Init () (int year, month_num, first_day_num; String log []={", "and" 1 "," two "and" three "and" four "and" five "," six "); for (int i = 0; i < 7; i + +) (label [i]. setText (log [i]);) for (int i = 0; i <49; i = i +7) (label [i]. setForeground (Color.red); / / Sunday, the date will be set to red) for (int i = 6; i <49; i = i +7) (label [i]. setForeground (Color.green); / / Saturday, the date will be set to green) for (int i = 1; i <10000; i + +) (com1.addItem ( "" + i);) for (int i = 1; i <13; i + +) (com2.addItem ( "" + i);) month_num = (int) (now.get (Calendar.MONTH ));// get the current time in the year = (int) (now.get (Calendar.YEAR ));// by the time the current year com1.setSelectedIndex ( year-1) / / set the drop-down list shows that for the current year com2.setSelectedIndex (month_num) / / set up for the drop-down list shows that the current use of first_day_num = (year, month_num); Resetday (first_day_num, year, month_num );) public int use (int reyear, int remonth) (int week_num; now.set (reyear, remonth, 1) / / set-up time for the years to be on the first day of week_num = (int) (now.get (Calendar.DAY_OF_WEEK ));// be the first day of the week return week_num;) public void Resetday (int week_log, int year_log, int month_log) (int month_score_log; / / determine whether the mark is a leap year int month_day_score; / / storage month int count the number of days; month_score_log = 0; month_day_score = 0; count = 1; if (year_log% 4 == 0 & & year_log% 100! = 0 | | 400% year_log == 0) (/ / determine whether the leap year month_score_log = 1; month_log month_log = +1) / / will be sent in a few plus 1 switch (month_log) (case 1: case 3: case 5: case 7: case 8: case 10: case 12: month_day_score = 31; break; case 4: case 6: case 9: case 11: month_day_score = 30; break; case 2: if (month_score_log == 1) (month_day_score = 29;) else (month_day_score = 28;) break;) for (int i = 7; i <49; i ++){// initialization label label [i]. setText ("");) = week_log week_log +6; / / will be a few weeks and 6, to show that the correct month_day_score + = month_day_score week_log; for ( int i = week_log; i <month_day_score; i + +, count + +) (label [i]. setText (count +"");)) public static void main (String [] args) (JFrame.setDefaultLookAndFeelDecorated (true); MainFrame start = new MainFrame ();))
</ Td> </ tr> <tr>
↑ Back Abstract: recursive directory times calendar Content: This is my own calendar times to write a directory of categories, the use of the recursive method, if we who need to use it on lightly! Import java.io. *; (Public class ListDirectory Public static int listDir (String dir, ArrayList listFile) throws IOException ( Abstract: A Calendar of upcoming NetBeans events 16th Jan, 2007, Atlanta, GA, USA Venue: Cobb Galleria Centre, Java Developer Conference 20th Jan, 2007, Cairo, Egypt Sun technology evangelists Roman Strobl and Chuck Man Lee will speak about the newest and coolest features of NetBeans IDE 5.5 and Java SE 6 in Cairo on Jan 20. This event is the first conference organized by community of Java developers in Egypt. For more information visit the event site: http://www.egjug.org/java_developer_conference
The Open University: Teaching Java Through NetBeans! 1st Feb, 2007 - 31st Oct, 2007, Europe "You will apply and extend your understanding of object-orientated technology and of Java, and will implement code using NetBeans, a widely used integrated development environment from Sun Microsystems, "states the description of the Open University's" Software Development with Java "course, which runs from February 2007 to October 2007. Read all about the course and please let us know if you hear about other courses (anywhere in the world ) that make use of NetBeans. Thanks Troy Giunipero, from Prague, for letting us know about this one!
NetBeans Day - Hyderabad 23rd Feb, 2007, Hyderabad, India Venue: Hyderabad International Convention Centre NetBeans Day - Kuala Lumpur 6th Mar, 2007, Kuala Lumpur, Malaysia Venue: Kuala Lumpur Convention Centre in Level 3 - Ballroom 1, NetBeans Day - London 13th Mar, 2007, London, UK Venue: Central Hall Westminster, NetBeans Day - Paris 19th Mar, 2007, Paris, France
Venue: Espace Grande Arche;
Detailed agenda, venue and contact info available.
Register now!
NetBeans Day - St. Petersburg 13th Apr, 2007, St Petersburg, Russia
Venue: LenExpo.
Agenda, venue and contact info available.
Register now!
NetBeans Day - Sao Paulo 18th Apr, 2007, Sao Paulo, Brazil
Venue: Expo Transam? Rica;
Agenda, venue and contact info available.
Register now!
NetBeans Day at the JavaOne Conference 7th May, 2007, San Francisco
Learn from the experts - Meet James Gosling, Jonathan Schwartz, Tor Norbye, Charles Oliver Nutter, and Rich Green.
NetBeans Day is a companion event to the JavaOne 2007 Conference which begins the following day. You do not need to be registered for JavaOne: NetBeans Day is free for anyone who wishes to attend.
Register now!
NetBeans Day - Mexico City 18th May, 2007, Mexico City, Mexico Schedule and venue will be announced soon on this page.
Jazoon'07 24th Jul, 2007 - 28th Jul, 2007, Hallenstadion Zurich, Switzerland Jazoon, the international conference on Java technology, brings together experts and professional users of Java and open source technologies from all over Europe. Featuring a comprehensive range of topics, renowned speakers, a varied program of social and cultural events, parallel exhibition with integrated career platform and optimal logistics, Jazoon'07 provides young professionals and established specialists with a unique live experience. Abstract: The use of the doubts Calendar ↑ Back Abstract: ask a category on the Calendar when computing the problems ↑ Back Abstract: Why the current calendar month will be less a month? ? ↑ Back Abstract: a JSP to do with the calendar <! - File name: calendar.jsp -> <! - Show arbitrary, on the calendar, choose different year, month. Author: wildfield -> <% @ Page language = \ "java \" import = \ "java.util .* \"%> <%! String year; String month; %> <% Month = request.getParameter (\ "month \"); Year = request.getParameter (\ "year \"); %> <html> <head> <meta Http-equiv=\"Content-Type\" content=\"text/html; charset=gb2312\"> <title>, </ Title> <script Language=\"JavaScript\"> <! – Function changeMonth () ( Var mm = \ "calendar.jsp? Month = \" + document.sm.elements [0]. SelectedIndex + \ "& year = \" + <= Year%%>; Window.open (mm, \ "_self \"); ) //–></ Script> </ Head> <%! String days [];%> <% Days = new String [42]; For (int i = 0; i <42; i + +) ( Days = \ "\"; ) %> <% Calendar thisMonth = Calendar.getInstance (); If (month! = Null & & (! Month.equals (\ "null \"))) ThisMonth.set (Calendar.MONTH, Integer.parseInt (month)); If (year! = Null & & (! Year.equals (\ "null \"))) ThisMonth.set (Calendar.YEAR, Integer.parseInt (year)); Year = String.valueOf (thisMonth.get (Calendar.YEAR)); Month = String.valueOf (thisMonth.get (Calendar.MONTH)); ThisMonth.setFirstDayOfWeek (Calendar.SUNDAY); ThisMonth.set (Calendar.DAY_OF_MONTH, 1); Int firstIndex = thisMonth.get (Calendar.DAY_OF_WEEK) -1; Int maxIndex = thisMonth.getActualMaximum (Calendar.DAY_OF_MONTH); For (int i = 0; i <maxIndex; i + +) ( Days [firstIndex + i] = String.valueOf (i +1); ) %> <body> <FORM Name=\"sm\" method=\"post\" action=\"calendar.jsp\"> <=% Year%%>, <= Integer.parseInt (month) +1%>, <table Border=\"0\" width=\"168\" height=\"81\"> <div Align=center> <tr> <th Width=\"25\" height=\"16\" bgcolor=\"#FFFF00\"> <font color=\"red\">, </ font> </ Th> <th Width=\"25\" height=\"16\" bgcolor=\"#FFFF00\"> 1 </ th> <th Width=\"25\" height=\"16\" bgcolor=\"#FFFF00\"> 2 </ th> <th Width=\"25\" height=\"16\" bgcolor=\"#FFFF00\"> 3 </ th> <th Width=\"25\" height=\"16\" bgcolor=\"#FFFF00\"> 4 </ th> <th Width=\"25\" height=\"16\" bgcolor=\"#FFFF00\"> 5 </ th> <th Width=\"25\" height=\"16\" bgcolor=\"#FFFF00\"> <font color=\"green\"> 6 </ fon T> </ th> </ Tr> <% For (int j = 0; j <6; j + +) (%> <tr> <% For (int i = j * 7; i <(j +1) * 7; i + +) (%> <Td width = \ "15% \" height = \ "16 \" bgcolor = \ "# C0C0C0 \" valign = \ "middle \" align = \ "ce Nter \ "> <A href = \ "jump.jsp? Year = <= year%%> & month = <% = Integer.parseInt (month) +1%> & d Ate = <% = days [i]%> \ "target = \" main \ "><%= days [i ]%></ a> </ td> <%)%> </ Tr> <%)%> </ Div> </ Table> <table Border=\"0\" width=\"168\" height=\"20\"> <tr> <td Width=30%> <select name=\"month\" size=\"1\" onchange=\"changeMonth()\"> <option Value=\"0\"> January </ option> <option Value=\"1\"> February </ option> <option Value=\"2\"> March </ option> <option Value=\"3\"> April </ option> <option Value=\"4\"> May </ option> <option Value=\"5\"> June </ option> <option Value=\"6\"> July </ option> <option Value=\"7\"> August </ option> <option Value=\"8\"> September </ option> <option Value=\"9\"> October </ option> <option Value=\"10\"> November </ option> <option Value=\"11\"> December </ option> </ Select> </ td> <td Width=28%> <input type = text name = \ "year \" value = <= year%%> size maxlength = 4 = 4> </ td> <td>, </ Td> <td Width=28%> <input type=submit value=\"æäº¤\"> </ td> </ Tr> </ Table> </ FORM> <script Language=\"JavaScript\"> <! – Document.sm.month.options.selectedIndex = <month%% =>; //–> </ Script> </ Body> </ Html> ↑ Back
Class = 'week'> Th </ td> <td class='week'> F </ td> <td class='week'> Sa </ td> </ tr> ");
For (int i = 0; i
For (int j = 0; j
Out.print ( "</ tr>");
)
Out.print ( "</ table>");
)
Catch (Exception e) (
System.out.println ( "Error");
)
/ / PageContext.setAttribute (datasId, datas);
PageContext.setAttribute ( "year", new Integer (cal.get (Calendar.YEAR)));
PageContext.setAttribute (the "month", new Integer (cal.get (Calendar.MONTH) +1));
/ / PageContext.setAttribute (titleId, sdf.format (cal.getTime ()));
Return SKIP_BODY;
)
/ **
* Constructors calendar
* @ Param year
* @ Param month
* @ Return
* /
Protected static int [] [] buildCalendar (Calendar cal) (
Cal.set (Calendar.DAY_OF_MONTH, 1);
Int firstDateInWeek = cal.get (Calendar.DAY_OF_WEEK) -1;
Int dateOfMonth = getMonthDateCount (cal);
Int base + = dateOfMonth firstDateInWeek;
Int row = base / 7;
Row + = ((base% 7)> 0)? 1:0;
Int [] [] cals = new int [row] [7];
Int iCol = firstDateInWeek, iRow = 0;
For (int i = 1; i <= dateOfMonth; i + +) (
Cals [iCol iRow] [] = i;
If (iCol == 6) (
ICol = 0;
IRow + +;
)
Else
ICol + +;
)
Return cals;
)
/ **
* Designated by the number of days in
* @ Param cal
* @ Return
* /
Protected static int getMonthDateCount (Calendar cal) (
Calendar cal2 = (Calendar) cal.clone ();
Cal2.add (Calendar.MONTH, 1);
Cal2.set (Calendar.DAY_OF_MONTH, 1);
Cal2.add (Calendar.DAY_OF_MONTH, -1);
Return cal2.get (Calendar.DAY_OF_MONTH);
)
Public static void main (String [] args) throws Exception (
Int [] [] = buildCalendar days (Calendar.getInstance ());
For (int i = 0; i
System.out.println ();
)
)
/ **
* @ Return
* /
Public int getMonth () (
Return month;
)
Public int getYear () (
Return year;
)
Public void setMonth (int month) (
This.month = month;
)
Public void setYear (int year) (
This.year = year;
)
)
Third, call jsp
<% @ Page language = "java" contentType = "text / html; GBK charset ="%>
<% @ Taglib prefix = "c" uri = "http://java.sun.com/jstl/core"%>
<% @ Taglib uri = "/ WEB-INF/dlog.tld" prefix = "dlog"%>
<table> <tr> <td Width="200">
<%
Integer year = (Integer) pageContext.getAttribute ( "year");
Integer month = (Integer) pageContext.getAttribute (the "month");
Int nextYear = year.intValue ();
Int lastYear = year.intValue ();
Int next_m month.intValue = () +1;
If (next_m> 12) (
Next_m = 1;
NextYear + +;
)
Int last_m month.intValue = () -1;
If (last_m <1) (
Last_m = 12;
LastYear -;
)
%>
& ParamMonth = <= last_m%%>> on January
& ParamMonth = <= next_m%%>> Next Month
= & ParamMonth
<% = Month.intValue ()%>> last year
= & ParamMonth
<% = Month.intValue ()%>> next year
Function TempSave (ElementID) (CommentsPersistDiv.setAttribute ( "CommentContent" document.getElementById (ElementID). Value); CommentsPersistDiv.save ( "CommentXMLStore");) function Restore (ElementID) (CommentsPersistDiv.load ( "CommentXMLStore"); document . getElementById (ElementID). CommentsPersistDiv.getAttribute value = ( "CommentContent");) </ td> <td width="176" valign="top" class="ArticleTeitle">
</ Td> </ tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle">
Jsp Calendar
A calendar program
<table Width="678" border="0"> <tr> <td width="313"> process diagram:
Import javax.swing .*;
Import java.awt.event .*;
Import java.awt .*;
Import java.util.Calendar;
Import java.util.Date;
/ **
* Calendar categories, providing calendar
* /
Public class MonthSelector extends JPanel implements ActionListener, MouseMotionListener, MouseListener
(
Final private String TITLES [] = ( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
Final private int ROW_HEIGHT = 20;
Final private int ROW_WIDTH = 40;
Private JTable table; / / Form
Private JLabel title; / / Title
Private JButton nextMonth; / / button in the next month
Private JButton preMonth; / / last month button
Private JPanel top; / / top containers
Private int year; / / display the current year
Private int month; / / display the current month
Private int day; / / current choice of date
Private int week; / / currently selected week
Private int selectedX = -1;
Private int selectedY = -1;
Private int clickX = -1;
Private int clickY = -1;
Public MonthSelector () (
Calendar cal = Calendar.getInstance ();
Cal.setTime (new Date ());
Year = cal.get (Calendar.YEAR);
Month = cal.get (Calendar.MONTH) +1;
Day = cal.get (Calendar.DAY_OF_MONTH) -1;
Cal.get week = (Calendar.DAY_OF_WEEK) -1;
Top = new JPanel (new FlowLayout (FlowLayout.CENTER));
Table = new JTable (7,7);
Table.setPreferredSize (new Dimension (ROW_WIDTH * 7, ROW_HEIGHT * 7));
Table.setRowHeight (ROW_HEIGHT);
For (int i = 0; i
Title = new JLabel ();
NextMonth = new JButton (">>");
PreMonth = new JButton ("<<");
Top.add (preMonth);
Top.add (title);
Top.add (nextMonth);
SetTitle ();
Table.setEnabled (false);
/ / Set button
SetLayout (new BorderLayout ());
Add (top, BorderLayout.NORTH);
Add (table, BorderLayout.CENTER);
PreMonth.addActionListener (this);
NextMonth.addActionListener (this);
ShowMonth () / / set to display the current month
Table.setCellSelectionEnabled (true);
Table.addMouseMotionListener (this);
Table.addMouseListener (this);
)
/ **
* Designated the Year and the month of the date of
* @ Return
* /
Public int getDaysOfMonth (int year, int month)
(
Int Days 31,28,31,30,31,30,31,31,30,31,30,31 [] = ();
/ / Determine whether a leap year
If (year 400% == 0 | | (year% 4 == 0 & & 100% year! = 0)) / / this is a leap year
Days [1] = 29;
Return Days [month-1];
)
/ **
* Obtain a prescribed in the first day of the week
* @ Param month
* @ Return
* /
Public int getWeekOfFirstDay (int year, int month) (
Calendar cal = Calendar.getInstance ();
Cal.set (Calendar.YEAR, year);
Cal.set (Calendar.MONTH, month - 1);
Cal.set (Calendar.DAY_OF_MONTH, 1);
Int result = cal.get (Calendar.DAY_OF_WEEK) - 1;
Return result;
)
/ **
* Set up the title of show
* /
Private void setTitle () (
String m = String.valueOf (month);
If (m.length () == 1) m = "0" + m;
Title.setText (String.valueOf (year) + "" + m + "on");
)
/ **
* Show in
* /
Private void showMonth () (
For (int x = 0; x <7; x + +)
For (int y = 1; y <7; y + +) table.setValueAt ( "", y, x);
Int y = 1;
Int x = getWeekOfFirstDay (year, month);
Int maxDay = getDaysOfMonth (year, month);
For (int i = 0; i
X + +;
If (x> 6) (
X = 0;
Y + +;
)
)
Repaint ();
)
/ **
* Button
* @ Param e
* /
Public void actionPerformed (ActionEvent e) (
If (e.getSource (). Equals (nextMonth)) (
Month + +;
If (month> 12) (
Month = 1;
Year + +;
)
)
If (e.getSource (). Equals (preMonth)) (
Month -;
If (month <1) (
Month = 12;
Year -;
)
)
SetTitle ();
ShowMonth ();
)
/ **
* Rendering
* @ Param g
* /
Public void paint (Graphics g) (
Super.paint (g);
/ / Repaint Table First LINE
G.fillRect (0, top.getHeight (), getWidth () -1, ROW_HEIGHT -1);
G.setColor (Color.white);
For (int i = 0; i <7; i + +)
G.drawString ((String) (table.getModel (). GetValueAt (0, i)), i * ROW_WIDTH, top.getHeight () + ROW_HEIGHT - 3);
Calendar cal = Calendar.getInstance ();
Cal.set (Calendar.YEAR, year);
Cal.set (Calendar.MONTH, month);
Cal.set (Calendar.DAY_OF_MONTH, day);
Int line = cal.get (Calendar.DAY_OF_WEEK_IN_MONTH) + 1;
Int x = * table.getWidth week () / 7;
Int y = top.getHeight () + ROW_HEIGHT * line;
G.setColor (Color.black);
G.drawRect (x +1, y +1, ROW_WIDTH-4, ROW_HEIGHT-4);
If (selectedX> = 0 & & selectedY> = 0 & &! Table.getModel (). GetValueAt (selectedY, selectedX). Equals ("")){
G.setColor (Color.blue);
G.drawRect (selectedX * ROW_WIDTH +1 (selectedY + 2) * ROW_HEIGHT -1, ROW_WIDTH-4, ROW_HEIGHT-4);
)
If (clickY> = 0 & & clickX> = 0 &! Table.getModel (). GetValueAt (clickY, clickX). Equals (""))
(
G.setColor (Color.green);
G.drawRect (clickX * ROW_WIDTH +1 (clickY + 2) * ROW_HEIGHT -1, ROW_WIDTH-4, ROW_HEIGHT-4);
)
)
Public void mouseDragged (MouseEvent e) ()
Public void mouseMoved (MouseEvent e) (
If (e.getX ()> 0 & & e.getY ()
(
SelectedX = e.getX () / ROW_WIDTH;
SelectedY = e.getY () / ROW_HEIGHT;
Repaint ();
)
)
Public void mouseClicked (MouseEvent e) ()
Public void mousePressed (MouseEvent e) (
If (e.getX ()> 0 & & e.getY ()
(
ClickX = e.getX () / ROW_WIDTH;
ClickY = e.getY () / ROW_HEIGHT;
Repaint ();
)
)
Public void mouseReleased (MouseEvent e) ()
Public void mouseEntered (MouseEvent e) ()
Public void mouseExited (MouseEvent e) ()
/ * –= [Test code] =– * /
Public static void main (String [] args) (
JFrame frm = new JFrame ();
Frm.getContentPane (). SetLayout (new BorderLayout ());
Frm.getContentPane (). Add (new MonthSelector ());
Frm.pack ();
Frm.show ();
)
)
</ Td> </ tr> <tr>
CALENDAR procedures
SimpleDateFormat SDF = new SimpleDateFormat ( "yyyy ',' MM ',' dd ',' HH: mm: ss format ");// Calendar now time display type = Calendar.getInstance (); time = SDF.format (now . getTime ());// by the current date and time g.setFont (f); g.setColor (Color.orange); g.drawString (time, 100,25);)) Recursive directory times calendar
Import java.util .*;
Int result = 0;
File file = new File (dir);
File fileList [];
If (! File.isDirectory ()) (
Result = 1;
Else ()
FileList = file.listFiles ();
For (int i = 0; i
ListDir (fileList [i]. GetPath (), listFile);
Else ()
ListFile.add (fileList [i]. GetPath ());
)
)
)
Return result;
)
) Java, java, J2SE, j2se, J2EE, j2ee, J2ME, j2me, ejb, ejb3, JBOSS, jboss, spring, hibernate, jdo, struts, webwork, ajax, AJAX, mysql, MySQL, Oracle, Weblogic, Websphere, scjp , scjd This is me?
↑ Back A Calendar of upcoming NetBeans events
Agenda: agenda as PDF,
More info: Venue and contact information,
Register now, it's free!
Agenda & contact info
Register now! It's free!
Agenda: Detailed agenda,
Venue and contact info available.
Register now, it's free
Agenda and more information: tech day homepage,
Register now, it's free!
↑ Back The use of the doubts Calendar
I use the Sony Ericsson simulator running:
Calendar calendar = Calendar.getInstance (TimeZone.getTimeZone ( "GMT"));
Calendar calendar1 = Calendar.getInstance (TimeZone.getTimeZone ( "GMT +8:00"));
Calendar calendar2 = Calendar.getInstance (TimeZone.getDefault ());
System.out.println (calendar.getTime ());
System.out.println (calendar1.getTime ());
System.out.println (calendar2.getTime ());
The time:
Fri May 26 03:22:17 UTC 2006
Fri May 26 03:22:17 UTC 2006
Fri May 26 03:22:17 UTC 2006
The current system and the time difference, a full eight hours, may I ask how matter ah, and I use the type GMT TimeZone is why results UCT type, done Why? Thank you!
Incidentally ask about, I use development environment for Eclipse, the use of simulators, with System.ou.print ( "aa"); in the value can not be displayed on the console, until withdraw from the simulator, or after the use of the System. out, println ( "xx"); could be System.ou.print ( "aa"); the value displayed is why ah, the Eclipse is not what should be installed? Thank you
About that time, another good look at the book that Wang Sen
UTC is the world the meaning of coordination, and we are +8, so you can print a poor eight hours issue
Print the best use of your time to format SimpleDateFormat
Looking forward to a more precise response!
Up
I use the Eclipse development environment, the use of simulators, with System.ou.print ( "aa"); in the value can not be displayed on the console, until withdraw from the simulator, or after using System.out, println ( " xx "); could be System.ou.print (" aa "); the value displayed is why ah, the Eclipse is not what should be installed?
Ditto said, the time zone difference of eight hours.
Also: System.out, print ( "xx");
System.out, println ( "xx");
Is not the same, please note, the above output, not-for-line, below his output for, and for firms
When the question is the issue of simulators, thank you all!
Println print and the distinction clear to me why Eclipse in the simulator environment, a separate output can show that the value of print, or until the withdrawal is a simulator called println when news can be made in the console. In general the Eclipse development environment under a separate not only print, I would like to understand the problem Eclispse settings or plug-in bug EclispeMe
Up
ChDw (m) () Blue: 155
Print the best use of your time to SimpleDateFormat formatted specifically how do? I would like to know, under the code posted by reference. Thank you, the
Zaiding
Up
Asked one category on the Calendar when computing the problems
J2ME recent study
My platform is ECLIPSE + WTK2. 2
Problems in their study on the Calendar of issues such as the following procedure
Package study;
Import javax.microedition.midlet.MIDlet;
Import javax.microedition.midlet.MIDletStateChangeException;
Import java.util .*;
Import javax.microedition.lcdui .*;
Public class CalendarTest extends MIDlet (
Protected void startApp () (throws MIDletStateChangeException
/ / TODO Auto-generated method stub
Calendar cal = Calendar.getInstance ();
Date now = new Date ();
Cal.setTime (now);
System.out.println (cal);
/ / Change time zones CCT
/ * TimeZone tz = TimeZone.getTimeZone ( "CCT");
Calendar cctcal = Calendar.getInstance (tz);
Date now = new Date ();
Cctcal.setTime (now);
System.out.println (cctcal) * /
)
Protected void pauseApp () (
/ / TODO Auto-generated method stub
)
Protected void destroyApp (boolean arg0) throws MIDletStateChangeException (
/ / TODO Auto-generated method stub
)
)
It is the result of its operation
Com.sun.cldc.util.j2me.CalendarImpl @ d590dbc
I had my time zone, replaced by CCT, and the results above, I think the same should be the output of the date and hour ah Why is this? ?
Calendar can not be printed directly below him get there is a way to see it out their own landlord
This ah my heart but also feel this is a "JAVA phone / PDA program design entry," a book with examples of the computation of the results I feel may not be printed
Calendar of the current month will be less a month? ?
Code as follows:
Calendar rightNow = Calendar.getInstance ();
Int month = rightNow.get (Calendar.MONTH);
I do not know why, always than the current month in a small, for example, it is November, and the month is 10, I will set up systems for January, the month 0. In the simulator on board and really like this
However, the normal day and help out please everyone, I wake up some points, which is why?
Public static final int MONTHField number for get and set indicating the month. This is a calendar-specific value. The first month of the year is JANUARY which is 0; the last depends on the number of months in a year.
Jdk explanation.
This is the son tell array subscript 0 from the beginning, not why
No reason is that the case.
Some time this issue will also outbreak, therefore, some time to date is slightly packaging category.
You see this example
————————————————– ———–
Calendar rightNow = Calendar.getInstance ();
Date date = new Date (82,6,3);
RightNow.setTime (date);
Int month = rightNow.get (Calendar.MONTH);
System.out.println (month);
String format = "MM / dd / yyyy HH: mm: ss";
SimpleDateFormat formatter = new SimpleDateFormat (format);
System.out.println (formatter.format (rightNow.getTime ()));
————————————————– ——————
Print results
6
07/03/1982 00:00:00
That is the date I type-June 3, 1982
Calendar type of recognition for his July 3, 1982 a
He figures to 6-July that, no way. . . . . .
This is the
Thank you, everyone! ! :)
I also suspect that such a system is likely to set, but did not find in the jdk gzpoplar (poplar) the information provided in the latter half of the (The first month of the year is JANUARY which is 0; the last depends on the number of months in a year.)
I Tieshanglai you use that part of the sentence or baidu try to google.
A JSP to do with the calendar