removed fmobjview abstraction from albumview, added gui get for album
This commit is contained in:
parent
ffaf973b9f
commit
6ceb77393c
@ -2,14 +2,14 @@ package sarsoo.fmframework.drive;
|
|||||||
|
|
||||||
import sarsoo.fmframework.gui.AlbumView;
|
import sarsoo.fmframework.gui.AlbumView;
|
||||||
import sarsoo.fmframework.music.Album;
|
import sarsoo.fmframework.music.Album;
|
||||||
|
import sarsoo.fmframework.util.GetObject;
|
||||||
|
|
||||||
public class Driver {
|
public class Driver {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
||||||
System.out.println("Hello World");
|
GetObject.getAlbum().view();
|
||||||
AlbumView view = new AlbumView(Album.getAlbum("Recovery", "Eminem", "sarsoo"));
|
|
||||||
view.setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,8 @@ import java.awt.GridLayout;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
@ -14,6 +16,7 @@ import javax.swing.JOptionPane;
|
|||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import sarsoo.fmframework.music.Album;
|
import sarsoo.fmframework.music.Album;
|
||||||
|
import sarsoo.fmframework.music.FMObj;
|
||||||
|
|
||||||
public class AlbumView extends JFrame{
|
public class AlbumView extends JFrame{
|
||||||
JPanel info = new JPanel();
|
JPanel info = new JPanel();
|
||||||
@ -38,11 +41,13 @@ public class AlbumView extends JFrame{
|
|||||||
// info.add(userPlayCount);
|
// info.add(userPlayCount);
|
||||||
buttons.add(open);
|
buttons.add(open);
|
||||||
|
|
||||||
|
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||||
|
|
||||||
name.setText(album.getName());
|
name.setText(album.getName());
|
||||||
name.setHorizontalTextPosition(JLabel.CENTER);
|
name.setHorizontalTextPosition(JLabel.CENTER);
|
||||||
listeners.setText(album.getListeners() + " Listeners");
|
listeners.setText(numberFormat.format(album.getListeners()) + " Listeners");
|
||||||
playCount.setText(album.getPlayCount() + " Scrobbles");
|
playCount.setText(numberFormat.format(album.getPlayCount()) + " Scrobbles");
|
||||||
userPlayCount.setText(album.getUserPlayCount() + " Your Scrobbles");
|
userPlayCount.setText(numberFormat.format(album.getUserPlayCount()) + " Your Scrobbles");
|
||||||
|
|
||||||
|
|
||||||
open.addActionListener(new ActionListener() {
|
open.addActionListener(new ActionListener() {
|
||||||
|
@ -6,6 +6,8 @@ import java.awt.GridLayout;
|
|||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
import java.text.NumberFormat;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
@ -37,11 +39,13 @@ public class FMObjView extends JFrame{
|
|||||||
// info.add(userPlayCount);
|
// info.add(userPlayCount);
|
||||||
buttons.add(open);
|
buttons.add(open);
|
||||||
|
|
||||||
|
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||||
|
|
||||||
name.setText(obj.getName());
|
name.setText(obj.getName());
|
||||||
name.setHorizontalTextPosition(JLabel.CENTER);
|
name.setHorizontalTextPosition(JLabel.CENTER);
|
||||||
listeners.setText(obj.getListeners() + " Listeners");
|
listeners.setText(numberFormat.format(obj.getListeners()) + " Listeners");
|
||||||
playCount.setText(obj.getPlayCount() + " Scrobbles");
|
playCount.setText(numberFormat.format(obj.getPlayCount()) + " Scrobbles");
|
||||||
userPlayCount.setText(obj.getUserPlayCount() + " Your Scrobbles");
|
userPlayCount.setText(numberFormat.format(obj.getUserPlayCount()) + " Your Scrobbles");
|
||||||
|
|
||||||
|
|
||||||
open.addActionListener(new ActionListener() {
|
open.addActionListener(new ActionListener() {
|
||||||
@ -62,4 +66,6 @@ public class FMObjView extends JFrame{
|
|||||||
// add(info);
|
// add(info);
|
||||||
add(buttons);
|
add(buttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
|
import sarsoo.fmframework.gui.AlbumView;
|
||||||
import sarsoo.fmframework.net.Network;
|
import sarsoo.fmframework.net.Network;
|
||||||
import sarsoo.fmframework.parser.Parser;
|
import sarsoo.fmframework.parser.Parser;
|
||||||
|
|
||||||
@ -61,4 +62,10 @@ public class Album extends FMObj{
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void view() {
|
||||||
|
AlbumView view = new AlbumView(this);
|
||||||
|
view.setVisible(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package sarsoo.fmframework.music;
|
package sarsoo.fmframework.music;
|
||||||
|
|
||||||
|
import sarsoo.fmframework.gui.FMObjView;
|
||||||
|
|
||||||
public class FMObj {
|
public class FMObj {
|
||||||
|
|
||||||
protected String name;
|
protected String name;
|
||||||
@ -22,6 +24,11 @@ public class FMObj {
|
|||||||
this.wiki = wiki;
|
this.wiki = wiki;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void view() {
|
||||||
|
FMObjView view = new FMObjView(this);
|
||||||
|
view.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
14
fmframework/src/sarsoo/fmframework/util/GetObject.java
Normal file
14
fmframework/src/sarsoo/fmframework/util/GetObject.java
Normal 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");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user