removed fmobjview abstraction from albumview, added gui get for album

This commit is contained in:
aj 2018-03-24 20:10:47 -07:00
parent ffaf973b9f
commit 6ceb77393c
6 changed files with 48 additions and 9 deletions

View File

@ -2,14 +2,14 @@ package sarsoo.fmframework.drive;
import sarsoo.fmframework.gui.AlbumView;
import sarsoo.fmframework.music.Album;
import sarsoo.fmframework.util.GetObject;
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);
GetObject.getAlbum().view();
}
}

View File

@ -6,6 +6,8 @@ import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URI;
import java.text.NumberFormat;
import java.util.Locale;
import javax.swing.JButton;
import javax.swing.JFrame;
@ -14,6 +16,7 @@ import javax.swing.JOptionPane;
import javax.swing.JPanel;
import sarsoo.fmframework.music.Album;
import sarsoo.fmframework.music.FMObj;
public class AlbumView extends JFrame{
JPanel info = new JPanel();
@ -38,11 +41,13 @@ public class AlbumView extends JFrame{
// info.add(userPlayCount);
buttons.add(open);
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
name.setText(album.getName());
name.setHorizontalTextPosition(JLabel.CENTER);
listeners.setText(album.getListeners() + " Listeners");
playCount.setText(album.getPlayCount() + " Scrobbles");
userPlayCount.setText(album.getUserPlayCount() + " Your Scrobbles");
listeners.setText(numberFormat.format(album.getListeners()) + " Listeners");
playCount.setText(numberFormat.format(album.getPlayCount()) + " Scrobbles");
userPlayCount.setText(numberFormat.format(album.getUserPlayCount()) + " Your Scrobbles");
open.addActionListener(new ActionListener() {

View File

@ -6,6 +6,8 @@ import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.net.URI;
import java.text.NumberFormat;
import java.util.Locale;
import javax.swing.JButton;
import javax.swing.JFrame;
@ -37,11 +39,13 @@ public class FMObjView extends JFrame{
// info.add(userPlayCount);
buttons.add(open);
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
name.setText(obj.getName());
name.setHorizontalTextPosition(JLabel.CENTER);
listeners.setText(obj.getListeners() + " Listeners");
playCount.setText(obj.getPlayCount() + " Scrobbles");
userPlayCount.setText(obj.getUserPlayCount() + " Your Scrobbles");
listeners.setText(numberFormat.format(obj.getListeners()) + " Listeners");
playCount.setText(numberFormat.format(obj.getPlayCount()) + " Scrobbles");
userPlayCount.setText(numberFormat.format(obj.getUserPlayCount()) + " Your Scrobbles");
open.addActionListener(new ActionListener() {
@ -62,4 +66,6 @@ public class FMObjView extends JFrame{
// add(info);
add(buttons);
}
}

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import org.w3c.dom.Document;
import sarsoo.fmframework.gui.AlbumView;
import sarsoo.fmframework.net.Network;
import sarsoo.fmframework.parser.Parser;
@ -61,4 +62,10 @@ public class Album extends FMObj{
return false;
}
@Override
public void view() {
AlbumView view = new AlbumView(this);
view.setVisible(true);
}
}

View File

@ -1,5 +1,7 @@
package sarsoo.fmframework.music;
import sarsoo.fmframework.gui.FMObjView;
public class FMObj {
protected String name;
@ -22,6 +24,11 @@ public class FMObj {
this.wiki = wiki;
}
public void view() {
FMObjView view = new FMObjView(this);
view.setVisible(true);
}
public String toString() {
return name;
}

View File

@ -0,0 +1,14 @@
package sarsoo.fmframework.util;
import javax.swing.JOptionPane;
import sarsoo.fmframework.music.Album;
public class GetObject {
public static Album getAlbum() {
String artistName = JOptionPane.showInputDialog(null, "Enter Artist Name");
String albumName = JOptionPane.showInputDialog(null, "Enter Album Name");
return Album.getAlbum(albumName, artistName, "sarsoo");
}
}