JComponent () { final JPanel panel = new JPanel(new GridBagLayout()); final JLabel nameLabel = new JLabel(AntBundle.message("save.meta.data.name.label")); panel.add(nameLabel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBInsets.emptyInsets(), 0, 0)); myTfName = new JTextField(myInitialEvent.getPresentableName()); nameLabel.setLabelFor(myTfName); myTfName.selectAll(); panel.add(myTfName, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insetsTop(4), 0, 0)); final DefaultListModel dataModel = new DefaultListModel(); myTargetList = new JBList(dataModel); final List<String> targetNames = myInitialEvent.getTargetNames(); for (@NlsSafe String name : targetNames) { dataModel.addElement(name); } panel.add(new JLabel(AntBundle.message("save.meta.data.targets.label")), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, JBUI.insetsTop(6), 0, 0)); panel.add(ScrollPaneFactory.createScrollPane(myTargetList), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 2, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, JBUI.insetsTop(4), 0, 0)); final JButton upButton = new JButton(AntBundle.message("button.move.up")); panel.add(upButton, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insets(6, 6, 0, 0), 0, 0)); final JButton downButton = new JButton(AntBundle.message("button.move.down")); panel.add(downButton, new GridBagConstraints(1, 4, 1, GridBagConstraints.REMAINDER, 0.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, JBUI.insetsLeft(6), 0, 0)); class UpdateAction implements ActionListener { @Override public void actionPerformed(ActionEvent e) { upButton.setEnabled(ListUtil.canMoveSelectedItemsUp(myTargetList)); downButton.setEnabled(ListUtil.canMoveSelectedItemsDown(myTargetList)); } } upButton.addActionListener(new UpdateAction() { @Override public void actionPerformed(ActionEvent e) { ListUtil.moveSelectedItemsUp(myTargetList); super.actionPerformed(e); } }); downButton.addActionListener(new UpdateAction() { @Override public void actionPerformed(ActionEvent e) { ListUtil.moveSelectedItemsDown(myTargetList); super.actionPerformed(e); } }); myTargetList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { upButton.setEnabled(ListUtil.canMoveSelectedItemsUp(myTargetList)); downButton.setEnabled(ListUtil.canMoveSelectedItemsDown(myTargetList)); } }); myTargetList.setSelectedIndex(0); return panel; }