List box highlight color

Can I control the highlight color of the selected item in a list? I see foreground and background only. Thanks.

Currently, no. You could use a Table with one column - you can control the selection color for the Table. I’ll add it as a feature request.

This is done for 3.1.6.


Is there a way that I can force the Selected Focus Border to be on around a particular item in a list box?

Can I do that somehow in a table?

In a table, can I hide the column header or assign it dynamically?


The focus border will be displayed if the list box has focus. You can programatically give a component focus by calling requestFocusInWindow on it, like this:

list = event.source.parent.getComponent("MyList") list.selectedIndex=2 list.requestFocusInWindow()

You cannot hide a column header, you can assign it dynamically by changing the column name of the underlying dataset.

You can change a column header programatically, but its pretty gnarly scripting. See this post for details: … .php?t=455

I had a screen where I wanted to hide columns dynamially, and used more of the Java Swing functions. Basically, I had a table of about 20 columns, but only certain columns need to be visible based on what the operator is doing (planning orders, monitoring the process, auditing the finished orders). For instance, I didn’t want to display things like “End Time” while they were planning orders. I could have used multiple tables instead, but I like the way I’ve got it working.

I’ll defer to Java Swing experts to come up with a better way of doing this, but in a nutshell this is what worked for me:

When the screen launches, I set the minWidth to 0 for the columns I may want to hide later:

t1=fpmi.gui.getParentWindow(event).getComponentForPath('Root Container.table1').getComponent(0).getComponent(0) 

col1 = t1.columnModel.getColumn(10) 

To hide a column, I set the max and preferred widths to 0:


col1 = t1.columnModel.getColumn(10) 

To make it visible, I set the max and preferred widths to new values:


col1 = t1.columnModel.getColumn(10) 

So, with buttons or a checkbox, individual columns can be easily hidden. The next thing I’m working on is storing the column widths in a file or table so I don’t have to use absolute values anywhere.

I’ll admit that the setMaxWidth(0) looks strange and that it looks like setPreferredWidth(0) should suffice, but I could not get consistent results otherwise.


I haven’t looked into it that much, but why don’t you use property bindings for your column names in the datasource clause? For example, you could have a checkbox with a dynamic property (string) that is the column name when it is selected, and blank otherwise. On the checkbox dynamic property ‘ColumnName’:if({Root Container.Checkbox.selected},"Column1, ","")and your dataset query:SELECT {Root Container.Checkbox.ColumnName} Column2 FROM myTable WHERE 1=1
You could also make a different SELECT query for each case (planning orders, monitoring the process, auditing the finished orders) and put it in a root container property to avoid using so much Jython.

I didn’t use that approach because I didn’t know what the implications would be on my “Table Customizer” properties. For instance, if I change my query to remove a column of data, doesn’t that remove the name I gave it in the Table Customizer too? At least, that’s what happened on an earlier attempt, but maybe I was doing it wrong. Instead, I leave all of the columns in the query and just make them zero width, which seems to maintain the custom column properties I made.


I just tested that now (version 3.1.6) with a checkbox driving one of my columns, and it doesn’t effect the settings of the other columns in the table customizer. If all you need to worry about is the column name, you can use the ‘as’ keyword to reassign those headers in the SQL SELECT statement. ie:SELECT SUM(individual_costs) as "Total Cost", minutes_to_produce as "Time" FROM final_products ...

The table component stores custom column configuration (custom header names, formats, etc) by the name of the underlying column. Suppose your query returns columns named A,B,C,D. Then you’ll have 4 custom column configurations stored. If you modify your query dynamically in the runtime to only return A,B,C, and later modify it again to have D again, D’s configuration will still be there. Its all about what columns were present when you saved your window. So, if you can have all columns present when you save your window, you’ll be fine. Just be careful about using preview mode with datasource traffic turned on.

Now, about hiding columns. Dynamic queries is a good way to go, if you can live with the behavior described above. Otherwise, scripting is a fine way to go too. The way you discovered, Step7, is fine if its working for you. The table component does have a setColumnWidth(idx,width) function that might make your code cleaner, but you still might have to set the minimumWidth as you were doing.

You also might want to experiment with something like this:

table = event.source.parent.getComponent("MyTable") col = table.getColumnAttributes("ColumnB") col.hidden = 1 table.columnAttributes = table.columnAttributes # forces re-load

But only do that if you can have all columns present when you save the table - the results will be odd if your column set is truly dynamic.

Hope this clears things up,

Thanks for the tips. It will make my tables look pretty sharp (and BDS, sorry for the thread hijack, but there was some stuff that overlapped with your questions).

… put it in a root container property to avoid using so much Jython.[/quote]

Mark me down as one of the guys who doesn’t mind Jython at all. In fact, Jython/Python is a blast. I recently had to come up with a way to import some machine code files and output them into something readable, and ended up doing the whole thing with Python. Once I got used to the concepts of lists, it was a breeze. I’m going to be pretty dangerous now… :slight_smile:

Python is indeed one of the more beautiful languages I’ve come across…