我有两个JCheckBox的和一个JEditorPane。我要寻找的输出作为下如何使两个复选框在Swing中彼此相邻?
但我当前的代码是有点乱对此我不能
private void createContents()
{
JEditorPane license;
JCheckBox confirmBox;
JCheckBox declineBox;
license = new JEditorPane("text/html", "");
license.setText (buildEulaText());
license.setEditable(false);
confirmBox = new JCheckBox("I accept.", false);
declineBox = new JCheckBox("I decline.", false);
add(license, BorderLayout.CENTER);
add(confirmBox, BorderLayout.SOUTH);
add(declineBox, BorderLayout.NORTH); //I know this is wrong
}
需要帮助。 在此先感谢。
注意:这些应该是单选按钮,而不是复选框。或者一个复选框会做(检查是“我接受”,而不是检查是“我拒绝”)。使用两个复选框意味着您允许用户同时接受和拒绝。 – RealSkeptic
@RealSkeptic,我接受了我的错误并更正了它。它是单选按钮。谢谢 –