los dos botones tenga/sean una imagen y saber como acomodarlos, darles posicion en el propio
applet para ponerlos donde yo quiero, si alguien me puede indicar si esto se puede en el
siguiente código y como, le estaré muy agradecido!
Código PHP:
package CapturarMic;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import javax.sound.sampled.*;
public class CapturarMic extends JApplet{
AudioFormat audioFormat;
TargetDataLine targetDataLine;
final JButton captureBtn = new JButton("Capturar");
final JButton stopBtn = new JButton("Parar");
final JPanel btnPanel = new JPanel();
final ButtonGroup btnGroup = new ButtonGroup();
final JRadioButton aiffBtn = new JRadioButton("AIFF");
final JRadioButton waveBtn = new JRadioButton("WAV",true);
public void init( String args[]){
new CapturarMic();
}
public CapturarMic(){
captureBtn.setEnabled(true);
stopBtn.setEnabled(false);
captureBtn.addActionListener(
new ActionListener(){
public void actionPerformed(
ActionEvent e){
captureBtn.setEnabled(false);
stopBtn.setEnabled(true);
captureAudio();
}
}
);
stopBtn.addActionListener(
new ActionListener(){
public void actionPerformed(
ActionEvent e){
captureBtn.setEnabled(true);
stopBtn.setEnabled(false);
targetDataLine.stop();
targetDataLine.close();
}
}
);
getContentPane().add(captureBtn);
getContentPane().add(stopBtn);
btnGroup.add(aiffBtn);
btnGroup.add(waveBtn);
btnPanel.add(aiffBtn);
btnPanel.add(waveBtn);
getContentPane().add(btnPanel);
getContentPane().setLayout(new FlowLayout());
setSize(300,220);
setVisible(true);
}
private void captureAudio(){
try{
audioFormat = getAudioFormat();
DataLine.Info dataLineInfo =
new DataLine.Info(
TargetDataLine.class,
audioFormat);
targetDataLine = (TargetDataLine)
AudioSystem.getLine(dataLineInfo);
new CaptureThread().start();
}catch (Exception e) {
e.printStackTrace();
System.exit(0);
}
}
private AudioFormat getAudioFormat(){
float sampleRate = 44100.0F;
int sampleSizeInBits = 16;
int channels = 1;
boolean signed = true;
boolean bigEndian = false;
return new AudioFormat(sampleRate,
sampleSizeInBits,
channels,
signed,
bigEndian);
}
class CaptureThread extends Thread{
public void run(){
AudioFileFormat.Type fileType = null;
File audioFile = null;
if(aiffBtn.isSelected()){
fileType = AudioFileFormat.Type.AIFF;
audioFile = new File("prueba.aif");
}else if(waveBtn.isSelected()){
fileType = AudioFileFormat.Type.WAVE;
audioFile = new File("c:/test1/testfermdp.wav");
}
try{
targetDataLine.open(audioFormat);
targetDataLine.start();
AudioSystem.write(
new AudioInputStream(targetDataLine),
fileType,
audioFile);
}catch (Exception e){
e.printStackTrace();
}
}
}
}