Skip to content

TextField: fixed extra margin when leading/trailing component or icon are present#1110

Open
DJ-Raven wants to merge 1 commit intoJFormDesigner:mainfrom
DJ-Raven:fixed-text-margin
Open

TextField: fixed extra margin when leading/trailing component or icon are present#1110
DJ-Raven wants to merge 1 commit intoJFormDesigner:mainfrom
DJ-Raven:fixed-text-margin

Conversation

@DJ-Raven
Copy link
Copy Markdown
Contributor

@DJ-Raven DJ-Raven commented Apr 1, 2026

This PR fixes an issue with TextField margins when using leading/trailing components or icons.

When no layout constraint is set and the JTextField column is 0, the layout uses the component’s preferred size. In this case, an extra horizontal margin becomes visible.

From reviewing the existing implementation, the left and right insets are reduced when leading/trailing components are present, but this is not reflected in the preferred size calculation.

This PR resolves the issue by updating getPreferredSize(JComponent c) to adjusted insets.

Before Fix

no-fix

After Fix

fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant