MusicPathDialog(Frame owner,
String title) {
super(owner, title, true);
GridBagLayout gridbag = new GridBagLayout();
GridBagConstraints constraints = new GridBagConstraints();
constraints.insets = new Insets(5, 5, 5, 5);
getContentPane().setLayout(gridbag);
Symbols symbols = NeurosProperties.getSymbols();
String path = symbols.getPath();
final JLabel pathLabel = new JLabel( "Music path:", JLabel.RIGHT);
constraints.gridwidth = 1;
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.weightx = 1;
gridbag.setConstraints(pathLabel, constraints);
getContentPane().add(pathLabel);
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.fill = GridBagConstraints.HORIZONTAL;
gridbag.setConstraints(pathText, constraints);
getContentPane().add(pathText);
JPanel selectionPanel = new JPanel();
selectionPanel.setLayout(new GridLayout(0, 1));
noneRadioButton = new JRadioButton("None");
noneRadioButton.addActionListener(this);
selectionPanel.add(noneRadioButton);
artistRadioButton = new JRadioButton("Artist");
artistRadioButton.addActionListener(this);
selectionPanel.add(artistRadioButton);
artistAlbumRadioButton = new JRadioButton("Artist/Album");
artistAlbumRadioButton.addActionListener(this);
selectionPanel.add(artistAlbumRadioButton);
genreArtistRadioButton = new JRadioButton("Genre/Artist");
genreArtistRadioButton.addActionListener(this);
selectionPanel.add(genreArtistRadioButton);
customPathRadioButton = new JRadioButton("Custom Path");
customPathRadioButton.addActionListener(this);
selectionPanel.add(customPathRadioButton);
TitledBorder selectionBorder = new TitledBorder("Path Selection");
selectionPanel.setBorder(selectionBorder);
constraints.fill = GridBagConstraints.BOTH;
constraints.gridwidth = 2;
gridbag.setConstraints(selectionPanel, constraints);
getContentPane().add(selectionPanel);
pathGroup = new ButtonGroup();
pathGroup.add(noneRadioButton);
pathGroup.add(artistRadioButton);
pathGroup.add(artistAlbumRadioButton);
pathGroup.add(genreArtistRadioButton);
pathGroup.add(customPathRadioButton);
// Determine which button to set
if (path == null) {
path = artistAlbumRadioButtonPath;
}
customPathRadioButton.setSelected(true);
if (path == noneRadioButtonPath) {
noneRadioButton.setSelected(true);
pathText.setEnabled(false);
}
if (path == artistAlbumRadioButtonPath) {
artistAlbumRadioButton.setSelected(true);
pathText.setEnabled(false);
}
pathText.setText(path);
JPanel helpPanel = new JPanel();
helpPanel.setLayout(new GridLayout(0, 1, 3, 5));
helpPanel.add(new JLabel("%a, artist"));
helpPanel.add(new JLabel("%b, album"));
helpPanel.add(new JLabel("%m, track"));
helpPanel.add(new JLabel("%t, track (padded)"));
helpPanel.add(new JLabel("%n, name"));
helpPanel.add(new JLabel("%e, extension"));
helpPanel.add(new JLabel("%%, percent"));
helpPanel.add(new JLabel("Add a * (i.e. %*a) to encode chars."));
TitledBorder helpBorder = new TitledBorder("Path Symbols");
helpPanel.setBorder(helpBorder);
constraints.fill = GridBagConstraints.BOTH;
constraints.gridwidth = GridBagConstraints.REMAINDER;
gridbag.setConstraints(helpPanel, constraints);
getContentPane().add(helpPanel);
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new GridLayout(1, 0, 10, 0));
changeButton = new JButton("Change");
changeButton.addActionListener(this);
buttonPanel.add(changeButton);
cancelButton = new JButton("Cancel");
cancelButton.addActionListener(this);
buttonPanel.add(cancelButton);
constraints.gridwidth = GridBagConstraints.REMAINDER;
constraints.weightx = 1;
gridbag.setConstraints(buttonPanel, constraints);
getContentPane().add(buttonPanel);
pack();
}
|