diff --git a/fmframework/src/sarsoo/fmframework/drive/Driver.java b/fmframework/src/sarsoo/fmframework/drive/Driver.java index 5209141..9700436 100644 --- a/fmframework/src/sarsoo/fmframework/drive/Driver.java +++ b/fmframework/src/sarsoo/fmframework/drive/Driver.java @@ -1,10 +1,15 @@ package sarsoo.fmframework.drive; +import sarsoo.fmframework.gui.AlbumView; +import sarsoo.fmframework.music.Album; + public class Driver { public static void main(String[] args) { System.out.println("Hello World"); + AlbumView view = new AlbumView(Album.getAlbum("Recovery", "Eminem", "sarsoo")); + view.setVisible(true); } } diff --git a/fmframework/src/sarsoo/fmframework/gui/AlbumView.java b/fmframework/src/sarsoo/fmframework/gui/AlbumView.java new file mode 100644 index 0000000..b3d4d60 --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/gui/AlbumView.java @@ -0,0 +1,66 @@ +package sarsoo.fmframework.gui; + +import java.awt.Desktop; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URI; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JOptionPane; +import javax.swing.JPanel; + +import sarsoo.fmframework.music.Album; + +public class AlbumView extends JFrame{ + JPanel info = new JPanel(); + JPanel buttons = new JPanel(); + JLabel name = new JLabel(); + JLabel listeners = new JLabel(); + JLabel playCount = new JLabel(); + JLabel userPlayCount = new JLabel(); + JButton open = new JButton("View Online"); + + public AlbumView(Album album) { + super(album.toString()); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLayout(new GridLayout(5,0)); + setSize(300, 200); + setResizable(false); + info.setLayout(new GridLayout()); + buttons.setLayout(new FlowLayout()); +// info.add(name); +// info.add(listeners); +// info.add(playCount); +// info.add(userPlayCount); + buttons.add(open); + + name.setText(album.getName()); + name.setHorizontalTextPosition(JLabel.CENTER); + listeners.setText(album.getListeners() + " Listeners"); + playCount.setText(album.getPlayCount() + " Scrobbles"); + userPlayCount.setText(album.getUserPlayCount() + " Your Scrobbles"); + + + open.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + try { + Desktop desktop = java.awt.Desktop.getDesktop(); + URI oURL = new URI(album.getUrl()); + desktop.browse(oURL); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + add(name); + add(listeners); + add(playCount); + add(userPlayCount); +// add(info); + add(buttons); + } +} diff --git a/fmframework/src/sarsoo/fmframework/gui/FMObjView.java b/fmframework/src/sarsoo/fmframework/gui/FMObjView.java new file mode 100644 index 0000000..3ab1fa8 --- /dev/null +++ b/fmframework/src/sarsoo/fmframework/gui/FMObjView.java @@ -0,0 +1,65 @@ +package sarsoo.fmframework.gui; + +import java.awt.Desktop; +import java.awt.FlowLayout; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.net.URI; + +import javax.swing.JButton; +import javax.swing.JFrame; +import javax.swing.JLabel; +import javax.swing.JPanel; + +import sarsoo.fmframework.music.FMObj; + +public class FMObjView extends JFrame{ + JPanel info = new JPanel(); + JPanel buttons = new JPanel(); + JLabel name = new JLabel(); + JLabel listeners = new JLabel(); + JLabel playCount = new JLabel(); + JLabel userPlayCount = new JLabel(); + JButton open = new JButton("View Online"); + + public FMObjView(FMObj obj) { + super(obj.toString()); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLayout(new GridLayout(5,0)); + setSize(300, 200); + setResizable(false); + info.setLayout(new GridLayout()); + buttons.setLayout(new FlowLayout()); +// info.add(name); +// info.add(listeners); +// info.add(playCount); +// info.add(userPlayCount); + buttons.add(open); + + name.setText(obj.getName()); + name.setHorizontalTextPosition(JLabel.CENTER); + listeners.setText(obj.getListeners() + " Listeners"); + playCount.setText(obj.getPlayCount() + " Scrobbles"); + userPlayCount.setText(obj.getUserPlayCount() + " Your Scrobbles"); + + + open.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + try { + Desktop desktop = java.awt.Desktop.getDesktop(); + URI oURL = new URI(obj.getUrl()); + desktop.browse(oURL); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + add(name); + add(listeners); + add(playCount); + add(userPlayCount); +// add(info); + add(buttons); + } +} diff --git a/fmframework/src/sarsoo/fmframework/music/FMObj.java b/fmframework/src/sarsoo/fmframework/music/FMObj.java index bf35091..04f22fd 100644 --- a/fmframework/src/sarsoo/fmframework/music/FMObj.java +++ b/fmframework/src/sarsoo/fmframework/music/FMObj.java @@ -22,6 +22,10 @@ public class FMObj { this.wiki = wiki; } + public String toString() { + return name; + } + public String getName() { return name; } @@ -38,11 +42,11 @@ public class FMObj { return listeners; } - public int playCount() { + public int getPlayCount() { return playCount; } - public int userPlayCount() { + public int getUserPlayCount() { return userPlayCount; } diff --git a/fmframework/src/sarsoo/fmframework/net/Network.java b/fmframework/src/sarsoo/fmframework/net/Network.java index 5f23690..7a33e45 100644 --- a/fmframework/src/sarsoo/fmframework/net/Network.java +++ b/fmframework/src/sarsoo/fmframework/net/Network.java @@ -1,9 +1,7 @@ package sarsoo.fmframework.net; -import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; -import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; @@ -13,9 +11,6 @@ import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; import org.xml.sax.SAXException; public class Network {