First off, I apologize for the long post, I just wanted to be clear and show you my issue so it can better be resolved.
I have the following code:
JPanel panelCard = new JPanel();
String[] cards = {"VISA", "MASTERCARD", "DISCOVER"};
JComboBox cardType = new JComboBox(cards);
panelCard.add(cardType);
GroupLayout layout2 = new GroupLayout(panelCCInfo);
panelCCInfo.setLayout(layout2);
layout2.setAutoCreateGaps(true);
layout2.setAutoCreateContainerGaps(true);
GroupLayout.SequentialGroup hGroup2 = layout2.createSequentialGroup();
hGroup2.addGroup(layout2.createParallelGroup()
.addComponent(cardName)
.addComponent(cardNumber)
.addComponent(expDate));
hGroup2.addGroup(layout2.createParallelGroup()
.addComponent(cardNameField)
.addComponent(cardNumberField)
.addComponent(expDateField));
hGroup2.addGroup(layout2.createParallelGroup()
.addComponent(panelCard));
layout2.setHorizontalGroup(hGroup2);
GroupLayout.SequentialGroup vGroup2 = layout2.createSequentialGroup();
vGroup2.addGroup(layout2.createParallelGroup(Alignment.BASELINE)
.addComponent(cardName)
.addComponent(cardNameField));
vGroup2.addGroup(layout2.createParallelGroup(Alignment.BASELINE)
.addComponent(cardNumber)
.addComponent(cardNumberField));
vGroup2.addGroup(layout2.createParallelGroup(Alignment.BASELINE)
.addComponent(expDate)
.addComponent(expDateField)
.addComponent(panelCard));
layout2.setVerticalGroup(vGroup2);
panelCheckout.add(panelCCInfo, BorderLayout.CENTER);
And when I run it, it displays this window:
But I would like to achieve this:
The problem occurs when I try to add a 3rd vertical group with the panelCard in the code:
hGroup2.addGroup(layout2.createParallelGroup().addComponent(panelCard));
It would seem that the 2 text field are cut off because of this, but I dont want it cut off.
What can I do to achieve the 2nd picture?
Thanks so much!