removed open ___ buttons, added on click actions to jlabels
This commit is contained in:
parent
771db2a281
commit
d6c68d014d
@ -5,6 +5,8 @@ import java.awt.Font;
|
|||||||
import java.awt.GridLayout;
|
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.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -39,7 +41,7 @@ public class AlbumView extends JFrame {
|
|||||||
public AlbumView(Album album) {
|
public AlbumView(Album album) {
|
||||||
super(album.getName());
|
super(album.getName());
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setLayout(new GridLayout(8, 1));
|
setLayout(new GridLayout(6, 1));
|
||||||
setSize(300, 300);
|
setSize(300, 300);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
|
|
||||||
@ -49,11 +51,11 @@ public class AlbumView extends JFrame {
|
|||||||
// if (album.getTrackList() != null)
|
// if (album.getTrackList() != null)
|
||||||
// buttons2.setLayout(new GridLayout(album.getTrackList().size(), 1));
|
// buttons2.setLayout(new GridLayout(album.getTrackList().size(), 1));
|
||||||
|
|
||||||
buttons2.add(open);
|
buttons.add(open);
|
||||||
buttons2.add(viewArtist);
|
// buttons2.add(viewArtist);
|
||||||
|
|
||||||
if (album.getWiki() != null)
|
if (album.getWiki() != null)
|
||||||
buttons2.add(viewWiki);
|
buttons.add(viewWiki);
|
||||||
if (album.getMbid() != null)
|
if (album.getMbid() != null)
|
||||||
buttons.add(musicBrainz);
|
buttons.add(musicBrainz);
|
||||||
buttons.add(rym);
|
buttons.add(rym);
|
||||||
@ -72,13 +74,21 @@ public class AlbumView extends JFrame {
|
|||||||
|
|
||||||
listeners.setText(numberFormat.format(album.getListeners()) + " Listeners");
|
listeners.setText(numberFormat.format(album.getListeners()) + " Listeners");
|
||||||
listeners.setHorizontalAlignment(SwingConstants.CENTER);
|
listeners.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
playCount.setText(numberFormat.format(album.getPlayCount()) + " Scrobbles");
|
playCount.setText(numberFormat.format(album.getPlayCount()) + " Total Scrobbles");
|
||||||
playCount.setHorizontalAlignment(SwingConstants.CENTER);
|
playCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
|
||||||
userPlayCount.setText(numberFormat.format(album.getUserPlayCount()) + String.format(" Your Scrobbles (%.2f%%)", Maths.getPercentListening(album, Reference.getUserName())));
|
userPlayCount.setText(numberFormat.format(album.getUserPlayCount()) + String.format(" Scrobbles (%.2f%%)", Maths.getPercentListening(album, Reference.getUserName())));
|
||||||
userPlayCount.setHorizontalAlignment(SwingConstants.CENTER);
|
userPlayCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
userPlayCount.setFont(sub);
|
userPlayCount.setFont(sub);
|
||||||
|
|
||||||
|
artist.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
album.getArtist().view();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
open.addActionListener(new ActionListener() {
|
open.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Network.openURL(album.getUrl());
|
Network.openURL(album.getUrl());
|
||||||
@ -153,8 +163,9 @@ public class AlbumView extends JFrame {
|
|||||||
add(listeners);
|
add(listeners);
|
||||||
add(playCount);
|
add(playCount);
|
||||||
|
|
||||||
add(trackListPanel);
|
// add(trackListPanel);
|
||||||
add(buttons);
|
add(buttons);
|
||||||
add(buttons2);
|
// add(buttons2);
|
||||||
|
pack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,9 @@ public class FMObjView extends JFrame{
|
|||||||
|
|
||||||
listeners.setText(numberFormat.format(obj.getListeners()) + " Listeners");
|
listeners.setText(numberFormat.format(obj.getListeners()) + " Listeners");
|
||||||
listeners.setHorizontalAlignment(SwingConstants.CENTER);
|
listeners.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
playCount.setText(numberFormat.format(obj.getPlayCount()) + " Scrobbles");
|
playCount.setText(numberFormat.format(obj.getPlayCount()) + " Total Scrobbles");
|
||||||
playCount.setHorizontalAlignment(SwingConstants.CENTER);
|
playCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
userPlayCount.setText(numberFormat.format(obj.getUserPlayCount()) + String.format(" Your Scrobbles (%.2f%%)", Maths.getPercentListening(obj, Reference.getUserName())));
|
userPlayCount.setText(numberFormat.format(obj.getUserPlayCount()) + String.format(" Scrobbles (%.2f%%)", Maths.getPercentListening(obj, Reference.getUserName())));
|
||||||
userPlayCount.setHorizontalAlignment(SwingConstants.CENTER);
|
userPlayCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
userPlayCount.setFont(sub);
|
userPlayCount.setFont(sub);
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package sarsoo.fmframework.gui;
|
package sarsoo.fmframework.gui;
|
||||||
|
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.GridLayout;
|
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.awt.event.MouseAdapter;
|
||||||
|
import java.awt.event.MouseEvent;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
@ -11,14 +14,17 @@ import javax.swing.JButton;
|
|||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
import javax.swing.SwingConstants;
|
||||||
|
|
||||||
import sarsoo.fmframework.music.Track;
|
import sarsoo.fmframework.music.Track;
|
||||||
import sarsoo.fmframework.net.Network;
|
import sarsoo.fmframework.net.Network;
|
||||||
|
import sarsoo.fmframework.util.Maths;
|
||||||
|
import sarsoo.fmframework.util.Reference;
|
||||||
|
|
||||||
public class TrackView extends JFrame {
|
public class TrackView extends JFrame {
|
||||||
JPanel info = new JPanel();
|
// JPanel info = new JPanel();
|
||||||
JPanel nameInfo = new JPanel();
|
// JPanel nameInfo = new JPanel();
|
||||||
JPanel scrobbleInfo = new JPanel();
|
// JPanel scrobbleInfo = new JPanel();
|
||||||
JPanel buttons = new JPanel();
|
JPanel buttons = new JPanel();
|
||||||
JPanel buttons2 = new JPanel();
|
JPanel buttons2 = new JPanel();
|
||||||
|
|
||||||
@ -39,13 +45,17 @@ public class TrackView extends JFrame {
|
|||||||
public TrackView(Track track) {
|
public TrackView(Track track) {
|
||||||
super(track.getName());
|
super(track.getName());
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setLayout(new GridLayout(3, 1));
|
if (track.getAlbum() != null) {
|
||||||
|
setLayout(new GridLayout(7, 1));
|
||||||
|
} else {
|
||||||
|
setLayout(new GridLayout(6, 1));
|
||||||
|
}
|
||||||
// setSize(300, 300);
|
// setSize(300, 300);
|
||||||
// setResizable(false);
|
setResizable(false);
|
||||||
|
|
||||||
info.setLayout(new GridLayout(1,2));
|
// info.setLayout(new GridLayout(6,1));
|
||||||
nameInfo.setLayout(new GridLayout(3,1));
|
// nameInfo.setLayout(new GridLayout(3,1));
|
||||||
scrobbleInfo.setLayout(new GridLayout(3,1));
|
// scrobbleInfo.setLayout(new GridLayout(3,1));
|
||||||
buttons.setLayout(new FlowLayout());
|
buttons.setLayout(new FlowLayout());
|
||||||
buttons2.setLayout(new FlowLayout());
|
buttons2.setLayout(new FlowLayout());
|
||||||
|
|
||||||
@ -62,14 +72,37 @@ public class TrackView extends JFrame {
|
|||||||
buttons.add(genius);
|
buttons.add(genius);
|
||||||
|
|
||||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||||
|
Font title = new Font("Arial", Font.BOLD, 24);
|
||||||
|
Font sub = new Font("Arial", Font.PLAIN, 20);
|
||||||
|
|
||||||
name.setText(track.getName());
|
name.setText(track.getName());
|
||||||
if(track.getAlbum() != null)
|
name.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
name.setFont(title);
|
||||||
|
|
||||||
|
if (track.getAlbum() != null) {
|
||||||
album.setText(track.getAlbum().getName());
|
album.setText(track.getAlbum().getName());
|
||||||
|
album.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
track.getAlbum().view();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
album.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
album.setFont(sub);
|
||||||
|
|
||||||
artist.setText(track.getArtist().getName());
|
artist.setText(track.getArtist().getName());
|
||||||
|
artist.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
artist.setFont(sub);
|
||||||
|
|
||||||
listeners.setText(numberFormat.format(track.getListeners()) + " Listeners");
|
listeners.setText(numberFormat.format(track.getListeners()) + " Listeners");
|
||||||
playCount.setText(numberFormat.format(track.getPlayCount()) + " Scrobbles");
|
listeners.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
userPlayCount.setText(numberFormat.format(track.getUserPlayCount()) + " Your Scrobbles");
|
playCount.setText(numberFormat.format(track.getPlayCount()) + " Total Scrobbles");
|
||||||
|
playCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
userPlayCount.setText(numberFormat.format(track.getUserPlayCount())
|
||||||
|
+ String.format(" Scrobbles (%.2f%%)", Maths.getPercentListening(track, Reference.getUserName())));
|
||||||
|
userPlayCount.setHorizontalAlignment(SwingConstants.CENTER);
|
||||||
|
userPlayCount.setFont(sub);
|
||||||
|
|
||||||
open.addActionListener(new ActionListener() {
|
open.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
@ -81,6 +114,14 @@ public class TrackView extends JFrame {
|
|||||||
track.getWiki().view(track.getName());
|
track.getWiki().view(track.getName());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
artist.addMouseListener(new MouseAdapter() {
|
||||||
|
@Override
|
||||||
|
public void mouseClicked(MouseEvent e) {
|
||||||
|
track.getArtist().view();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
viewArtist.addActionListener(new ActionListener() {
|
viewArtist.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
track.getArtist().view();
|
track.getArtist().view();
|
||||||
@ -102,20 +143,20 @@ public class TrackView extends JFrame {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
nameInfo.add(name);
|
add(name);
|
||||||
if (track.getAlbum() != null)
|
if (track.getAlbum() != null)
|
||||||
nameInfo.add(album);
|
add(album);
|
||||||
nameInfo.add(artist);
|
add(artist);
|
||||||
scrobbleInfo.add(listeners);
|
add(userPlayCount);
|
||||||
scrobbleInfo.add(playCount);
|
add(listeners);
|
||||||
scrobbleInfo.add(userPlayCount);
|
add(playCount);
|
||||||
|
|
||||||
info.add(nameInfo);
|
// info.add(nameInfo);
|
||||||
info.add(scrobbleInfo);
|
// info.add(scrobbleInfo);
|
||||||
|
|
||||||
add(info);
|
// add(info);
|
||||||
add(buttons);
|
add(buttons);
|
||||||
add(buttons2);
|
// add(buttons2);
|
||||||
pack();
|
pack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user