這工作得很好:
import java.awt.EventQueue;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.FormLayout;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Example {
public Example() {
FormLayout layout =
new FormLayout("left:pref, 15px, center:pref, 15px, right:pref, 15px, fill:pref, 15px, pref",
"pref, 12px, pref, 4px, pref, 4px, pref, 4px, pref, 4px, pref");
JPanel panel = new JPanel(layout);
CellConstraints cc = new CellConstraints();
JCheckBox field = new JCheckBox("EDEX:", true);
panel.add(field, cc.xy(5, 3));
JFrame f = new JFrame();
f.setBounds(10, 10, 100, 100);
f.setDefaultCloseOperation(3);
f.getContentPane().add(panel);
f.setVisible(true);
}
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new Example();
}
});
}
}
告訴我們有關'CC更多的代碼',w沒有它工作正常。 btw:'JCheckBox'而不是'JCheckbox' – oliholz