private void createControlPanel() { JPanel pnControls = new JPanel(); pnCopies.add(pnControls, BorderLayout.NORTH); pnControls.setLayout(new MigLayout("", "[][grow][][]", "[]")); lblNrOfCopies = new JLabel(); pnControls.add(lblNrOfCopies, "cell 0 0,alignx trailing"); txtValNrOfCopies = new JTextField(); txtValNrOfCopies.setEnabled(false); pnControls.add(txtValNrOfCopies, "flowx,cell 1 0"); txtValNrOfCopies.setColumns(10); btnAdd = new JButton(); btnAdd.setName(NAME_BUTTON_ADD_COPY); btnAdd.setMnemonic('a'); btnAdd.setIcon(IconUtil.loadIcon("add.gif")); pnControls.add(btnAdd, "cell 2 0"); btnRemove = new JButton(); btnRemove.setName(NAME_BUTTON_DELETE_COPY); btnRemove.setEnabled(false); btnRemove.setMnemonic('e'); btnRemove.setIcon(IconUtil.loadIcon("delete.gif")); pnControls.add(btnRemove, "cell 3 0"); }
@Override public void update(Observable o, Object arg) { if (o.getClass().equals(CopyPMod.class) || o.getClass().equals(BooksPMod.class)) { Preconditions.checkNotNull(arg); if (getReferenceObject().equals(arg)) { lblMessage.setText(Texts.get("BookDetailMainView.optimisticlock.error")); lblMessage.setIcon(IconUtil.loadIcon("warning.png")); logger.info("Book changed in the background, disabling view..."); disableComponents( btnSave, btnAdd, btnRemove, btnSetCondition, listCopies, txtFieldAuthor, txtFieldPublisher, txtFieldTitle, comboShelf); } else { logger.info("A different book changed in the background. Doing nothing..."); } } else { super.update(o, arg); } }