Swing - wrong setting of button array

Is there a way to have a collection of objects JButton

that are not in the standard "Grid" form? I am specifically going to create a set of buttons of different shapes and sizes, for example, the bottom two lines of the Microsoft calculator.

Here's an example of how I want the buttons to look like this:

Bottom two rows, Microsoft Calculator

+3


source to share


1 answer


GridBagLayout is the natural choice for the requested layout. You can distribute buttons evenly, span a range of cells, or even choose a size for each specific cell. Here's a good example .



+2


source







All Articles