グリッドバッグレイアウトで指定したパネルがあります。私は基本的に1列と4列を持っています。ラベルはデフォルトで中央に揃えられています。どのように私はそれらを左に揃えますか?JLabelをグリッドパネルレイアウトのパネルの左に揃えます。
private void addLabel(String name, int gridx, int gridy, int anchor){
gbc.gridx=gridx;
gbc.gridy=gridy;
JLabel label=new JLabel(name);
gbc.fill=GridBagConstraints.HORIZONTAL;
gbag.setConstraints(label, gbc);
panel1.add(label);
発信者回線は、次のとおりです。
gbc=new GridBagConstraints();
gbag=new GridBagLayout();
panlel1.setLayout(gbag);
addLabel(" Exemption type", 0, 0,anchor);
さらに、gbc.anchor = GridBagConstraints.WESTを設定すると、私のために働いた... – m13r