public void go() { List<String> categories = db.getCategoryNames(); view.makeCategoryCombo(categories); ActionListener keyWordActionListener = new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { int totalComponents = view.getAddPanel().getComponentCount(); JPanel anotherAddKeyWordsPane = new JPanel(); final JLabel removeLabel = new JLabel("remove"); removeLabel.setForeground(Color.blue); removeLabel.addMouseListener( new MouseListener() { @Override public void mouseClicked(MouseEvent arg0) { view.getAddPanel().remove(removeLabel.getParent()); view.getAddPanel().revalidate(); } @Override public void mouseEntered(MouseEvent arg0) { removeLabel.setCursor(new Cursor(Cursor.HAND_CURSOR)); } @Override public void mouseExited(MouseEvent arg0) { removeLabel.setCursor(new Cursor(Cursor.DEFAULT_CURSOR)); } @Override public void mousePressed(MouseEvent arg0) {} @Override public void mouseReleased(MouseEvent arg0) {} }); JLabel tfAnotherAddKeyWords = new JLabel(view.getKeyWordsTextFeild().getText()); view.getKeyWordsTextFeild().setText(""); anotherAddKeyWordsPane.setLayout(new GridLayout(0, 2)); anotherAddKeyWordsPane.add(removeLabel); anotherAddKeyWordsPane.add(tfAnotherAddKeyWords); view.getAddPanel().add(anotherAddKeyWordsPane, totalComponents - 5); view.getAddPanel().revalidate(); } }; view.getKeyWordsTextFeild().addActionListener(keyWordActionListener); view.getCancelButton() .addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { splitController.addCancelButtonPressed(); } }); view.getSaveButton() .addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { List<String> dummy = new ArrayList<String>(); dummy.add(view.getComboAddCategory().getSelectedItem().toString()); if (db.addCodeExample( view.getAddTitle().getText(), view.getTfAddDescription().getText(), view.getAddCode().getText(), view.getAddProgrammingLanguage().getSelectedItem().toString(), dummy, view.getAddPublic().isSelected()) == 2) { view.addNameNotUnique(); } else { splitController.addSaveButtonPressed(view.getAddTitle().getText()); } } }); }
public Container getView() { return view.getView(); }