我已经搜索并阅读了其他主题,但我仍然无法解决我的问题。我有一个 java 主类和一个 java jframe。我想添加 jslider 来改变我的 mp3 播放器的音量。我应该怎么办?
my_player2_func
class my_player2_func{ 静态播放器播放器;
static void play() {
try {
FileInputStream fe = new FileInputStream(my_player2_main.str);
player = new Player(fe);
} catch (Exception ex) {
System.out.println(ex);
}
new Thread(new Runnable() {
@Override
public void run() {
try {
player.play();
} catch (Exception ex) {
System.out.println(ex);
}
}
}).start();
}
static void stop() {
if (player != null)
player.close();
} }
my_player2_main
public my_player2_main() {
initComponents();
}
static String str;
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
my_player2_func.play();
}
private void jSlider1StateChanged(javax.swing.event.ChangeEvent evt) {//what should i do here?}