Pada menu radiobutton lagu1 tulis coding di bawah ini:
private void lagu1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(evt.getActionCommand().equalsIgnoreCase("lagu1")){
try{
player1=Manager.createPlayer(new URL("file",null,"C:\\Sing nyejo.mp3"));
player1.start();
btnplay.setText("STOP");
lagu1.setText("Sing nyejo.mp3");
player2.stop();
lagu2.setText("lagu2");
lagu2.setSelected(false);
btnplay.setEnabled(true);
} catch(Exception ex){}
}
else if(evt.getActionCommand().equals("Sing nyejo.mp3")){
try{
player1.stop();
btnplay.setText("PLAY");
lagu1.setText("lagu1");
btnplay.setEnabled(false);
} catch(Exception ex){}
}
}
pada lagu2:
private void lagu2ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
if(evt.getActionCommand().equalsIgnoreCase("lagu2")){
try{
player2=Manager.createPlayer(new URL("file",null,"C:\\Wali - Aku Bukan Bang Toyib(2).mp3"));
player2.start();
btnplay.setText("STOP");
lagu2.setText("Wali - Aku Bukan Bang Toyib(2).mp3");
player1.stop();
lagu1.setText("lagu1");
lagu1.setSelected(false);
btnplay.setEnabled(true);
} catch(Exception ex){}
}
else if(evt.getActionCommand().equals("Wali - Aku Bukan Bang Toyib(2).mp3")){
try{
player2.stop();
labelmp3.removeAll();
btnplay.setText("PLAY");
lagu2.setText("lagu2");
btnplay.setEnabled(false);
} catch(Exception ex){}
}
}
Buat class baru di dalam source:
void setwarna(){
if(inputwarna.getText().equalsIgnoreCase("merah") && coba.getText().equals("1") ){
background.setBackground(Color.red);
}
else if(inputwarna.getText().equalsIgnoreCase("hijau") && coba.getText().equals("2") ){
background.setBackground(Color.green);
}
else if(inputwarna.getText().equalsIgnoreCase("kuning")&& coba.getText().equals("3")){
background.setBackground(Color.yellow);
}
else if(inputwarna.getText().equalsIgnoreCase("dedik")&& coba.getText().equals("4")){
background.setBackground(Color.blue);
}
else JOptionPane.showMessageDialog(rootPane, "warna " + inputwarna.getText() + " atau password yang anda masukkan salah");
}
pada text warna dan password tulis coding:
setwarna();
Pada button play tulis coding:
private void btnplayActionPerformed(java.awt.event.ActionEvent evt) {
if(evt.getActionCommand().equals("STOP")){
try{
player1.stop();
lagu1.setText("lagu1");
lagu1.setSelected(false);
btnplay.setText("PLAY");
player2.stop();
lagu2.setSelected(false);
lagu2.setText("lagu2");
btnplay.setEnabled(false);
} catch(Exception ex){}
}
else if(evt.getActionCommand().equals("PLAY")){
try{
btnplay.setEnabled(true);
} catch(Exception ex){}
}
// TODO add your handling code here:
}
Pada button play buat menjadi enabled false
0 komentar:
Posting Komentar