[英]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.