Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swing - Irregular button array layout

Is there some way to have a set of JButton objects that aren't in a standard 'Grid' shape? I'm specifically looking to make a set of buttons that are different shapes and sizes, like the bottom two rows of the Microsoft Calculator.

Here is an example of what I want the buttons to look like:

Bottom two rows, Microsoft Calculator

like image 781
Salmononius2 Avatar asked Sep 02 '26 09:09

Salmononius2


1 Answers

GridBagLayout is natural choice for requested layout. You can spread buttons evenly, occupy range of cells or even choose size for each particular cell. Here is good example.

like image 80
Alex Avatar answered Sep 03 '26 23:09

Alex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!