在Java JFrame中显示Google日历 [英] Displaying Google Calendar in Java JFrame
问题描述
我无法在Java jframe中显示Google日历.
I am having trouble displaying a google calendar in a java jframe.
我确实看到了Google日历,但是它的背景是蓝色的,很难查看事件.
Edited: I do see the google calendar, but it is has a blue background and it makes it difficult to view events.
这是我的代码的伪装
temp
是google用户名.
temp
is the google username.
private void getGoogleCalendar(){
googlepane=new JPanel(new BorderLayout());
String s="https://www.google.com/calendar/b/0/htmlembed?src=groupboba@gmail.com&ctz=America/New_York&gsessionid=OK";
JEditorPane tp=new JEditorPane();
try {
HTMLEditorKit kit = new HTMLEditorKit();
StyleSheet styles =kit.getStyleSheet();
styles.importStyleSheet(new URL(s));
kit.setStyleSheet(styles);
kit.install(tp);
tp.setContentType("text/html");
tp.setEditorKit(kit);
tp.addHyperlinkListener(this);
tp.setEditable(false);
tp.setPage(s);
tp.setBackground(Color.white);
} catch (IOException e) {
e.printStackTrace();
}
googlepane.add(tp, BorderLayout.CENTER);
return;
}
推荐答案
JEditorPane无法完全显示Web页面,因为它仅支持html文本. Google日历页面包含"JavaScript".因此,在Web浏览器和使用JEditorPane的情况下,它将变成不同的显示.
JEditorPane can not display completely the Web page because it supports html text only. Google Calendar page includes "JavaScript". So it becomes a different display in the case of a web browser and the case of using JEditorPane.
我建议使用本地Swing库(DJ项目).
"JavascriptExecution.java"示例用于确认移动.
"JavascriptExecution.java" sample is used to confirm movement.
原始
webBrowser.setHTMLContent(htmlContent);
更改关注
final String urlString =
"https://www.google.com/calendar/"
+ "b/0/htmlembed?src=0ap0d38a4vobr8i81805dla3hk@group.calendar.google.com"
+ "&ctz=America/New_York&gsessionid=OK";
webBrowser.navigate(urlString);
并且您必须将以下三个jar文件添加到类传递中.
And you have to add the following three jar files to the class pass.
- DJNativeSwing.jar
- DJNativeSwing-SWT.jar
- swt-3.7M5-win32-win32-x86.jar
此swt库位于[进度库目录]/lib中.或者,您可以获取(网站)
This swt library is in [Directory that progresses library]/lib. Or you can get (the Website)
这篇关于在Java JFrame中显示Google日历的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!