java課程設(shè)計(jì)--日歷_第1頁(yè)
已閱讀1頁(yè),還剩14頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、<p>  《java語(yǔ)言課程設(shè)計(jì)》</p><p><b>  學(xué) 院: </b></p><p><b>  指導(dǎo)教師: </b></p><p><b>  學(xué) 號(hào):</b></p><p><b>  姓 名:</b></p>

2、<p><b>  班 級(jí):</b></p><p><b>  目錄</b></p><p>  一、課程題目……………………………………2</p><p>  二、需求分析……………………………………2</p><p>  三、概要設(shè)計(jì)……………………………………2</p&g

3、t;<p>  四、詳細(xì)設(shè)計(jì)……………………………………2</p><p>  五、測(cè)試數(shù)據(jù)及運(yùn)行結(jié)果………………………8</p><p>  六、源程序………………………………………9一、課程題目:日歷</p><p><b>  二、需求分析</b></p><p>  程序要求:1、使用“鼠標(biāo)單擊響應(yīng)

4、”模式的用戶界面顯示日歷;</p><p>  2、查詢?nèi)我馊掌?,?shí)現(xiàn)日期與星期的互查,單擊所選日期變色;</p><p>  3、初始界面顯示當(dāng)前系統(tǒng)時(shí)間;</p><p>  本程序體現(xiàn)了對(duì)圖形用戶界面、布局管理器的綜合運(yùn)用,可實(shí)現(xiàn)查詢?nèi)掌诤惋@示時(shí)間的功能,滿足日?;竟ぷ骱蛫蕵?lè)的需要。</p><p><b>  三、概要設(shè)計(jì)

5、</b></p><p><b>  四、詳細(xì)設(shè)計(jì)</b></p><p>  1、導(dǎo)入java中包</p><p>  import java.awt.BorderLayout;</p><p>  import java.awt.Color;</p><p>  import ja

6、va.awt.Component;</p><p>  import java.awt.Container;</p><p>  import java.awt.FlowLayout;</p><p>  import java.awt.event.ActionEvent;</p><p>  import java.awt.event.Ac

7、tionListener;</p><p>  import java.awt.event.FocusEvent;</p><p>  import java.awt.event.FocusListener;</p><p>  import java.util.Calendar;</p><p>  import javax.swing.J

8、Applet;</p><p>  import javax.swing.JButton;</p><p>  import javax.swing.JComboBox;</p><p>  import javax.swing.JFrame;</p><p>  import javax.swing.JLabel;</p>&

9、lt;p>  import javax.swing.JOptionPane;</p><p>  import javax.swing.JPanel;</p><p>  import javax.swing.JSpinner;</p><p>  import javax.swing.JTable;</p><p>  import

10、javax.swing.JTextField;</p><p>  import javax.swing.ListSelectionModel;</p><p>  import javax.swing.Timer;</p><p>  import javax.swing.event.ChangeEvent;</p><p>  impor

11、t javax.swing.event.ChangeListener;</p><p>  import javax.swing.table.AbstractTableModel;</p><p>  import javax.swing.table.TableCellRenderer;</p><p>  import javax.swing.table.Tabl

12、eModel;</p><p>  2、初始化:public void init()完成界面初始化,形成一個(gè)億掛歷形式顯示當(dāng)前日期的窗口。</p><p>  2.1、給容器cPanel設(shè)置格局:cPane.setLayout(new BorderLayout());</p><p>  2.2、日歷年份選擇復(fù)選框設(shè)置:</p><p>  

13、yearsLabel = new JLabel("Year: ");</p><p>  yearsSpinner = new JSpinner();</p><p>  yearsSpinner.setEditor(new JSpinner.NumberEditor(yearsSpinner, "0000"));</p><p&

14、gt;  yearsSpinner.setValue(new Integer(calendar.get(Calendar.YEAR)));</p><p><b>  注冊(cè)監(jiān)聽(tīng)器:</b></p><p>  yearsSpinner.addChangeListener(new ChangeListener() {</p><p>  publ

15、ic void stateChanged(ChangeEvent changeEvent) {</p><p>  int day = calendar.get(Calendar.DAY_OF_MONTH);</p><p>  calendar.set(Calendar.DAY_OF_MONTH, 1);</p><p>  calendar.set(Calend

16、ar.YEAR, ((Integer) yearsSpinner.getValue()).intValue());</p><p>  int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);</p><p>  calendar.set(Calendar.DAY_OF_MONTH, day > maxDay ? m

17、axDay : day);</p><p>  updateView();</p><p><b>  }</b></p><p><b>  });</b></p><p>  2.3、日歷月份下拉列表設(shè)置:</p><p>  JPanel yearMonthPanel

18、= new JPanel();</p><p>  cPane.add(yearMonthPanel, BorderLayout.NORTH);</p><p>  yearMonthPanel.setLayout(new BorderLayout());</p><p>  yearMonthPanel.add(new JPanel(), BorderLayout

19、.CENTER);</p><p>  JPanel yearPanel = new JPanel();</p><p>  yearMonthPanel.add(yearPanel, BorderLayout.WEST);</p><p>  yearPanel.setLayout(new BorderLayout());</p><p>

20、  yearPanel.add(yearsLabel, BorderLayout.WEST);</p><p>  yearPanel.add(yearsSpinner, BorderLayout.CENTER);</p><p>  monthsLabel = new JLabel("Month: ");</p><p>  monthsCom

21、boBox = new JComboBox();</p><p>  for (int i = 1; i <= 12; i++) {</p><p>  monthsComboBox.addItem(new Integer(i));</p><p><b>  }</b></p><p>  monthsCombo

22、Box.setSelectedIndex(calendar.get(Calendar.MONTH));</p><p><b>  注冊(cè)監(jiān)聽(tīng)器:</b></p><p>  monthsComboBox.addActionListener(new ActionListener() {</p><p>  public void actionPe

23、rformed(ActionEvent actionEvent) {</p><p>  int day = calendar.get(Calendar.DAY_OF_MONTH);</p><p>  calendar.set(Calendar.DAY_OF_MONTH, 1);</p><p>  calendar.set(Calendar.MONTH, mon

24、thsComboBox.getSelectedIndex());</p><p>  int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);</p><p>  calendar.set(Calendar.DAY_OF_MONTH, day > maxDay ? maxDay : day);</p>

25、<p>  updateView();</p><p><b>  }</b></p><p><b>  });</b></p><p>  2.4、數(shù)據(jù)更新引索:</p><p>  daysModel = new AbstractTableModel() {</p>&

26、lt;p>  public int getRowCount() {</p><p><b>  return 7;</b></p><p><b>  }</b></p><p>  public int getColumnCount() {</p><p><b>  return

27、 7;</b></p><p><b>  }</b></p><p>  public Object getValueAt(int row, int column) {</p><p>  if (row == 0) {</p><p>  return getHeader(column);</p&g

28、t;<p><b>  }</b></p><p><b>  row--;</b></p><p>  Calendar calendar = (Calendar) MyCalendar.this.calendar.clone();</p><p>  calendar.set(Calendar.DAY_O

29、F_MONTH, 1);</p><p>  int dayCount = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);</p><p>  int moreDayCount = calendar.get(Calendar.DAY_OF_WEEK) - 1;</p><p>  int index = row *

30、 7 + column;</p><p>  int dayIndex = index - moreDayCount + 1;</p><p>  if (index < moreDayCount || dayIndex > dayCount) {</p><p>  return null;</p><p><b> 

31、 } else {</b></p><p>  return new Integer(dayIndex);</p><p><b>  }</b></p><p><b>  }</b></p><p><b>  };</b></p><p&g

32、t;  2.5、日歷表格設(shè)置:</p><p>  daysTable = new CalendarTable(daysModel, calendar); daysTable.setCellSelectionEnabled(true);</p><p>  daysTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);<

33、;/p><p>  daysTable.setDefaultRenderer(daysTable.getColumnClass(0), new TableCellRenderer() {</p><p>  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,

34、</p><p>  boolean hasFocus, int row, int column) {</p><p>  String text = (value == null) ? "" : value.toString();</p><p>  JLabel cell = new JLabel(text);</p><

35、p>  cell.setOpaque(true);</p><p>  if (row == 0) {</p><p>  cell.setForeground(headerForeground);</p><p>  cell.setBackground(headerBackground);</p><p><b>  }

36、else {</b></p><p>  if (isSelected) {</p><p>  cell.setForeground(selectedForeground);</p><p>  cell.setBackground(selectedBackground);</p><p><b>  } else {

37、</b></p><p>  cell.setForeground(foreground);</p><p>  cell.setBackground(background);</p><p><b>  }</b></p><p><b>  }</b></p><

38、p>  return cell;</p><p><b>  }</b></p><p><b>  });</b></p><p>  updateView();</p><p>  cPane.add(daysTable, BorderLayout.CENTER);</p>

39、<p>  3、MyCalendar類</p><p>  靜態(tài)數(shù)據(jù)成員的定義:public static final String WEEK_SUN = "SUN";</p><p>  public static final String WEEK_MON = "MON";</p><p>  public st

40、atic final String WEEK_TUE = "TUE";</p><p>  public static final String WEEK_WED = "WED";</p><p>  public static final String WEEK_THU = "THU";</p><p>

41、  public static final String WEEK_FRI = "FRI";</p><p>  public static final String WEEK_SAT = "SAT";</p><p>  public static final Color background = Color.orange;</p>

42、<p>  public static final Color foreground = Color.black;</p><p>  public static final Color headerBackground = Color.blue;</p><p>  public static final Color headerForeground = Color.white

43、;</p><p>  public static final Color selectedBackground = Color.blue;</p><p>  public static final Color selectedForeground = Color.white;</p><p>  私有數(shù)據(jù)成員的定義:private JPanel cPane;&l

44、t;/p><p>  private JLabel yearsLabel;</p><p>  private JSpinner yearsSpinner;</p><p>  private JLabel monthsLabel;</p><p>  private JComboBox monthsComboBox;</p>&l

45、t;p>  private JTable daysTable;</p><p>  private AbstractTableModel daysModel;</p><p>  private Calendar calendar;</p><p>  private JButton button1;</p><p><b>

46、  構(gòu)造函數(shù):</b></p><p>  public MyCalendar() {</p><p>  cPane = (JPanel) getContentPane();</p><p><b>  }</b></p><p><b>  日歷首行設(shè)置:</b></p>

47、<p>  public static String getHeader(int index) {</p><p>  switch (index) {</p><p><b>  case 0:</b></p><p>  return WEEK_SUN;</p><p><b>  case

48、1:</b></p><p>  return WEEK_MON;</p><p><b>  case 2:</b></p><p>  return WEEK_TUE;</p><p><b>  case 3:</b></p><p>  return WE

49、EK_WED;</p><p><b>  case 4:</b></p><p>  return WEEK_THU;</p><p><b>  case 5:</b></p><p>  return WEEK_FRI;</p><p><b>  case

50、6:</b></p><p>  return WEEK_SAT;</p><p><b>  default:</b></p><p>  return null;</p><p><b>  }</b></p><p><b>  }</b&g

51、t;</p><p><b>  界面更新函數(shù):</b></p><p>  public void updateView() {</p><p>  daysModel.fireTableDataChanged();</p><p>  daysTable.setRowSelectionInterval(calenda

52、r.get(Calendar.WEEK_OF_MONTH),</p><p>  calendar.get(Calendar.WEEK_OF_MONTH));</p><p>  daysTable.setColumnSelectionInterval(calendar.get(Calendar.DAY_OF_WEEK) - 1,calendar.get(Calendar.DAY_OF_W

53、EEK) - 1);</p><p><b>  }</b></p><p>  4、CalendarTable類</p><p>  Calendar數(shù)據(jù)成員:private Calendar calendar;</p><p>  Calendar成員方法:</p><p>  public

54、CalendarTable(TableModel model, Calendar calendar) {</p><p>  super(model);</p><p>  this.calendar = calendar;</p><p><b>  }</b></p><p><b>  數(shù)據(jù)更新:<

55、/b></p><p>  public void changeSelection(int row, int column, boolean toggle, boolean extend) {</p><p>  super.changeSelection(row, column, toggle, extend);</p><p>  if (row == 0

56、) {</p><p><b>  return;</b></p><p><b>  }</b></p><p>  Object obj = getValueAt(row, column);</p><p>  if (obj != null) {</p><p>  c

57、alendar.set(Calendar.DAY_OF_MONTH, ((Integer)obj).intValue());</p><p><b>  }</b></p><p><b>  }</b></p><p>  4、public static void main(String[] args)主類</p&

58、gt;<p>  public static void main(String[] args) {</p><p>  JFrame frame = new JFrame("java小日歷");</p><p>  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);</p><p

59、>  MyCalendar myCalendar = new MyCalendar();</p><p>  myCalendar.init();</p><p>  frame.getContentPane().add(myCalendar);</p><p>  frame.setLocation(330,80);</p><p>

60、  frame.setSize(360, 212);</p><p>  frame.setVisible(true);</p><p><b>  }</b></p><p><b>  五、測(cè)試數(shù)據(jù)及運(yùn)行</b></p><p>  圖1 初始界面顯示日歷</p><p>

61、;  程序運(yùn)行后,顯示當(dāng)前系統(tǒng)時(shí)間,所在日期顯示為藍(lán)色</p><p>  圖2 日歷月份下拉列表顯示</p><p>  鼠標(biāo)點(diǎn)擊月份下拉鍵,移動(dòng)滾動(dòng)條可選擇月份</p><p><b>  圖3 數(shù)據(jù)更新</b></p><p>  該程序的年份復(fù)選框可實(shí)現(xiàn)上一年、下一年查詢?nèi)掌诠δ埽⑶疫€可實(shí)現(xiàn)任意選擇年份查詢?nèi)掌?/p>

62、功能</p><p><b>  六、源程序</b></p><p>  import java.applet.Applet;</p><p>  import java.awt.BorderLayout;</p><p>  import java.awt.Color;</p><p>  im

63、port java.awt.Component;</p><p>  import java.awt.Container;</p><p>  import java.awt.FlowLayout;</p><p>  import java.awt.event.ActionEvent;</p><p>  import java.awt.e

64、vent.ActionListener;</p><p>  import java.awt.event.FocusEvent;</p><p>  import java.awt.event.FocusListener;</p><p>  import java.util.Calendar;</p><p>  import javax.

65、swing.JApplet;</p><p>  import javax.swing.JButton;</p><p>  import javax.swing.JComboBox;</p><p>  import javax.swing.JFrame;</p><p>  import javax.swing.JLabel;</p

66、><p>  import javax.swing.JOptionPane;</p><p>  import javax.swing.JPanel;</p><p>  import javax.swing.JSpinner;</p><p>  import javax.swing.JTable;</p><p>  

67、import javax.swing.JTextField;</p><p>  import javax.swing.ListSelectionModel;</p><p>  import javax.swing.Timer;</p><p>  import javax.swing.event.ChangeEvent;</p><p>

68、  import javax.swing.event.ChangeListener;</p><p>  import javax.swing.table.AbstractTableModel;</p><p>  import javax.swing.table.TableCellRenderer;</p><p>  import javax.swing.tab

69、le.TableModel;</p><p><b>  //日歷</b></p><p>  public class MyCalendar extends JApplet</p><p><b>  {</b></p><p>  public static final String WEEK_

70、SUN = "SUN";</p><p>  public static final String WEEK_MON = "MON";</p><p>  public static final String WEEK_TUE = "TUE";</p><p>  public static final S

71、tring WEEK_WED = "WED";</p><p>  public static final String WEEK_THU = "THU";</p><p>  public static final String WEEK_FRI = "FRI";</p><p>  public sta

72、tic final String WEEK_SAT = "SAT";</p><p>  public static final Color background = Color.orange;</p><p>  public static final Color foreground = Color.black;</p><p>  publ

73、ic static final Color headerBackground = Color.blue;</p><p>  public static final Color headerForeground = Color.white;</p><p>  public static final Color selectedBackground = Color.blue;</p&

74、gt;<p>  public static final Color selectedForeground = Color.white;</p><p>  private JPanel cPane;</p><p>  private JLabel yearsLabel;</p><p>  private JSpinner yearsSpinner

75、;</p><p>  private JLabel monthsLabel;</p><p>  private JComboBox monthsComboBox;</p><p>  private JTable daysTable;</p><p>  private AbstractTableModel daysModel;</

76、p><p>  private Calendar calendar;</p><p>  private JButton button1;</p><p>  public MyCalendar() {</p><p>  cPane = (JPanel) getContentPane();</p><p><b&g

77、t;  }</b></p><p>  public void init()</p><p><b>  {</b></p><p>  cPane.setLayout(new BorderLayout());</p><p>  calendar = Calendar.getInstance();</

78、p><p>  calendar = Calendar.getInstance();</p><p>  JButton button1=new JButton("");</p><p>  button1.setBounds(10,10,10,10);</p><p>  cPane.add(button1,BorderLa

79、yout.SOUTH);</p><p>  yearsLabel = new JLabel("Year: ");</p><p>  yearsSpinner = new JSpinner();</p><p>  yearsSpinner.setEditor(new JSpinner.NumberEditor(yearsSpinner, &q

80、uot;0000"));</p><p>  yearsSpinner.setValue(new Integer(calendar.get(Calendar.YEAR)));</p><p>  yearsSpinner.addChangeListener(new ChangeListener() {</p><p>  public void state

81、Changed(ChangeEvent changeEvent) {</p><p>  int day = calendar.get(Calendar.DAY_OF_MONTH);</p><p>  calendar.set(Calendar.DAY_OF_MONTH, 1);</p><p>  calendar.set(Calendar.YEAR, ((In

82、teger) yearsSpinner.getValue()).intValue());</p><p>  int maxDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);</p><p>  calendar.set(Calendar.DAY_OF_MONTH, day > maxDay ? maxDay : day);

83、</p><p>  updateView();</p><p><b>  }</b></p><p><b>  });</b></p><p>  JPanel yearMonthPanel = new JPanel();</p><p>  cPane.add(yea

84、rMonthPanel, BorderLayout.NORTH);</p><p>  yearMonthPanel.setLayout(new BorderLayout());</p><p>  yearMonthPanel.add(new JPanel(), BorderLayout.CENTER);</p><p>  JPanel yearPanel =

85、new JPanel();</p><p>  yearMonthPanel.add(yearPanel, BorderLayout.WEST);</p><p>  yearPanel.setLayout(new BorderLayout());</p><p>  yearPanel.add(yearsLabel, BorderLayout.WEST);<

86、/p><p>  yearPanel.add(yearsSpinner, BorderLayout.CENTER);</p><p>  monthsLabel = new JLabel("Month: ");</p><p>  monthsComboBox = new JComboBox();</p><p>  for

87、(int i = 1; i <= 12; i++) {</p><p>  monthsComboBox.addItem(new Integer(i));</p><p><b>  }</b></p><p>  monthsComboBox.setSelectedIndex(calendar.get(Calendar.MONTH));

88、</p><p>  monthsComboBox.addActionListener(new ActionListener() {</p><p>  public void actionPerformed(ActionEvent actionEvent) {</p><p>  int day = calendar.get(Calendar.DAY_OF_MON

89、TH);</p><p>  calendar.set(Calendar.DAY_OF_MONTH, 1);</p><p>  calendar.set(Calendar.MONTH, monthsComboBox.getSelectedIndex());</p><p>  int maxDay = calendar.getActualMaximum(Calen

90、dar.DAY_OF_MONTH);</p><p>  calendar.set(Calendar.DAY_OF_MONTH, day > maxDay ? maxDay : day);</p><p>  updateView();</p><p><b>  }</b></p><p><b>  

91、});</b></p><p>  JPanel monthPanel = new JPanel();</p><p>  yearMonthPanel.add(monthPanel, BorderLayout.EAST);</p><p>  monthPanel.setLayout(new BorderLayout());</p>&l

92、t;p>  monthPanel.add(monthsLabel, BorderLayout.WEST);</p><p>  monthPanel.add(monthsComboBox, BorderLayout.CENTER);</p><p>  daysModel = new AbstractTableModel() {</p><p>  publi

93、c int getRowCount() {</p><p><b>  return 7;</b></p><p><b>  }</b></p><p>  public int getColumnCount() {</p><p><b>  return 7;</b>&l

94、t;/p><p><b>  }</b></p><p>  public Object getValueAt(int row, int column) {</p><p>  if (row == 0) {</p><p>  return getHeader(column);</p><p>&l

95、t;b>  }</b></p><p><b>  row--;</b></p><p>  Calendar calendar = (Calendar) MyCalendar.this.calendar.clone();</p><p>  calendar.set(Calendar.DAY_OF_MONTH, 1);<

96、;/p><p>  int dayCount = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);</p><p>  int moreDayCount = calendar.get(Calendar.DAY_OF_WEEK) - 1;</p><p>  int index = row * 7 + column;<

97、;/p><p>  int dayIndex = index - moreDayCount + 1;</p><p>  if (index < moreDayCount || dayIndex > dayCount) {</p><p>  return null;</p><p><b>  } else {</b

98、></p><p>  return new Integer(dayIndex);</p><p><b>  }</b></p><p><b>  }</b></p><p><b>  };</b></p><p>  daysTable =

99、 new CalendarTable(daysModel, calendar);</p><p>  daysTable.setCellSelectionEnabled(true);</p><p>  daysTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);</p><p>  daysTab

100、le.setDefaultRenderer(daysTable.getColumnClass(0), new TableCellRenderer() {</p><p>  public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,</p><p>  bool

101、ean hasFocus, int row, int column) {</p><p>  String text = (value == null) ? "" : value.toString();</p><p>  JLabel cell = new JLabel(text);</p><p>  cell.setOpaque(true)

102、;</p><p>  if (row == 0) {</p><p>  cell.setForeground(headerForeground);</p><p>  cell.setBackground(headerBackground);</p><p><b>  } else {</b></p>

103、<p>  if (isSelected) {</p><p>  cell.setForeground(selectedForeground);</p><p>  cell.setBackground(selectedBackground);</p><p><b>  } else {</b></p><p

104、>  cell.setForeground(foreground);</p><p>  cell.setBackground(background);</p><p><b>  }</b></p><p><b>  }</b></p><p>  return cell;</p&g

105、t;<p><b>  }</b></p><p><b>  });</b></p><p>  updateView();</p><p>  cPane.add(daysTable, BorderLayout.CENTER);</p><p><b>  }</b

106、></p><p>  public static String getHeader(int index) {</p><p>  switch (index) {</p><p><b>  case 0:</b></p><p>  return WEEK_SUN;</p><p>&l

107、t;b>  case 1:</b></p><p>  return WEEK_MON;</p><p><b>  case 2:</b></p><p>  return WEEK_TUE;</p><p><b>  case 3:</b></p><p&

108、gt;  return WEEK_WED;</p><p><b>  case 4:</b></p><p>  return WEEK_THU;</p><p><b>  case 5:</b></p><p>  return WEEK_FRI;</p><p>&l

109、t;b>  case 6:</b></p><p>  return WEEK_SAT;</p><p><b>  default:</b></p><p>  return null;</p><p><b>  }</b></p><p><b&

110、gt;  }</b></p><p>  public void updateView() {</p><p>  daysModel.fireTableDataChanged();</p><p>  daysTable.setRowSelectionInterval(calendar.get(Calendar.WEEK_OF_MONTH),</

111、p><p>  calendar.get(Calendar.WEEK_OF_MONTH));</p><p>  daysTable.setColumnSelectionInterval(calendar.get(Calendar.DAY_OF_WEEK) - 1,</p><p>  calendar.get(Calendar.DAY_OF_WEEK) - 1);&l

112、t;/p><p><b>  }</b></p><p>  public static class CalendarTable extends JTable {</p><p>  private Calendar calendar;</p><p>  public CalendarTable(TableModel mo

113、del, Calendar calendar) {</p><p>  super(model);</p><p>  this.calendar = calendar;</p><p><b>  }</b></p><p>  public void changeSelection(int row, int colu

114、mn, boolean toggle, boolean extend) {</p><p>  super.changeSelection(row, column, toggle, extend);</p><p>  if (row == 0) {</p><p><b>  return;</b></p><p>&

115、lt;b>  }</b></p><p>  Object obj = getValueAt(row, column);</p><p>  if (obj != null) {</p><p>  calendar.set(Calendar.DAY_OF_MONTH, ((Integer)obj).intValue());</p>

116、<p><b>  }</b></p><p><b>  }</b></p><p><b>  }</b></p><p>  public static void main(String[] args) {</p><p>  JFrame frame = n

117、ew JFrame("java小日歷");</p><p>  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);</p><p>  MyCalendar myCalendar = new MyCalendar();</p><p>  myCalendar.init();</p&g

118、t;<p>  frame.getContentPane().add(myCalendar);</p><p>  frame.setLocation(330,80);</p><p>  frame.setSize(360, 212);</p><p>  frame.setVisible(true);</p><p><

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 眾賞文庫(kù)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

評(píng)論

0/150

提交評(píng)論