1 package tim.prune.correlate;
3 import java.awt.BorderLayout;
4 import java.awt.GridLayout;
6 import javax.swing.BorderFactory;
7 import javax.swing.ButtonGroup;
8 import javax.swing.JLabel;
9 import javax.swing.JPanel;
10 import javax.swing.JRadioButton;
11 import javax.swing.border.EtchedBorder;
13 import tim.prune.I18nManager;
16 * GUI element to allow the selection of timestamp options
17 * for audio clip correlation
19 public class AudioTimestampSelector extends JPanel
21 /** Array of radio buttons */
22 private JRadioButton[] _radios = new JRadioButton[3];
27 * @param inTopLabelKey key for description label at top
28 * @param inLowerLabelKey key for description label at bottom, if any
30 public AudioTimestampSelector(String inTopLabelKey, String inLowerLabelKey)
32 createComponents(inTopLabelKey, inLowerLabelKey);
33 setBorder(BorderFactory.createCompoundBorder(
34 BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), BorderFactory.createEmptyBorder(4, 4, 4, 4))
39 * Create the GUI components
40 * @param inTopLabelKey key for description label at top
41 * @param inLowerLabelKey key for description label at bottom, if any
43 private void createComponents(String inTopLabelKey, String inLowerLabelKey)
45 setLayout(new BorderLayout());
46 add(new JLabel(I18nManager.getText(inTopLabelKey)), BorderLayout.NORTH);
47 // panel for the radio buttons
48 JPanel gridPanel = new JPanel();
49 gridPanel.setLayout(new GridLayout(0, 3, 15, 3));
50 final String[] keys = {"beginning", "middle", "end"};
51 ButtonGroup group = new ButtonGroup();
52 for (int i=0; i<3; i++)
54 _radios[i] = new JRadioButton(I18nManager.getText("dialog.correlate.timestamp." + keys[i]));
55 group.add(_radios[i]);
56 gridPanel.add(_radios[i]);
58 _radios[0].setSelected(true);
59 add(gridPanel, BorderLayout.CENTER);
60 if (inLowerLabelKey != null) {
61 add(new JLabel(I18nManager.getText(inLowerLabelKey)), BorderLayout.SOUTH);
66 * Get the option selected by the user
67 * @return 0 for beginning, 1 for middle or 2 for end
69 public int getSelectedOption()
71 for (int i=0; i<_radios.length; i++)
72 if (_radios[i].isSelected()) {return i;}