[英]How to display the weekend in different font color using Calendar class in Java?
当前,日历中的所有日期字体颜色都是相同的,但是我想将周末设置为不同的颜色。
Calendar c = Calendar.getInstance(Constants.localeCosnt);
int dateValue = c.get(Calendar.DATE);
setFortnightsOfTheMonth(DateUtils.getFortnightsOfTheMonth(c.getTime(), dateValue));
好像您希望输出是彩色的。 使用适当的文本输出组件。 你可以做这样的事情
JTextArea txt = new JTextArea();
Font font = new Font("Verdana", Font.BOLD, 12);
txt.setFont(font);
txt.setForeground(Color.BLUE);
注意,您将需要使用自己的文本组件输出。 我在做的只是显示一条路
感谢您的回答。
但是后来我确实使用String函数在JSF页面上尝试了它,但是它确实起作用了。
<p:column id="hoursWorkedDay1"
headerText="#{timeAndExpenseManagedController.firstDate}"
style="background-color:#{timeAndExpenseManagedController.firstDate.substring(0,3)== 'Sat' or
timeAndExpenseManagedController.firstDate.substring(0,3)== 'Sun'?
'#e6f0ff !important' : 'none !important'}">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.