HTMLDocument setBase - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for HTMLDocument setBase method.

This code example shows how to use the following methods:addStyle, getStyle, setBase
        tfText.setText(StringUtils.excerpt(aText, EXCERPT_SENTENCES, EXCERPT_MIN_CHARS, EXCERPT_MAX_CHARS));
        tfText.setEditable(false);
        tfText.setToolTipText("<html>" + aText);
 
        HTMLDocument doc = (HTMLDocument)tfText.getDocument();
        doc.setBase(article.getLink());
        Style def = doc.getStyle("default");
        doc.addStyle(TEXT_STYLE_NAME, def);
        UifUtilities.setFontAttributes(doc, TEXT_STYLE_NAME, articleConfig.getTextFont());
 
        setViewMode(config.getViewMode());
 
        layout = new FormLayout("5px, center:pref, 5px", "5px, pref, 5px, pref, 5px, pref, 5px");
        setLayout(layout);
 
        aImageURL = aImageURL == null ? config.getNoImageURL() : aImageURL;
        Dimension dim = modeToDimension(config.getViewMode());
        lbImage = new AsyncImagePanel(aImageURL, dim.width, dim.height,
            new ShadowBorder(COLOR_SHADOW_BORDER), article.isRead());
        setTextComponentsWidth(); 
6
CodeRank
This code example shows how to use the following methods:getDocumentProperties, setBase
		} 
	} 
 
	public void initImageLoader(HTMLDocument document) {
		try { 
			document.setBase(new URL(ImageLoaderCache.IMAGE_URL_PREFIX));
		} catch (MalformedURLException e) {
			log.error(e.getMessage());
		} 
		setContextResource(navigator.getCurrentResource());
		document.getDocumentProperties().put("imageCache", this);
	} 
 
 
	private String getResourceHref(String requestUrl) {
		String resourceHref = requestUrl.toString().substring(IMAGE_URL_PREFIX.length());
		resourceHref = currentFolder + resourceHref;
		resourceHref = FilenameUtils.normalize(resourceHref);
		// normalize uses the SYSTEM_SEPARATOR, which on windows is a '\' 
		// replace with '/' to make it href '/' 
6
CodeRank
This code example shows how to use the following methods:addDocumentListener, removeDocumentListener, setBase
		final SHTMLPanel noteViewerComponent = noteController.getNoteViewerComponent();
		if (noteViewerComponent == null) {
			return; 
		} 
		final HTMLDocument document = noteViewerComponent.getDocument();
		document.removeDocumentListener(mNoteDocumentListener);
		try { 
			final URL url = node.getMap().getURL();
			if (url != null) {
				document.setBase(url);
			} 
			else { 
				document.setBase(new URL("file: "));
			} 
		} 
		catch (final Exception e) {
		} 
		noteController.setDefaultFont();
		final String note = node != null ? NoteModel.getNoteText(node) : null;
		if (note != null) {

5
CodeRank
This code example shows how to use the following methods:removeDocumentListener, addDocumentListener, setBase
		final SHTMLPanel noteViewerComponent = noteController.getNoteViewerComponent();
		if (noteViewerComponent == null) {
			return; 
		} 
		final HTMLDocument document = noteViewerComponent.getDocument();
		document.removeDocumentListener(mNoteDocumentListener);
		try { 
			final URL url = node.getMap().getURL();
			if (url != null) {
				document.setBase(url);
			} 
			else { 
				document.setBase(new URL("file: "));
			} 
		} 
		catch (final Exception e) {
		} 
		noteController.setDefaultFont();
		final String note = node != null ? NoteModel.getNoteText(node) : null;
		if (note != null) {

5
CodeRank
This code example shows how to use the following methods:getStyleSheet, setBase
        SwingUtils.setPopupMenu(textPane, new JTextPanePopupMenu(textPane));
  
        final HTMLDocument document = (HTMLDocument) this.textPane.getDocument();
 
        // Set the base URL of the text pane 
        document.setBase(Main.class.getResource("templates/"));
         
        // Modify the body style so it matches the system font 
        final Font font = UIManager.getFont("Label.font");
        String bodyRule = "body { font-family: " + font.getFamily() + 
            "; font-size: " + font.getSize() + "pt; }";
        document.getStyleSheet().addRule(bodyRule);                
         
        final JScrollPane scrollPane = new JScrollPane(textPane);
        add(scrollPane);
 
        redraw(); 
    } 
 
    /** 
4
CodeRank
setBase Method Overview
Sets the location to resolve relative URLs against.
See Code Examples for other Java 8 HTMLDocument Methods: