ho riscritto un codice compilante
Con non funziona intendo dire i due campi di tipo label ai quali ho settato la dimensione a 80 non rimangono di dimensione 80 quando aumento o diminuisco la dimensione del JFrame
import javax.swing.*;
import java.awt.*;
public class Layout extends JFrame{
public Layout() {
JLabel fileNameLabel = new JLabel("Ciao");
JLabel languageNameLabel = new JLabel("Cane");
languageNameLabel.setSize(80, 20);
JLabel lineNumberLabel = new JLabel("Ciao");
lineNumberLabel.setSize(80, 20);
JPanel statusBarPanel = new JPanel();
statusBarPanel.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
c.weightx = 1;
c.gridx = 0;
c.gridy = 0;
c.fill = GridBagConstraints.HORIZONTAL;
statusBarPanel.add(fileNameLabel, c);
c.gridx = 1;
c.gridy = 0;
c.fill = GridBagConstraints.NONE;
statusBarPanel.add(languageNameLabel, c);
c.gridx = 2;
c.gridy = 0;
c.fill = GridBagConstraints.NONE;
statusBarPanel.add(lineNumberLabel, c);
getContentPane().add(statusBarPanel);
this.setSize(600, 800);
this.setVisible(true);
}
public static void main (String[] args) {
new Layout();
}
}