An open API service indexing awesome lists of open source software.

https://github.com/gleidsonmt/blockcode

Block code for javafx applications
https://github.com/gleidsonmt/blockcode

Last synced: 3 months ago
JSON representation

Block code for javafx applications

Awesome Lists containing this project

README

        

# Block code for JavaFx examples

This code use an adaption from https://highlightjs.org/


Block code is a simple web view (javafx) that implements a highlight in its content.

🧬
```
|-- BlockCode (StackPane)
|-- Code (WebView)

```
### 👾 Example

```java
// Imperative style
BlockCode block = new BlockCode();
block.setTheme(Theme.GITHUB);
block.setCodeType(CodeType.JAVASCRIPT);
block.setContent("""
function hello() {
console.log('Hello')
};""");
block.build();

// Declarative style
BlockCode code = new BlockCode()
.theme(Theme.GITHUB)
.codeType(CodeType.JAVASCRIPT)
.content("function hello() { console.log('Hello') };")
.build();
```


example_block_code

```
|-- BlockCodeView (TabPane)
|-- Tab (Tab) 'java'
|-- BlockCode (StackPane)
|-- Code (WebView)
|-- Tab (Tab) 'FXML'
|-- BlockCode (StackPane)
|-- Code (WebView)
|-- Tab (Tab) 'Css'
|-- BlockCode (StackPane)
|-- Code (WebView)

```
### 👾 Example
```java
// Or using tabs
BlockCodeView block = new BlockCodeView();
block.setJavaCode("""
Button button = new Button("Cancel");
""");

block.setFXMLCode("""





""");

block.setCssCode("""
.button {
-fx-accent: red;
}
""");
```
### 🎆 The Result



### Setting copy event
```java
block.setOnCopying(e -> {
...
});
```

### Styling copy button
```css
.copy-button {
...
}

```