-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLeftPanel.java
More file actions
154 lines (141 loc) · 4.99 KB
/
LeftPanel.java
File metadata and controls
154 lines (141 loc) · 4.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
/**
* The Responder class manage left panel
*
* @author omid mahyar and pouyan hesabi *
* @version 1.0 (1398/04/05)
*/
public class LeftPanel extends JPanel {
private JButton addToLibraryIcon = new JButton(new ImageIcon("icons/plus.png"));
private ButtonForLeftPanel songs;
private ButtonForLeftPanel albums;
private int y = 390, i = 0;
private ButtonForLeftPanel buttonForLeftPanel;
private ArrayList<ButtonForLeftPanel> playlists = new ArrayList<>();
private JButton addPlaylistIcon;
private ButtonForLeftPanel favoriteSongs;
private ButtonForLeftPanel SharedPlaylist;
private ButtonForLeftPanel home;
public LeftPanel() {
this.setBackground(Color.DARK_GRAY);
this.setPreferredSize(new Dimension(200, 700));
this.setLayout(null);
JLabel homeIcon = new JLabel(new ImageIcon("icons/home.png"));
homeIcon.setLocation(5, 0);
homeIcon.setSize(25, 30);
this.add(homeIcon);
home = new ButtonForLeftPanel("Home");
home.setLocation(30, 0);
this.add(home);
JLabel libraryIcon = new JLabel(new ImageIcon("icons/library.png"));
libraryIcon.setLocation(5, 45);
libraryIcon.setSize(25, 30);
this.add(libraryIcon);
TextLabel library = new TextLabel("Library");
library.setLocation(50, 45);
this.add(library);
songs = new ButtonForLeftPanel("Songs");
songs.setLocation(30, 90);
this.add(songs);
albums = new ButtonForLeftPanel("Albums");
albums.setLocation(30, 135);
this.add(albums);
addToLibraryIcon.setSize(30, 30);
addToLibraryIcon.setLocation(5, 180);
addToLibraryIcon.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.setBackground(Color.DARK_GRAY);
addToLibraryIcon.setBorderPainted(false);
addToLibraryIcon.setFocusPainted(false);
addToLibraryIcon.setContentAreaFilled(false);
this.add(addToLibraryIcon);
TextLabel addToLibrary = new TextLabel("add to Library");
addToLibrary.setLocation(50, 180);
this.add(addToLibrary);
addPlaylistIcon = new JButton(new ImageIcon("icons/plus.png"));
addPlaylistIcon.setSize(30, 30);
addPlaylistIcon.setLocation(5, 270);
addPlaylistIcon.setCursor(new Cursor(Cursor.HAND_CURSOR));
this.setBackground(Color.DARK_GRAY);
addPlaylistIcon.setBorderPainted(false);
addPlaylistIcon.setFocusPainted(false);
addPlaylistIcon.setContentAreaFilled(false);
this.add(addPlaylistIcon);
TextLabel addToPlaylist = new TextLabel("add Playlist");
addToPlaylist.setLocation(50, 270);
this.add(addToPlaylist);
JLabel playlistIcon = new JLabel(new ImageIcon("icons/playlist.png"));
playlistIcon.setLocation(7, 225);
playlistIcon.setSize(25, 30);
this.add(playlistIcon);
TextLabel playlist = new TextLabel("Playlist");
playlist.setLocation(50, 225);
this.add(playlist);
favoriteSongs = new ButtonForLeftPanel("Favorites");
favoriteSongs.setLocation(28, 360);
favoriteSongs.setSize(100, 30);
this.add(favoriteSongs);
SharedPlaylist = new ButtonForLeftPanel("SharedPlaylist");
SharedPlaylist.setLocation(26, 315);
SharedPlaylist.setSize(130, 30);
this.add(SharedPlaylist);
}
/**
* removing playlist label from left panel
*
* @param name a String who name of play list
*/
public void removePlaylist(String name) {
for (int j = 0; j < playlists.size(); j++) {
if (playlists.get(j).getActionCommand().equals(name)) {
this.remove(playlists.get(j));
playlists.remove(playlists.get(j));
break;
}
}
}
/**
* removing all playlist label from left panel
*/
public void clearPlaylist() {
playlists.clear();
i = 0;
}
/**
* adding playlist label from left panel
*
* @param name a String who name of play list
*/
public void addLableOfplaylist(String name) {
buttonForLeftPanel = new ButtonForLeftPanel(name);
buttonForLeftPanel.setLocation(35, y + i * 50);
this.add(buttonForLeftPanel);
playlists.add(buttonForLeftPanel);
i++;
}
public JButton getAddToLibraryIcon() {
return addToLibraryIcon;
}
public ButtonForLeftPanel getAlbums() {
return albums;
}
public ButtonForLeftPanel getSongs() {
return songs;
}
public JButton getAddPlaylistIcon() {
return addPlaylistIcon;
}
public ArrayList<ButtonForLeftPanel> getPlaylists() {
return playlists;
}
public ButtonForLeftPanel getFavoriteSongs() {
return favoriteSongs;
}
public ButtonForLeftPanel getSharedPlaylist() {
return SharedPlaylist;
}
public ButtonForLeftPanel getHome() {
return home;
}
}