How to add two label in one gridbox?
-
23-09-2019 - |
Question
How can I add two label in the same grid box? e.g. in row 1, col 1 the will be 2 labels? The code below will add the label in two different grid.
JPanel chckBox = new JPanel(new GridLayout(1,8,3,3));
JLabel label1 = new JLabel("A");
JLabel label2 = new JLabel("B");
...
chckBox.add(label1);
chckBox.add(label2);
...
Solution
Put a JPanel
into that part of the grid and have the two labels as children of that panel (which can have its own layout manager).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow