How-to
When popup calendar buttons are too small for touch panels
Short answer
The popup calendar's date-navigation buttons don't grow with the component, because a Swing panel and the buttons' maximum sizes hold them at their old rendered size; a propertyChange script that resizes the five buttons and their containing JPanel fixes it. Judge the fix in millimetres: rendered pixels × active display area ÷ resolution. On a 1280 × 800 panel with a 216 mm active area, 100-pixel buttons render at 16.9 mm and clear a 10 mm plant-floor target.
On this page
The Ignition Vision popup calendar gives a window date and time entry and behaves well on a mouse-driven PC. On a touch panel it fails in one specific place: widening the component grows most of the popup, but the four date-navigation buttons at the bottom never scale, so the row that steps between days and months stays far too small to press reliably. The fix is a propertyChange script that walks the component tree at runtime, finds the five buttons inside the popup, and resizes both the buttons and the JPanel that confines them. Setting the buttons' preferred size alone changes nothing, because the parent panel and the buttons' own maximum sizes hold the rendered geometry. Judge the result in physical units: a 10 mm rendered target is the number this article commits to for plant-floor popups, checked against the WCAG 2.5.8 floor of 24 × 24 CSS pixels.
What sets the physical size of a touch target #
A button's touch quality is its rendered size in millimetres, not the pixel value in the project. Convert with the panel's own datasheet numbers:
physical width (mm) = button width (px) × active display width (mm) ÷ horizontal resolution (px)
and use the matching height figures for button height. With display scaling at 100 percent, one Vision component pixel, one screen pixel and one CSS pixel coincide, so pixel-based rules transfer directly; at other scales, verify on the running client.
Two reference points. WCAG 2.5.8 Target Size (Minimum), a Level AA success criterion, requires a pointer-input target of at least 24 × 24 CSS pixels, with a few defined exceptions such as an undersized target whose 24-pixel clearance circle touches no neighbouring target. Mobile guidance commonly asks for 44 × 44 pixel targets, and target-size discussions put the defensible lower bound around 7 mm — 20 pt, roughly 27 CSS pixels. For an HMI popup pressed by hurried or gloved operators I design to 10 mm rendered, close to the 44-pixel rule's physical intent, and treat anything under 7 mm as a fail.
The same conversion decides sizing HMI touch buttons in a dense button matrix: the rendered millimetres decide everywhere, not the configured pixel size.
Why widening the calendar leaves the bottom row small #
Two couplings cause it. First, the popup's geometry normally follows the calendar component's width, so widening the field widens the popup — that scales most controls but means an oversized date field is the only knob it offers. Second, the four navigation buttons live in their own JPanel with a BoxLayout, and Swing layout managers negotiate sizes rather than obeying them: setPreferredSize is a request, and the Java Swing tutorial documents that components give hints through getMinimumSize, getPreferredSize and getMaximumSize. In the tested calendar, changing one button's preferred size alone left its rendered height at 32 pixels; the parent panel's preferred size and the buttons' maximum size were the binding constraints.
Height misbehaves the same way — enlarge only the panel and the panel grows while the buttons stay — so set both constraints together and read each container's live bounds from its string output when something still refuses to move.
Walk the component tree before resizing anything #
The calendar is a PMIDateTimeSelector whose internals hold date-selector panels and Swing containers several levels down; a direct lookup at the first child level finds only some of them. Discover before you resize, and treat the counts, labels and nesting below as what one inspection found — confirm them in your own client rather than assume them.
Run this in the Vision client or client preview, with Calendar replaced by your component's name in the window:
def walk(container, depth):
for item in container.getComponents():
print type(item), str(item)
walk(item, depth + 1)
walk(event.source.parent.getComponent('Calendar'), 0)
The walk prints every class, and each component's string carries its live bounds — the inspected panel reported 123x32 with a javax.swing.BoxLayout, which is where the 32-pixel height showed. In that inspection the popup held precisely five JButton objects: four navigation buttons labelled <<, <, > and >>, and one OK button beside the panel that parents the four. Re-run the walk on your build and base every edit on what it prints.
The resize script, step by step #
The script derives the button size from the calendar width because the popup stays coupled to it: five equal controls across the popup means one fifth each, written as the 0.2 factor, and the four navigation buttons share one panel at four fifths. A calendar 500 pixels wide gives int(500 × 0.2) = 100-pixel buttons; the panel then takes 4 × 100 = 400 pixels, and 400 + 100 = 500 checks against the calendar width.
- Open the window in the Vision client or client preview at the panel's native resolution.
- Attach a propertyChange script to the popup calendar component, gated on componentRunning so it runs once the component is live.
- Reach the popup through the calendar's internal popup field by reflection, then walk it recursively and collect every JButton.
- Take the parent of any non-OK button; that JPanel is the navigation row.
- Compute newWidth as one fifth of the calendar width and set each button's height equal to it for square targets.
- Set both the preferred and the maximum size on all five buttons, then set the navigation panel's preferred size to 4 × newWidth by newHeight.
- Save, open the popup, rerun the walk, and read each JButton's string: the width-by-height pair should read 100x100 for a 500-pixel calendar.
if event.propertyName == 'componentRunning':
from java.awt import Dimension
popupCalendar = event.source # the popup calendar component
newWidth = int(float(popupCalendar.width) * 0.2) # five buttons: one fifth each
newHeight = newWidth # square targets
def getJButtons(container):
found = []
for component in container.getComponents():
if 'JButton' in str(component.__class__):
found.append(component)
else:
found.extend(getJButtons(component))
return found
popupField = popupCalendar.getClass().getDeclaredField('popup')
popupField.setAccessible(True)
popup = popupField.get(popupCalendar)
jbuttons = getJButtons(popup)
buttonPanel = next((button.parent for button in jbuttons
if button.text != 'OK'), None)
for button in jbuttons:
button.setPreferredSize(Dimension(newWidth, newHeight))
button.setMaximumSize(Dimension(newWidth, newHeight))
buttonPanel.setPreferredSize(Dimension(4 * newWidth, newHeight))
If the OK button stays small on your build, the walk tells you which container parents it; give that container the same preferred-size treatment. The square-button choice and the 0.2 fraction both come from the discovered five-button layout — recount and recompute if your tree differs. After resizing, check the labels still fit inside their new buttons.
Worked example: the buttons in millimetres #
Take a 1280 × 800 panel whose datasheet gives a 216 × 135 mm active area — illustrative figures typical of a 10.1-inch 16:10 display; substitute your own datasheet values into the same arithmetic. Pitch: 216 ÷ 1280 = 0.169 mm per pixel horizontally and 135 ÷ 800 = 0.169 mm per pixel vertically. Square pixels agree across both axes; if yours do not, recheck the datasheet before trusting either number.
The script's 100-pixel buttons render at 100 × 0.169 = 16.9 mm square. Against the reference points: WCAG 2.5.8's 24-pixel floor is 24 × 0.169 = 4.1 mm on this panel, while the same 24 CSS pixels give 24 × 0.265 = 6.4 mm on a 96-dpi office monitor — pixel rules silently shrink on finer-pitch panels, which is why the check runs in millimetres. The 44-pixel mobile rule lands at 44 × 0.169 = 7.4 mm here, at the 7 mm lower bound rather than the 11.6 mm it means on an office screen; keeping that intent needs 11.6 ÷ 0.169 ≈ 69 pixels, so set 70, which is 70 × 0.169 = 11.8 mm.
Decision: ship the navigation row at 100 pixels — 16.9 mm, more than twice the 7 mm bound and more than four times the WCAG floor on this panel. Where the popup genuinely runs out of room, 60 pixels is the smallest I would sign off on a plant floor, at 60 × 0.169 = 10.1 mm, and nothing goes below the 24-pixel floor. Working backwards from a target: pixels = target mm × resolution ÷ active area = 10 × 1280 ÷ 216 = 59.3, rounded up to 60.
Picking among the three fixes #
| Approach | What changes | Trade-off |
|---|---|---|
| Widen the calendar component | Most popup controls grow with the field width | No scripting, but the navigation row stays small and an oversized field distorts the window |
| Resize the buttons and their panel from the field width | The five buttons and the navigation panel scale with the calendar | Fixes the row; sizes stay coupled to the field width |
| Resize the popup when it opens | Popup and buttons sized independently of a compact field | Best fit for a tight window; relies on reflective access to the same internal popup object |
If the window can afford a wider date field, use the script above — fewest unknowns and no extra coupling. If the field must stay compact, keep it narrow and add the popup-resize variant: with the same reflective popup handle, size the popup itself when it becomes visible instead of deriving every dimension from the field width, then re-verify the millimetre result on your deployed version. Widening alone is a quick demonstration of the coupling, not a fix.
Version and upgrade limits #
The nested tree this technique drives is not part of the component's documented configuration surface, so treat the popup field name, the button labels and the nesting as facts to re-discover rather than constants: run the walk again after every Ignition upgrade. One operational note: if date entry gates a batch or quality record, test the enlarged buttons with the thickest gloves actually used at the station before calling the fix done.
Questions asked
Does Windows display scaling affect the pixel-to-millimetre check?
Yes. Above 100 percent scaling, one component pixel lands on more than one screen pixel, so buttons render larger than the on-paper conversion suggests, while text and icons can blur. Run the client at the deployed scale, open the popup, and measure the finished buttons on the glass before signing off the size.
My calendar's popup has a different button count — what changes in the script?
Only the arithmetic. Divide one by the count your discovery walk finds and use that fraction for newWidth, and give the navigation panel one button's width per button it holds — four navigation buttons need 4 times newWidth, five would need 5 times. Confirm the count and grouping from the printed class and text list before hard-coding any fraction.
Is there an alternative to scripting the Vision component?
Yes. In Perspective, any view can be called as a popup, so the equivalent control is your own date-entry view with buttons sized to the panel's touch target. In Vision, a popup window with large day, month and year buttons writing to the same property works without touching the internal component tree, at the cost of building the control yourself.
Will the script survive an Ignition upgrade?
Treat it as unverified until rerun. The popup field, the button labels and the nesting are internal implementation details rather than a documented interface, and they can move between versions. Keep the discovery walk in the project, run it after each upgrade, and correct the field name or button texts if the printed tree no longer matches what the script expects.