Directory

← Back

CodeLabel

Displays source code nicely formatted and colored

Author

Rating

Popularity

<100

A drop-in replacement for Label, formats and colorizes source code nicely.

CodeLabel uses the google-code-prettify library to do the heavy-lifting. An example can be seen by clicking the code example highlight - yes, this is the same component seen in both Sampler and Directory.

Sample code

package org.vaadin.codelabel;

import com.vaadin.Application;
import com.vaadin.ui.Label;
import com.vaadin.ui.Window;

public class CodeLabelDemo extends Application {
    @Override
    public void init() {
        Window mainWindow = new Window("CodeLabel Demo");
        Label label = new CodeLabel(
                "package org.vaadin.codelabel;\n"
                        + "\n"
                        + "import com.vaadin.Application;\n"
                        + "import com.vaadin.ui.*;\n"
                        + "\n"
                        + "public class CodeLabelDemo extends Application {\n"
                        + "        @Override\n"
                        + "        public void init() {\n"
                        + "                Window mainWindow = new Window(\"CodeLabel Demo\");\n"
                        + "                Label label = new CodeLabel(\"\");\n"
                        + "                mainWindow.addComponent(label);\n"
                        + "                setMainWindow(mainWindow);\n"
                        + "        }\n" + "}");
        mainWindow.addComponent(label);
        setMainWindow(mainWindow);
    }
}

Compatibility

(Loading compatibility data...)

Was this helpful? Need more help?
Leave a comment or a question below. You can also join the chat on Discord or ask questions on StackOverflow.

Version

Released
2010-01-22
Maturity
STABLE
License
Apache License 2.0

Compatibility

Framework
Vaadin 6.0+
Vaadin 7.0+ in 7.0.0
Browser
Internet Explorer
Internet Explorer
Internet Explorer
Firefox
Opera
Safari

Vaadin Add-on Directory

Find open-source widgets, add-ons, themes, and integrations for your Vaadin application. Vaadin Add-on Directory
The channel for finding, promoting, and distributing Vaadin add-ons.
Online