本文介绍了方法在Java Swing中构建一个简单的日历的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一个简单的方法来实现日历(类似于google日历)在java。日历必须在顶部显示星期一 - 星期日,并且每行显示一小时。

 星期一|星期二|星期三
08:00
09:00
10:00
11:00

如何在Swing中创建一个日历?我使用Netbeans IDE。每一列都应该能够保存一些文本。



我可以只使用swing组件吗?

解决方案

你可能想考虑使用 JTable 。您可以使用 AbstractTableModel 定义表的维以及其他一些属性,然后您可以使用所需的值填充顶行和第一列。



有关详细信息,请参阅下面的表格。请查看。 p>

I need a simple way to implement a Calendar (similar to google calendar) in java. The calendar must display Monday - Sunday at the top and each hour as a row.

      Monday | Tuesday | Wednesday
08:00
09:00
10:00
11:00

How would one create a calendar in Swing like that? I'm using Netbeans IDE. Each column should be able to hold some text.

Could I just use the table component in swing? If so, can i modify it to meet my needs?

解决方案

You would probably want to think about using JTable. You can use an AbstractTableModel to define the dimensions of the table, as well as some other properties, then you can fill in the top row and first column with the desired values. You can also set certain parts of the table editable by your users, in the event that you wanted to be able to input data into the calendar.

For more info, take a look at the JTable documentation.

这篇关于方法在Java Swing中构建一个简单的日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 16:40