changeset 1943:763e8e77c468 default tip

swing
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 19 May 2025 17:19:23 -0600
parents a25b7963a792
children
files src/luan/modules/swing/Awt_container.luan src/luan/modules/swing/Component.luan
diffstat 2 files changed, 22 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/luan/modules/swing/Awt_container.luan	Mon May 19 14:53:04 2025 -0600
+++ b/src/luan/modules/swing/Awt_container.luan	Mon May 19 17:19:23 2025 -0600
@@ -62,6 +62,7 @@
 	if preferred_size~=nil then jcomponent.setPreferredSize(to_dimension(preferred_size)) end
 	local maximum_size = delete(props,"maximum_size")
 	if maximum_size~=nil then jcomponent.setMaximumSize(to_dimension(maximum_size)) end
+--[[
 	component.repaint = jcomponent.repaint
 	component.validate = jcomponent.validate
 	function component.add(el)
@@ -75,6 +76,7 @@
 			jcomponent.add(child.java)
 		end
 	end
+]]
 	function component.add_resize_listener(fn)
 		jcomponent.addComponentListener(newResizeListener(fn))
 	end
--- a/src/luan/modules/swing/Component.luan	Mon May 19 14:53:04 2025 -0600
+++ b/src/luan/modules/swing/Component.luan	Mon May 19 17:19:23 2025 -0600
@@ -107,13 +107,33 @@
 	function component.dont_gc(obj)
 		component._dont_gc[obj] = true
 	end
+--[[
 	function component.add(child)
 		jcomponent.add(child.java,child.constraints)
 	end
+]]
 	function component.scroll_into_view_vertically()
 		scrollIntoViewVertically(jcomponent)
 	end
 	component.set_layout = jcomponent.setLayout
+	local function changed()
+		jcomponent.revalidate()
+		jcomponent.repaint()
+	end
+	function component.add(el)
+		jcomponent.add(el.java,el.constraints)
+		changed()
+	end
+	function component.remove(el)
+		jcomponent.remove(el.java)
+		changed()
+	end
+	function component.add_all(list)
+		for _, child in ipairs(list) do
+			jcomponent.add(child.java)
+		end
+		changed()
+	end
 end
 Component.construct = construct