Table Column Attributes Data Binding to another table

I have a 4 Tables with the same Columns Qty and Names. i would like to see if it is possible to bind the "Column Attributes Data" of a table to another table "Column Attributes Data" , so that they are Bind and the same , TABLE 1 to TABLE 2, TABLE 3 AND TABLE 4. meaning that if i adjust the width of a column on TABLE 1 . the other TABLES adjust the same .

so that the operator and designer does not need to adjust Table columns to make them match .
here is a screenshot of how I display the tables in window. any ideas?

Are these Table components or Power Table components?

Table components.

I'm not sure how you could bind it because the attributes data property is not a bindable property on the table. Also, the attributes data propertyChange event won't occur outside of the designer. You could play around with developing a column model listener to synchronize the columns. Here's a quick example to get you started:

# Written for the table's propertyChange event handler
# Runs only once at initialization when the window is first opened
# Won't run in designer unless preview mode is on prior to the window being opened
if event.propertyName == 'componentRunning':

	# Implement a custom table model listener class
	from javax.swing.event import TableColumnModelListener
	class ColumnModelListener(TableColumnModelListener):
		def __init__(self):
			pass
		def columnSelectionChanged(self, event):
			pass
		
		# If adding, removing, and moving columns is allowed,
		# ...develop the next three methods to synchronize that
		def columnMoved(self, event):
			pass
		def columnAdded(self, event):
			pass
		def columnRemoved(self, event):
			pass
			
		# Synchronize the column widths here:
		def columnMarginChanged(self, event):
			# Get the current widths of the top table
			widths = [column.width for column in event.source.columns]
			
			# I had to add this to ensure the columns in my tables had an equal range of motion
			# column.minWidth = 0
							
			#Iterate through the other tables and syncronize the widths
			for table in [tableTwo, tableThree, tableFour]:
				self.setColumnWidths(table, widths)

		# Create a custom method within the class for setting the widths of each table
		# ...so there are not four copies of the same code for each table
		def setColumnWidths(self, table, widths):
			for index, column in enumerate(table.columnModel.columns):
				column.minWidth = 0
				column.preferredWidth = widths[index]
	
	# Assign the table components to unambiguous variables for use by the listener
	tableOne = event.source.parent.getComponent('Table 1').table
	tableTwo = event.source.parent.getComponent('Table 2').table
	tableThree = event.source.parent.getComponent('Table 3').table
	tableFour = event.source.parent.getComponent('Table 4').table
	
	# Create an instance of the listener and assign it to the table
	listener = ColumnModelListener()
	tableOne.columnModel.addColumnModelListener(listener)

Result:
Screen Recording 2024-02-01 at 9.48.13 AM

Edit: Removed improperly placed column.minWidth

4 Likes