java help with checkbox placement.

Status
Not open for further replies.
I am writing a desktop java program and I am having trouble with checkbox placement and a border with a label around it.

I want a group of 8 check boxes 2 rows of 4 very (one row on top of each other) that are as close together as possible without being distorted when checked.

Around this I want a tight border with a label.

I need 60 sets of this.

I can get the checkboxes correct using code and not a swing designer from eclipse but am not having luck with a border.

Coding like how I am doing it seems very tedious to do it 60 times, if there is a simpler way to do this please let me know.
 
I am writing a desktop java program and I am having trouble with checkbox placement and a border with a label around it.

I want a group of 8 check boxes 2 rows of 4 very (one row on top of each other) that are as close together as possible without being distorted when checked.

Around this I want a tight border with a label.

I need 60 sets of this.

I can get the checkboxes correct using code and not a swing designer from eclipse but am not having luck with a border.

Coding like how I am doing it seems very tedious to do it 60 times, if there is a simpler way to do this please let me know.

AWT, Swing, SWT, GWT or JavaFX?

Oops... didn't see swing designer

When I'm building a bunch of similar items, I create a builder method that takes appropriate values (i.e., an AbstractAction?). In this builder, set the default/preferred min/max sizes... Also, the used font/size (which is probably a bad practice considering the High DPI screens we're using these days. Won't scale right.)

As for alignment, you're gonna need to mess around with a GroupLayout or :gasp: a GridBagLayout to make the layout work the way you expect it. Sometimes, wrapping components in JPanel with BorderLayout and only using BorderLayout.NORTH and BorderLayout.SOUTH does what you want it to do.

If you want to group two or more check boxes, you'll need a JPanel to "wrap" them, then apply the border to that. You'll have to remove the default FlowLayout and use, as mentioned, gridbag or grouplayout.

Unless someone else could come up with a better solution.
 
Status
Not open for further replies.