写代码最烦搞前台相关的东西了,非常的受不鸟。之前学的时候,经常遇到这个不显示那个不出现之类的问题。
工作后本以为以后不可能用swing了,没想到啊,新工作分到了cs组泪奔
大家给看看,我想在没个list里加2个checkbox,用于全选和反选,咋就显示不出来呢?
public class OptCalbeConnDlg extends JDialog{
private JScrollPane paneA;
private JScrollPane paneB;
private JScrollPane connPane;
private JButton connBtn = new JButton();
private JButton breakBtn = new JButton();
private JButton confirmBtn = new JButton();
private DefaultListModel listModelA;
private DefaultListModel listModelB;
private DefaultListModel connListModel;
private JList listA = null;
private JList listB = null;
private JList connList = null;
private JLabel fiberALbl = new JLabel("A端光缆:", SwingConstants.RIGHT);
private JLabel fiberZLbl = new JLabel("Z端光缆:", SwingConstants.RIGHT);
private JTextField fiberATxt = new JTextField();
private JTextField fiberZTxt = new JTextField();
private OptCoresNumManage coresNum = new OptCoresNumManage();
private JCheckBox allCheckBox = new JCheckBox("全选");
private JCheckBox unCheckBox = new JCheckBox("反选");
private JPanel checkPanel = new JPanel();
public OptCalbeConnDlg(){
initGUI();
}
public void initGUI(){
paneA = new JScrollPane();
paneB = new JScrollPane();
connPane = new JScrollPane();
paneA.add(allCheckBox);
paneB.add(checkPanel);
connPane.add(checkPanel);
getContentPane().setLayout(null);
getContentPane().add(paneA);
getContentPane().add(paneB);
getContentPane().add(connPane);
this.setTitle("光缆接续");
checkPanel.add(allCheckBox);
checkPanel.add(unCheckBox);
fiberALbl.setBounds(30, 10, 80, 28);
fiberZLbl.setBounds(30, 35, 80, 28);
fiberATxt.setBounds(120, 10, 350, 23);
fiberZTxt.setBounds(120, 35, 350, 23);
fiberALbl.setForeground(Color.BLUE);
fiberZLbl.setForeground(Color.BLUE);
fiberATxt.setEditable(false);
fiberZTxt.setEditable(false);
/*fiberATxt.setText(fiberA.getCode());
fiberZTxt.setText(fiberB.getCode());*/
fiberATxt.setText("sdgfasdfasgagsgfasfesfe");
fiberZTxt.setText("932dj903kjdjsoaewoid93kdjsj");
fiberATxt.setBackground(Color.getHSBColor(255, 204, 204));
fiberZTxt.setBackground(Color.getHSBColor(255, 204, 204));
getContentPane().add(fiberALbl);
getContentPane().add(fiberZLbl);
getContentPane().add(fiberATxt);
getContentPane().add(fiberZTxt);
listModelA = new DefaultListModel();
listModelB = new DefaultListModel();
connListModel = new DefaultListModel();
/*List noConnListA = coresNum.getCoresList(freeGroupA.getCode());
List noConnListB = coresNum.getCoresList(freeGroupB.getCode());
for(int i = 0; i < noConnListA.size(); i++){
listModelA.addElement(noConnListA.get(i));
}
for(int i = 0; i < noConnListB.size(); i++){
listModelB.addElement(noConnListB.get(i));
}*/
listA = new JList(listModelA);
listB = new JList(listModelB);
connList = new JList(connListModel);
paneA.setBounds(30, 60, 150, 180);
paneA.setBorder(BorderFactory.createTitledBorder("A端纤芯列表"));
paneB.setBounds(320, 60, 150, 180);
paneB.setBorder(BorderFactory.createTitledBorder("Z端纤芯列表"));
connPane.setBounds(30, 250, 310, 180);
connPane.setBorder(BorderFactory.createTitledBorder("熔接关系"));
paneA.setViewportView(listA);
paneB.setViewportView(listB);
connPane.setViewportView(connList);
getContentPane().add(connBtn);
connBtn.setText(">>连接<<");
connBtn.setBounds(210, 130, 90, 28);
connBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
connBtnActionPerformed(evt);
}
});
getContentPane().add(breakBtn);
breakBtn.setText("<<-断开->>");
breakBtn.setBounds(360, 300, 100, 28);
breakBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
breakBtnActionPerformed(evt);
}
});
confirmBtn = new JButton("确定");
getContentPane().add(confirmBtn);
confirmBtn.setBounds(360, 360, 100, 28);
confirmBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
confirmBtnActionPerformed(evt);
}
});
pack();
SwingUtils.configDialogToCenter(this, 500);
setSize(500, 470);
this.setResizable(false);
}
}
工作后本以为以后不可能用swing了,没想到啊,新工作分到了cs组泪奔
大家给看看,我想在没个list里加2个checkbox,用于全选和反选,咋就显示不出来呢?
public class OptCalbeConnDlg extends JDialog{
private JScrollPane paneA;
private JScrollPane paneB;
private JScrollPane connPane;
private JButton connBtn = new JButton();
private JButton breakBtn = new JButton();
private JButton confirmBtn = new JButton();
private DefaultListModel listModelA;
private DefaultListModel listModelB;
private DefaultListModel connListModel;
private JList listA = null;
private JList listB = null;
private JList connList = null;
private JLabel fiberALbl = new JLabel("A端光缆:", SwingConstants.RIGHT);
private JLabel fiberZLbl = new JLabel("Z端光缆:", SwingConstants.RIGHT);
private JTextField fiberATxt = new JTextField();
private JTextField fiberZTxt = new JTextField();
private OptCoresNumManage coresNum = new OptCoresNumManage();
private JCheckBox allCheckBox = new JCheckBox("全选");
private JCheckBox unCheckBox = new JCheckBox("反选");
private JPanel checkPanel = new JPanel();
public OptCalbeConnDlg(){
initGUI();
}
public void initGUI(){
paneA = new JScrollPane();
paneB = new JScrollPane();
connPane = new JScrollPane();
paneA.add(allCheckBox);
paneB.add(checkPanel);
connPane.add(checkPanel);
getContentPane().setLayout(null);
getContentPane().add(paneA);
getContentPane().add(paneB);
getContentPane().add(connPane);
this.setTitle("光缆接续");
checkPanel.add(allCheckBox);
checkPanel.add(unCheckBox);
fiberALbl.setBounds(30, 10, 80, 28);
fiberZLbl.setBounds(30, 35, 80, 28);
fiberATxt.setBounds(120, 10, 350, 23);
fiberZTxt.setBounds(120, 35, 350, 23);
fiberALbl.setForeground(Color.BLUE);
fiberZLbl.setForeground(Color.BLUE);
fiberATxt.setEditable(false);
fiberZTxt.setEditable(false);
/*fiberATxt.setText(fiberA.getCode());
fiberZTxt.setText(fiberB.getCode());*/
fiberATxt.setText("sdgfasdfasgagsgfasfesfe");
fiberZTxt.setText("932dj903kjdjsoaewoid93kdjsj");
fiberATxt.setBackground(Color.getHSBColor(255, 204, 204));
fiberZTxt.setBackground(Color.getHSBColor(255, 204, 204));
getContentPane().add(fiberALbl);
getContentPane().add(fiberZLbl);
getContentPane().add(fiberATxt);
getContentPane().add(fiberZTxt);
listModelA = new DefaultListModel();
listModelB = new DefaultListModel();
connListModel = new DefaultListModel();
/*List noConnListA = coresNum.getCoresList(freeGroupA.getCode());
List noConnListB = coresNum.getCoresList(freeGroupB.getCode());
for(int i = 0; i < noConnListA.size(); i++){
listModelA.addElement(noConnListA.get(i));
}
for(int i = 0; i < noConnListB.size(); i++){
listModelB.addElement(noConnListB.get(i));
}*/
listA = new JList(listModelA);
listB = new JList(listModelB);
connList = new JList(connListModel);
paneA.setBounds(30, 60, 150, 180);
paneA.setBorder(BorderFactory.createTitledBorder("A端纤芯列表"));
paneB.setBounds(320, 60, 150, 180);
paneB.setBorder(BorderFactory.createTitledBorder("Z端纤芯列表"));
connPane.setBounds(30, 250, 310, 180);
connPane.setBorder(BorderFactory.createTitledBorder("熔接关系"));
paneA.setViewportView(listA);
paneB.setViewportView(listB);
connPane.setViewportView(connList);
getContentPane().add(connBtn);
connBtn.setText(">>连接<<");
connBtn.setBounds(210, 130, 90, 28);
connBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
connBtnActionPerformed(evt);
}
});
getContentPane().add(breakBtn);
breakBtn.setText("<<-断开->>");
breakBtn.setBounds(360, 300, 100, 28);
breakBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
breakBtnActionPerformed(evt);
}
});
confirmBtn = new JButton("确定");
getContentPane().add(confirmBtn);
confirmBtn.setBounds(360, 360, 100, 28);
confirmBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) {
confirmBtnActionPerformed(evt);
}
});
pack();
SwingUtils.configDialogToCenter(this, 500);
setSize(500, 470);
this.setResizable(false);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货