(JFrame parentFrame,DefaultTableModel tableModel)
| 142 | |
| 143 | // 添加行 |
| 144 | private static void addRow(JFrame parentFrame,DefaultTableModel tableModel) { |
| 145 | JComboBox JComboBoxitem = new JComboBox(); // 请求、响应部分选择 |
| 146 | DefaultComboBoxModel defaultComboBoxModelitem = new DefaultComboBoxModel(); |
| 147 | defaultComboBoxModelitem.addElement("Request header"); |
| 148 | defaultComboBoxModelitem.addElement("Request body"); |
| 149 | defaultComboBoxModelitem.addElement("Response header"); |
| 150 | defaultComboBoxModelitem.addElement("Response body"); |
| 151 | JComboBoxitem.setModel(defaultComboBoxModelitem); |
| 152 | |
| 153 | JComboBox JComboBoxtype = new JComboBox(); // 请求、响应部分选择 |
| 154 | DefaultComboBoxModel defaultComboBoxModeltype = new DefaultComboBoxModel(); |
| 155 | defaultComboBoxModeltype.addElement("Literal"); |
| 156 | defaultComboBoxModeltype.addElement("Regex"); |
| 157 | defaultComboBoxModeltype.addElement("Extract"); |
| 158 | JComboBoxtype.setModel(defaultComboBoxModeltype); |
| 159 | |
| 160 | // JTextField itemField = new JTextField(); |
| 161 | JTextField hostField = new JTextField(30); |
| 162 | JTextField matchField = new JTextField(30); |
| 163 | JTextField replaceField = new JTextField(30); |
| 164 | // JTextField typeField = new JTextField(); |
| 165 | JTextField commentField = new JTextField(30); |
| 166 | |
| 167 | |
| 168 | JPanel panel = new JPanel(new GridLayout(6, 2)); |
| 169 | JPanel panel1 = new JPanel(new BorderLayout()); |
| 170 | panel.add(new JLabel("Host:")); |
| 171 | panel.add(hostField); |
| 172 | panel1.add(new JLabel("Item:"), BorderLayout.CENTER); |
| 173 | panel.add(panel1); |
| 174 | panel.add(JComboBoxitem); |
| 175 | |
| 176 | |
| 177 | panel.add(new JLabel("Match:")); |
| 178 | panel.add(matchField); |
| 179 | |
| 180 | panel.add(new JLabel("Replace:")); |
| 181 | panel.add(replaceField); |
| 182 | |
| 183 | panel.add(new JLabel("Type:")); |
| 184 | panel.add(JComboBoxtype); |
| 185 | |
| 186 | panel.add(new JLabel("Comment:")); |
| 187 | panel.add(commentField); |
| 188 | |
| 189 | int result = JOptionPane.showConfirmDialog(parentFrame, panel, "Add Row", |
| 190 | JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); |
| 191 | |
| 192 | if (result == JOptionPane.OK_OPTION) { |
| 193 | String host = hostField.getText().toString(); |
| 194 | String item = JComboBoxitem.getSelectedItem().toString(); |
| 195 | String match = matchField.getText(); |
| 196 | String replace =replaceField.getText(); |
| 197 | String type = JComboBoxtype.getSelectedItem().toString(); |
| 198 | String comment =commentField.getText(); |
| 199 | |
| 200 | Object[] rowData = {false ,host ,item ,match ,replace ,type , comment }; |
| 201 | tableModel.addRow(rowData); |
no test coverage detected