Method Signatures and Parameters | |
Jt.code(String body) | body (String) The string to display as code or monospace text. |
Chainable builder methods | |
language(String language) | The language that the code is written in, for syntax highlighting. This defaults to For a list of available language values, see list on prismjs documentation. |
lineNumbers(boolean lineNumbers) | An optional boolean indicating whether to show line numbers to the left of the code block. This defaults to |
wrapLines(boolean wrapLines) | An optional boolean indicating whether to wrap lines. This defaults to |
height(String height) | The height of the code block element. This can be one of the following:
|
height(int heightPixels) | The height of the element in pixels. The element will have a fixed height. If the content is larger than the specified height, scrolling is enabled. |
width(String width) | The width of the element. This can be one of the following:
|
width(int widthPixels) | The width of the element in pixels. The element will have a fixed width. If the specified width is greater than the width of the parent container, the width of the element matches the width of the parent container. |
key(String key) | A string to use as the unique key for the widget. If this is omitted, a key will be generated for the widget based on its content. No two widgets may have the same key. |
No description | |
use() | Put the widget in the app, in the |
use(JtContainer container) | Put the widget in the app, in the provided container. |
Examples
Simple code block
import tech.catheu.jeamlit.core.Jt;
public class CodeApp {
public static void main(String[] args) {
Jt.code("public class HelloWorld {}").use();
}
}
Multi-line code with syntax highlighting
import tech.catheu.jeamlit.core.Jt;
public class MultilineCodeApp {
public static void main(String[] args) {
String pythonCode = """
import numpy as np
a = np.arange(15).reshape(3, 5)
""";
Jt.code(pythonCode).language("python").use();
}
}
Still have questions?
Go to our discussions forum for helpful information and advice from Jeamlit experts.