JBrowser Source Code Files

JBrowser Source Code Files are provided in the source package file.

You can download JBrowser source package as described in the previous tutorial and go to the "src" sub-folder to view Source Code files.

You can also browse JBrowser Source Code files below:

✍: FYIcenter

org/mozilla/browser/impl/components/JMultiLineLabel.java

package org.mozilla.browser.impl.components;

import java.util.Vector;

import javax.swing.JLabel;

/**
 * Implements a JLabel-like component, that is capable
 * to display several lines of text
 */
public class JMultiLineLabel extends JLabel
{

    private static final long serialVersionUID = 1L;

    public void setText(String s) {
        if (s == null) s = ""; //$NON-NLS-1$
        String lines[] = breakupLines(s);
        StringBuffer sb = new StringBuffer();
        sb.append("<html>"); //$NON-NLS-1$
        for (int i=0; i<lines.length; i++) {
            if (i>0) sb.append("<br>"); //$NON-NLS-1$
            sb.append(lines[i]);
        }
        sb.append("</html>"); //$NON-NLS-1$
        super.setText(sb.toString());
    }

    private static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
    private static int LINE_SEPARATOR_LEN = LINE_SEPARATOR.length();

    @SuppressWarnings("unchecked") //$NON-NLS-1$
    public static String[] breakupLines(String text) {
        int len = text.length();
        if (len == 0) return new String[] {""}; //$NON-NLS-1$
        else {
            Vector data = new Vector(10);
            int start=0;
            int i=0;
            while (i<len) {
                if (text.startsWith(LINE_SEPARATOR,i)) {
                    data.addElement(text.substring(start,i));
                    start=i+LINE_SEPARATOR_LEN;
                    i=start;
                }
                else if (text.charAt(i)=='\n') {
                    data.addElement(text.substring(start,i));
                    start=i+1;
                    i=start;
                }
                else { i++; }
            }

            if (start != len) {
                data.addElement(text.substring(start));
            }

            int numlines = data.size();
            String lines[] = new String[numlines];
            data.copyInto(lines);
            return lines;
        }
    }

}

org/mozilla/browser/impl/components/JMultiLineLabel.java

Or download all of them as a single archive file:

File name: jbrowser-1.9-fyi.zip
File size: 625318 bytes
Release date: 2022-11-10
Download 

 

Downloading JBrowser 1.9

Download and Install JBrowser Source Package

Download and Review JBrowser

⇑⇑ FAQ for JBrowser

2017-07-17, 8391👍, 1💬