CAN SOMEONE PLEASE SHOW ME HOW THIS PIEVE OF CODING WORKS AND WHAT IT DOES?
ASAP PLEASE !!!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class CheckLibrary extends JFrame
implements ActionListener {
[code=java] JTextField trackNo = new JTextField(2);
TextArea information = new TextArea(6, 50);
JButton list = new JButton("List All Tracks");
JButton check = new JButton("Check Track");
public CheckLibrary() { [/java]
setLayout(new BorderLayout());
setBounds(100, 100, 400, 200);
setTitle("Check Library");
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
JPanel top = new JPanel();
top.add(new JLabel("Enter Track Number:"));
top.add(trackNo);
top.add(check);
top.add(list);
list.addActionListener(this);
check.addActionListener(this);
add("North", top);
JPanel middle = new JPanel();
information.setText(LibraryData.listAll());
middle.add(information);
add("Center", middle);]
[setResizable(false);
setVisible(true);
}
//
public void actionPerformed(ActionEvent e) {
if (e.getSource() == list) {
information.setText(LibraryData.listAll());
} else {
String key = trackNo.getText();
String name = LibraryData.getName(key);
if (name == null) {
information.setText("No such track number");
} else {
information.setText(name + " - " + LibraryData.getArtist(key));
information.append("\nRating: " + stars(LibraryData.getRating(key)));
information.append("\nPlay count: " + LibraryData.getPlayCount(key));
}
}
}
[code=java] private String stars(int rating) {
String stars = "";
for (int i = 0; i < rating; ++i) {
stars += "*";
}
return stars;[/java]
}
}
This is meant to be coding for a jukebox application