我在GridBagLayout中使用ProgressBar。在布局之外,设置边界非常有效。在GridBagLayout中,我无法进行任何调整。我该怎么办?
base[i] = new JPanel();
base[i].setLayout(gbl);
progressBar[i] = new JProgressBar();
progressBar[i].setForeground(Color.GREEN);
progressBar[i].setValue(s1.getInBesitz().get(i).getAktKp() * 100 / s1.getInBesitz().get(i).getMaxKp());
progressBar[i].setBounds(110, 280, 180, 5);
if (progressBar[i].getValue() < 50) {
progressBar[i].setForeground(Color.YELLOW);
if (progressBar[i].getValue() < 25) {
progressBar[i].setForeground(Color.RED);
}
}
gbc.gridx = 1;
gbc.gridy = 5;
gbc.fill = GridBagConstraints.NONE;
base[i].add(progressBar[i], gbc);