下面代码是一个模拟左右选择器的swing,其中左边面板中加入了很多个复选框的测试数据,不幸的是他们超出了规定的面板范围,求修正,谢谢
import java.awt.Checkbox;
import java.awt.Font;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JPanel;
import javax.swing.ScrollPaneConstants;
public class ChooseCSSFrame extends javax.swing.JDialog {
private static final long serialVersionUID = 1L;
private Font currentFont = new java.awt.Font("新宋体", 0, 14);
private Font currentFont4PanelTitle = new java.awt.Font("新宋体", 0, 12);
private javax.swing.JButton addNoteButton;
private javax.swing.JButton addAllButton;
private javax.swing.JButton delNoteButton;
private javax.swing.JButton delAllButton;
private javax.swing.JButton sureButton;
private javax.swing.JButton cancelButton;
private javax.swing.JScrollPane showNoteJSPanel;
private javax.swing.JPanel showNotePanel;
private javax.swing.JPanel donnotShowNotePanel;
private javax.swing.JPanel buttonPanel;
private List<String> cssList;
public ChooseCSSFrame(List<String> cssList) {
this.cssList = cssList;
initComponents();
}
private void initComponents() {
showNoteJSPanel = new javax.swing.JScrollPane(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
showNotePanel = new JPanel();
donnotShowNotePanel = new javax.swing.JPanel();
buttonPanel = new javax.swing.JPanel();
addNoteButton = new javax.swing.JButton();
addAllButton = new javax.swing.JButton();
delNoteButton = new javax.swing.JButton();
delAllButton = new javax.swing.JButton();
sureButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
showNoteJSPanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "显示的节点", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, currentFont4PanelTitle)); // NOI18N
showNotePanel.setLayout(new java.awt.GridLayout(cssList.size(), 1));
showNoteJSPanel.setViewportView(showNotePanel);
for (String note : cssList) {
showNotePanel.add(new Checkbox(note));
}
donnotShowNotePanel.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "不显示的节点",
javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, currentFont4PanelTitle)); // NOI18N
donnotShowNotePanel.setLayout(new java.awt.GridLayout());
addNoteButton.setFont(currentFont); // NOI18N
addNoteButton.setText("添加");
addNoteButton.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
addAllButton.setFont(currentFont); // NOI18N
addAllButton.setText("添加全部");
addAllButton.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
delNoteButton.setFont(currentFont); // NOI18N
delNoteButton.setText("删除");
delNoteButton.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
delAllButton.setFont(currentFont); // NOI18N
delAllButton.setText("删除全部");