# Using the @FXML annotations in Kotlin to get at FXML

**URL:** <https://discuss.kotlinlang.org/t/using-the-fxml-annotations-in-kotlin-to-get-at-fxml/277>\
**Category:** Uncategorized\
**Created:** [March 16, 2015, 3:37am UTC](https://discuss.kotlinlang.org/t/using-the-fxml-annotations-in-kotlin-to-get-at-fxml/277 "2015-03-16T03:37:06Z")\
**Posts on this page:** 1\
**Showing post:** 13

<div class="post-metadata">

**Author:** ![pablow91](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.kotlinlang.org/pablow91/32/1516_2.png) [@pablow91](https://discuss.kotlinlang.org/u/pablow91)\
**Post date:** [March 27, 2015, 10:08am UTC](https://discuss.kotlinlang.org/t/using-the-fxml-annotations-in-kotlin-to-get-at-fxml/277/13 "2015-03-27T10:08:20Z")

</div>

Hi.

I think that using **Delegates.notNull()** will not work without doing some additional “magic”.

Lets says that we have this declaration

> FXML var tabPane: TabPane by Delegates.notNull()

At **Kotlin Bytecode** we can see that **tabPane** is converted into **field\_name$delegate** and it's type is migrated to **ReadWriteProperty**. To set TabPane it is required to invoke **setTabPane** method which **FXMLLoader** will not do.

I think that in order to make FXML annotaton works we(community) have to create custom **FXMLLoader** and maybe some custom **Delegator** (witch allow make FXML fields as values not variables).

In my opinion someting like this should be a nice way to bind FXML components within controller class:

> val tabPane: TabPane by bindFXML()

Where **bindFXML()** should be _initialized_ by custom **FXMLLoader**

I will try do some proof-of-concept in few next days.

---

_[View the full topic](https://discuss.kotlinlang.org/t/using-the-fxml-annotations-in-kotlin-to-get-at-fxml/277)._
