Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automate sizing of NodeSelector JComboBox #216

Merged
merged 1 commit into from
Feb 28, 2023

Conversation

bobjacobsen
Copy link
Contributor

This changes the handling of the JComboBox in org.openlcb.swing.NodeSelector so that it automatically sizes itself to the largest selection string available when the NodeSelector is created.

  • If there are no known nodes, a default of 70 spaces wide it used

  • The JComboBox does not resize if additional nodes are discovered after it's been created to prevent the GUI from moving around spontaneously.

@balazsracz
Copy link
Collaborator

I don't see any code to resize the combo box when there are nodes. The only code seems to be active when node count == 0.
So how does this work?

@bobjacobsen
Copy link
Contributor Author

A JComboBox by default has a preferred size that will hold its longest content. That's used by a pack() call during layout, so it'll be that size unless there are external constraints.

The previous code was overriding that behavior by always by setting a manual size. I removed that to allow the default behavior to work, setting it specifically only when there isn't any content. That's needed because the default-no-content size is 20 characters, smaller than our typical identifiers.

@balazsracz balazsracz merged commit 7dce671 into openlcb:master Feb 28, 2023
@bobjacobsen bobjacobsen deleted the nodeselector_sizing branch March 1, 2023 15:52
balazsracz added a commit that referenced this pull request Mar 10, 2023
…orepeat

* 'master' of github.com:openlcb/OpenLCB_Java:
  Address space improvements (#218)
  Config Node displays more info as needed (#217)
  Update default backup filename to id-name-softversion-date-time (#214)
  Automate sizing of NodeSelector JComboBox (#216)
  add EventID.toShortString() (#215)
  Allow NodeSelector user to specify length of ID string (#213)
  Hub - add separate options for sending / receiving line termination characters (#212)
  Hub Line Endings / GC Serial (#208)
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.

2 participants