annotate src/luan/modules/swing/Label.luan @ 1735:4b56eff90040 default tip

add hosting.html
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 02 Oct 2022 17:32:00 -0600
parents 915cb538e2a3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1616
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local set_metatable = Luan.set_metatable or error()
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 require "java"
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local JLabel = require "java:javax.swing.JLabel"
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local Label = {}
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local mt = {}
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12 function mt.__index(label,key)
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 error("'"..key.."' not defined")
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 end
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 function mt.__new_index(label,key,value)
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 error("'"..key.."' not defined")
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 end
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 function Label.new(text)
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 local jlabel = JLabel.new(text)
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 local label = { java = jlabel }
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 set_metatable(label,mt)
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 return label
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 end
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26
915cb538e2a3 start swing
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 return Label