四川科技职业学院毕业设计(论文)
第 33 页
private void refreshSystem() {
TitlePanel.getInstance().setTheme(themeNumer);
MyMenuBar.getInstance().setMenuBackgroundColor(getBackgroundColor());
MyPopupMenu.getInstance().setBackgroundColor(getBackgroundColor());
BottomPanel bpnl = BottomPanel.getInstance();
bpnl.setBackgroundColor(getForegroundColor()); MySliderUI.setSliderColor(getForegroundColor());
bpnl.getTimeSlider().setUI(new MySliderUI(bpnl.getTimeSlider())); bpnl.getSoundSlider().setUI(new MySliderUI(bpnl.getSoundSlider())); bpnl.getSongNameLabel().setForeground(getListTextColor()); bpnl.getTimeLabel().setForeground(getListTextColor());
MyTabbedPaneUI.setDefaultColor(getForegroundColor());
RightPanel.getInstance().getListTabPnl().setUI(new MyTabbedPaneUI());
RightPanel.getInstance().getListTabPnl().setForeground(getListTextColor());
MyCellRenderer.setForegroundColor(getListTextColor()); MyCellRenderer.setBackgroundColor(getForegroundColor()); MiniMusic.getInstance().setBorderColor(getListTextColor()); MiniMusic.getInstance().repaint(); }
public Color getBackgroundColor() {
return Color.decode(pp.getProperty(\ }
public Color getForegroundColor() {
return Color.decode(pp.getProperty(\ }
四川科技职业学院毕业设计(论文)
第 34 页
public Color getListTextColor() {
return Color.decode(pp.getProperty(\ }
public static MySkin getCurrentSkin() { return mySkin; } }
当点击更换按钮时弹出系统颜色选择器,如图5.3.1
图5.3.1
主要功能实现代码:
public void actionPerformed(ActionEvent e) { Object obj = e.getSource(); if (obj == ccButton) {
Color newColor = JColorChooser.showDialog(this, \更换颜色\ if (newColor != null) {
titlePanel.setSkinColor(newColor); MiniMusic.getInstance().repaint();
四川科技职业学院毕业设计(论文)
第 35 页
} }
5.4 播放按钮详细设计
播放按钮主要包括:上一曲/下一曲,播放/暂停,停止,声音:开/关。如图5.4
主要功能实现代码: /**
* 开始播放音乐 */
public static void start() {
if (player != null && !noCanPlaySong()) {
player.getGainControl().setLevel(soundSlider.getValue() / 100.0F); setSoundState(getSoundState()); player.start(); //进度条更新
SliderUpdateThread.initThread(); SliderUpdateThread.getThread().start(); SliderUpdateThread.resume();
player.addControllerListener(SongControlListener.getInstance()); playerState = PlayerState.PLAY;
psButton.setIcon(new IconTool(\ psButton.setIconPath(\
songNameLabel.setText(currentSong.getSongName()); int index = defaultSongInfo.indexOf(currentSong);
defaultSongList.setSelectedIndex(index);
LRCParse.getInstance().LoadLRC(); LRCLabel.getInstance().refresh();
四川科技职业学院毕业设计(论文)
第 36 页
PlayerInfoLabel.getInstance().refresh();
}
} /**
* 暂停音乐函数 */
public static void pause() { if (player != null) { player.stop();
playerState = PlayerState.PAUSE;
psButton.setIcon(new IconTool(\ psButton.setIconPath(\ PlayerInfoLabel.getInstance().refresh(); } } /**
* 停止播放 */
public static void stop() { if (player != null) {
playerState = PlayerState.UNREALIZED;
psButton.setIcon(new IconTool(\ psButton.setIconPath(\ SliderUpdateThread.pause();
timeSlider.setValue(0);
timeLabel.setText(\
FormatUtils.formatTime(player.getDuration().getSeconds()));
player.close();
PlayerInfoLabel.getInstance().refresh();
四川科技职业学院毕业设计(论文)
第 37 页
}
}
/**
* 清空所有信息 */
public static void clear() { if (player != null) {
playerState = PlayerState.UNREALIZED;
psButton.setIcon(new IconTool(\ psButton.setIconPath(\ SliderUpdateThread.pause(); timeSlider.setValue(0); player.close(); }
timeLabel.setText(\
songNameLabel.setText(\播放列表中没有可以播放的歌曲\
LRCLabel.getInstance().setStandOutSign(0);
} /**
* 下一首歌曲 */
public static void nextSong() { if (noCanPlaySong()) { return; }
int index = defaultSongInfo.indexOf(currentSong); if (index == defaultSongInfo.size() - 1) { index = 0;