Foros del Web » Programación para mayores de 30 ;) » Java »

Imagen como fondo en applet y botones: Como se hace???

Estas en el tema de Imagen como fondo en applet y botones: Como se hace??? en el foro de Java en Foros del Web. Hola! quisiera hacer que mi applet tenga un fondo de color o una imagen, y si es posible que los dos botones tenga/sean una imagen ...
  #1 (permalink)  
Antiguo 10/05/2009, 13:57
 
Fecha de Ingreso: diciembre-2001
Ubicación: Mar del Plata
Mensajes: 203
Antigüedad: 22 años, 4 meses
Puntos: 0
Imagen como fondo en applet y botones: Como se hace???

Hola! quisiera hacer que mi applet tenga un fondo de color o una imagen, y si es posible que

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 initString 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();
    }
  }
}

__________________
:) Fernando Dichiera (:
[email protected]
  #2 (permalink)  
Antiguo 11/05/2009, 15:26
 
Fecha de Ingreso: diciembre-2001
Ubicación: Mar del Plata
Mensajes: 203
Antigüedad: 22 años, 4 meses
Puntos: 0
Respuesta: Imagen como fondo en applet y botones: Como se hace???

Alguna idea, o ayuda? Desde ya gracias!
__________________
:) Fernando Dichiera (:
[email protected]
  #3 (permalink)  
Antiguo 23/06/2009, 20:55
 
Fecha de Ingreso: diciembre-2001
Ubicación: Mar del Plata
Mensajes: 203
Antigüedad: 22 años, 4 meses
Puntos: 0
Respuesta: Imagen como fondo en applet y botones: Como se hace???

Quizas alguién vuelve a leer este post y puede ayudarme, dado que no puedo lograr lo que quiero. Muy amables!
__________________
:) Fernando Dichiera (:
[email protected]
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:15.