I imagine that this could probably be done by extending the DataSetListCellRenderer class in some way. This looks like an interesting problem, so if you figure it out, please let me know; I'm interested to see how you do it.
Edit: After looking at this, I believe the crossed out statement above to be wrong. The JTable is accessible directly, so modifying the column model in some way is probably more appropriate.
@Micah_Carr, your problem could probably be solved by simply disabling the horizontal scroll bar. Here is a script I've developed that accomplishes this:
from com.inductiveautomation.factorypmi.application.components.combobox import TableComboBoxPopup
from javax.swing import JTable, JScrollPane, JViewport
#Can be launched from a button for testing but belongs in the parent window's internalFrameOpened event handler
dropdown = system.gui.getParentWindow(event).getComponentForPath('Root Container.Dropdown')
def getPopup():
ui = dropdown.getUI()
if ui is not None:
for child in range(ui.getAccessibleChildrenCount(dropdown)):
component = ui.getAccessibleChild(dropdown, child)
if isinstance(component, TableComboBoxPopup):
return component
def getScrollPane():
popup = getPopup()
if popup is not None:
for component in popup.getComponents():
if isinstance(component, JScrollPane):
return component
def getViewport():
scrollPane = getScrollPane()
if scrollPane is not None:
for component in scrollPane.getComponents():
if isinstance(component, JViewport):
return component
def getTable():
viewport = getViewport()
if viewport is not None:
for component in viewport.getComponents():
if isinstance(component, JTable):
return component
scrollPane = getScrollPane()
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER)
table = getTable()
table.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN)
The above code also sets the sets the auto resize policy for the table.
Edit: Further experimentation has revealed that changes to the table and scrollpane are remembered by the component for the duration of the session, so it is not necessary for a listener to reapply the scrollbar policy or auto resize policy every time the dropdown is opened. I've refactored the above script to be applied once and only once when the window is initially opened, and I've eliminated the listener entirely.