started gui work
This commit is contained in:
parent
14a6f006d5
commit
ffaf973b9f
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
66
fmframework/src/sarsoo/fmframework/gui/AlbumView.java
Normal file
66
fmframework/src/sarsoo/fmframework/gui/AlbumView.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
65
fmframework/src/sarsoo/fmframework/gui/FMObjView.java
Normal file
65
fmframework/src/sarsoo/fmframework/gui/FMObjView.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user