Tuesday, 27 August 2013

Remove an element correctly in GridBagLayout

Remove an element correctly in GridBagLayout

jPanel1 = new JPanel();
GridBagLayout layout = new GridBagLayout();
jPanel1.setLayout(layout);
GridBagConstraints gbc = new GridBagConstraints();
filler = new JLabel();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 1;
gbc.weighty = 1;
jPanel1.add(filler, gbc);
Im trying to remove by doing jPanel1.remove(filler), and placing a new
JLabel in that position after that, but is clearly not working. What am i
doing wrong?
Thanks!

No comments:

Post a Comment