import javax.swing.*;
import java.awt.*;
public class JTunesPanel extends JPanel {
private JButton searchButton;
private JRadioButton artistRadio, songRadio;
private JTextField searchField;
private JLabel artistsLabel, songsLabel;
private JList artistList, songList;
private GridBagLayout layout;
private GridBagConstraints constraints;
private JScrollPane songScrollPane, artistScrollPane;
public JTunesPanel() {
layout = new GridBagLayout();
setLayout(layout);
constraints = new GridBagConstraints();
searchField = new JTextField();
constraints.gridx = 0;
constraints.gridy = 0;
constraints.gridwidth = 3;
constraints.gridheight = 1;
constraints.fill = GridBagConstraints.BOTH;
constraints.anchor = GridBagConstraints.WEST;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.weightx = 75;
constraints.weighty = 0;
layout.setConstraints(searchField, constraints);
add(searchField);
searchButton = new JButton("Search");
constraints.gridx = 3;
constraints.gridy = 0;
constraints.gridwidth = 1;
constraints.gridheight = 1;
constraints.fill = GridBagConstraints.NONE;
constraints.anchor = GridBagConstraints.WEST;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.weightx = 0;
constraints.weighty = 0;
layout.setConstraints(searchButton, constraints);
add(searchButton);
artistsLabel = new JLabel("Artists");
constraints.gridx = 0;
constraints.gridy = 1;
constraints.gridwidth = 2;
constraints.gridheight = 1;
constraints.fill = GridBagConstraints.BOTH;
constraints.anchor = GridBagConstraints.CENTER;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.weightx = 50;
constraints.weighty = 0;
add(artistsLabel);
songsLabel = new JLabel("Songs");
constraints.gridx = 2;
constraints.gridy = 1;
constraints.gridwidth = 2;
constraints.gridheight = 1;
constraints.fill = GridBagConstraints.BOTH;
constraints.anchor = GridBagConstraints.CENTER;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.weightx = 50;
constraints.weighty = 0;
add(songsLabel);
artistList = new JList();
constraints.gridx = 0;
constraints.gridy = 2;
constraints.gridwidth = 2;
constraints.gridheight = 1;
constraints.fill = GridBagConstraints.BOTH;
constraints.anchor = GridBagConstraints.CENTER;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.weightx = 50;
constraints.weighty = 0;
artistScrollPane = new JScrollPane(artistList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
layout.setConstraints(artistScrollPane, constraints);
add(artistScrollPane);
songList = new JList();
constraints.gridx = 2;
constraints.gridy = 2;
constraints.gridwidth = 2;
constraints.gridheight = 1;
constraints.fill = GridBagConstraints.BOTH;
constraints.anchor = GridBagConstraints.CENTER;
constraints.insets = new Insets(5, 5, 5, 5);
constraints.weightx = 50;
constraints.weighty = 0;
songScrollPane = new JScrollPane(songList, ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
layout.setConstraints(songScrollPane, constraints);
add(songScrollPane);
}
}