java 表格项的删除、编辑、增加 修改版 (五)

2014-11-24 09:44:17 · 作者: · 浏览: 2
break; case "TR": addCenterBox.removeAll(); addCenterBox.add(mOptmanagerPanel.trJpanel()); disaddFrame.validate(); break; default: break; } } catch (Exception e2) { //JOptionPane.showMessageDialog(null, "please choose add item first"); //System.out.println("again"); } addOkButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addrowData[0] = rowListName; addrowData[1] = String.valueOf(0); model.addRow(addrowData); disaddFrame.setVisible(false); } }); } }); addCancleButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { disaddFrame.setVisible(false); //System.exit(0); } }); addLeftBox.add(addScrollPane); addBottomBox.add(initAddOkandCancleJPanel()); addCenterJPanel.add(addCenterBox,BorderLayout.NORTH); disaddFrame.add(addLeftBox,BorderLayout.WEST); disaddFrame.add(addCenterJPanel,BorderLayout.CENTER); disaddFrame.add(addBottomBox,BorderLayout.SOUTH); disaddFrame.setTitle("Add"); disaddFrame.setBounds(750,400,300,400); //disaddFrame.pack(); disaddFrame.setVisible(true); } public void editPanel(){ //存在关闭后第二次打开有滚动条嵌套和确定取消按钮位置不一致的问题,已解决:box.removeAll(); editOkButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { if(settingEditor.stopEditing()){} disEditFrame.setVisible(false); Editbox.removeAll(); } }); editCancleButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { disEditFrame.setVisible(false); Editbox.removeAll(); } }); Editbox.add(initEditOkandCancleJPanel()); disEditFrame.add(Editbox); disEditFrame.setBounds(750,400,300,400); disEditFrame.setVisible(true); disEditFrame.pack(); } public String[][] getAlgorithmData(){ rowData = new String[algorithmlist.size()][2]; for (int i = 0; i < algorithmlist.size(); i++) { rowData[i][0] = algorithmlist.get(i).getName(); rowData[i][1] = String.valueOf(i); } return rowData; } /*public String[] getRowName(){ rowName = new String[algorithmlist.size()]; for (int i = 0; i < algorithmlist.size(); i++) { rowName[i] = algorithmlist.get(i).getName(); } return rowName; }*/ public JPanel initAddOkandCancleJPanel(){ okandCancleJPanel = new JPanel(); okandCancleJPanel.add(addOkButton); okandCancleJPanel.add(addCancleButton); return okandCancleJPanel; } public JPanel initEditOkandCancleJPanel(){ okandCancleJPanel = new JPanel(); okandCancleJPanel.add(editOkButton); okandCancleJPanel.add(editCancleButton); return okandCancleJPanel; } /*public JPanel initdurationJPanel(){ durationJPanel.setLayout(new GridLayout(1, 2,30,10)); durationJPanel.add(new Label("Duration")); durationJPanel.add(new TextField(0)); return durationJPanel; }*/ public JPanel bfgsjJPanel(){ setting = new BFGSSetting(); settingEditor = new BFGSSettingEditor((BFGSSetting) setting); bfgsJPanel = (JPanel) settingEditor.getEditorComponent(); return bfgsJPanel; } public JPanel cgJpanel(){ setting = new CGSetting(); settingEditor = new CGSettingEditor((CGSetting) setting); cgJPanel = (JPanel) settingEditor.getEditorComponent(); return cgJPanel; } public JPanel dfpJpanel(){ setting = new DFPSetting() ; settingEditor = new DFPSettingEditor((DFPSetting) setting); dfpJPanel = (JPanel) settingEditor.getEditorComponent(); return dfpJPanel; } public JPanel lmJpanel(){ setting = new LMSetting(); settingEditor = new LMSettingEditor((LMSetting) setting); lmJPanel = (JPanel) settingEditor.getEditorComponent(); return lmJPanel; } public JPanel newTrJpanel(){ setting = new NewTRSetting(); settingEditor = new NewTRSettingEditor((NewTRSetting) setting); newTRJPanel = (JPanel) settingEditor.getEditorComponent(); return newTRJPanel; } public JPanel newSdJpanel(){ setting = new NewSDSetting(); settingEditor = new NewSDSettingEditor((NewSDSetting) setting); newSDJPanel = (JPanel) settingEditor.getEditorComponent(); return newSDJPanel; } public JPanel psJpanel(){ setting = new PatternSearchSetting(); settingEditor = new PatternSearchSettingEditor((PatternSearchSetting) setting); pSJPanel = (JPanel) settingEditor.getEditorComponent(); return pSJPanel; } public JPanel deJpanel(){ setting = new DifferentialEvolutionSetting(); settingEditor = new DifferentialEvolutionSettingEditor((DifferentialEvolutionSetting) setting); deJPanel = (JPanel) settingEditor.getEditorComponent(); return deJPanel; } public JPanel psoJpanel(){ setting = new PSOSetting(); settingEditor = new PSOSettingEditor((PSOSetting) setting); psoJPanel = (JPanel) settingEditor.getEditorComponent(); return psoJPanel; } public JPanel splxJpanel(){ setting = new SimplexSetting(); settingEditor = new SimplexSettingEditor((SimplexSetting) setting); splxJPanel = (JPanel) settingEditor.getEditorComponent(); return splxJPanel; } public JPanel trJpanel(){ setting = new TRSetting(); settingEditor = new TRSettingEditor((TRSetting) setting); trJPanel = (JPanel) settingEditor.getEditorComponent(); return trJPanel; } }