本文整理汇总了Java中javax.swing.text.html.HTMLDocument.setBase方法的典型用法代码示例。如果您正苦于以下问题:Java HTMLDocument.setBase方法的具体用法?Java HTMLDocument.setBase怎么用?Java HTMLDocument.setBase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.html.HTMLDocument
的用法示例。
在下文中一共展示了HTMLDocument.setBase方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initComponents
import javax.swing.text.html.HTMLDocument; //导入方法依赖的package包/类
private void initComponents(URL ruleBase, String htmlDescription) {
setLayout(new BorderLayout());
setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
HTMLTextArea descriptionArea = new HTMLTextArea();
HTMLDocument hdoc = (HTMLDocument) descriptionArea.getDocument();
descriptionArea.setText(htmlDescription);
descriptionArea.setCaretPosition(0);
hdoc.setBase(ruleBase);
JScrollPane descriptionAreaScrollPane = new JScrollPane(descriptionArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
descriptionAreaScrollPane.setPreferredSize(new Dimension(375, 220));
add(descriptionAreaScrollPane, BorderLayout.CENTER);
}
示例2: openPSP
import javax.swing.text.html.HTMLDocument; //导入方法依赖的package包/类
public javax.swing.text.Document openPSP(PSP psp) {
HTMLDocument doc = (HTMLDocument) editorKit.createDefaultDocument();
if (psp == null)
return doc;
String filename = getPSPPath(psp);
try {
/*DEBUG*/
// Util.debug("Open note: " + filename);
// Util.debug("Note Title: " + note.getTitle());
doc.setBase(new URL(getPSPURL(psp)));
editorKit.read(
new InputStreamReader(new FileInputStream(filename), "UTF-8"),
doc,
0);
}
catch (Exception ex) {
//ex.printStackTrace();
// Do nothing - we've got a new empty document!
}
return doc;
}
示例3: openNote
import javax.swing.text.html.HTMLDocument; //导入方法依赖的package包/类
/**
* @see net.sf.memoranda.util.Storage#openNote(net.sf.memoranda.Note)
*/
public javax.swing.text.Document openNote(Note note) {
HTMLDocument doc = (HTMLDocument) editorKit.createDefaultDocument();
if (note == null)
return doc;
/*
String filename = JN_DOCPATH + note.getProject().getID() + File.separator;
CalendarDate d = note.getDate();
filename += d.getDay() + "-" + d.getMonth() + "-" + d.getYear();
*/
String filename = getNotePath(note);
try {
/*DEBUG*/
// Util.debug("Open note: " + filename);
// Util.debug("Note Title: " + note.getTitle());
doc.setBase(new URL(getNoteURL(note)));
editorKit.read(
new InputStreamReader(new FileInputStream(filename), "UTF-8"),
doc,
0);
}
catch (Exception ex) {
//ex.printStackTrace();
// Do nothing - we've got a new empty document!
}
return doc;
/*HTMLDocument doc = (HTMLDocument)editorKit.createDefaultDocument();
if (note == null) return doc;
String filename = JN_DOCPATH + note.getProject().getID() + "/";
CalendarDate d = note.getDate();
filename += d.getDay() + "-" + d.getMonth() + "-" + d.getYear();
try {
long t1 = new java.util.Date().getTime();
FileInputStream istream = new FileInputStream(filename);
ObjectInputStream ois = new ObjectInputStream(istream);
doc = (HTMLDocument)ois.readObject();
ois.close();
istream.close();
long t2 = new java.util.Date().getTime();
System.out.println(filename+" open:"+ (t2-t1) );
}
catch (Exception ex) {
ex.printStackTrace();
}
return doc;*/
}
示例4: openNote
import javax.swing.text.html.HTMLDocument; //导入方法依赖的package包/类
/**
* @see net.sf.memoranda.util.Storage#openNote(net.sf.memoranda.Note)
*/
public javax.swing.text.Document openNote(Note note) {
HTMLDocument doc = (HTMLDocument) editorKit.createDefaultDocument();
if (note == null)
return doc;
/*
String filename = JN_DOCPATH + note.getProject().getID() + File.separator;
CalendarDate d = note.getDate();
filename += d.getDay() + "-" + d.getMonth() + "-" + d.getYear();
*/
String filename = getNotePath(note);
try {
/*DEBUG*/
doc.setBase(new URL(getNoteURL(note)));
editorKit.read(
new InputStreamReader(new FileInputStream(filename), "UTF-8"),
doc,
0);
}
catch (Exception ex) {
//ex.printStackTrace();
// Do nothing - we've got a new empty document!
}
return doc;
/*HTMLDocument doc = (HTMLDocument)editorKit.createDefaultDocument();
if (note == null) return doc;
String filename = JN_DOCPATH + note.getProject().getID() + "/";
CalendarDate d = note.getDate();
filename += d.getDay() + "-" + d.getMonth() + "-" + d.getYear();
try {
long t1 = new java.util.Date().getTime();
FileInputStream istream = new FileInputStream(filename);
ObjectInputStream ois = new ObjectInputStream(istream);
doc = (HTMLDocument)ois.readObject();
ois.close();
istream.close();
long t2 = new java.util.Date().getTime();
Util.debug(filename+" open:"+ (t2-t1) );
}
catch (Exception ex) {
ex.printStackTrace();
}
return doc;*/
}