Os pongo el codigo, ya se que hay algunas cosas que no sirven de nada, pero mas adelante me serviran con el projecto.
Gracias
Código PHP:
import java.awt.Container;
import java.awt.FileDialog;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.io.File;
import javax.rmi.CORBA.Util;
import javax.swing.*;
import javax.swing.filechooser.FileNameExtensionFilter;
public class Traducir extends JFrame implements ActionListener{
private JTextField texto;
private JButton boton;
private JButton boton2;
private JButton boton3;
public String linea1;
public String linea2;
public String t;
public String ruta;
public File file;
public File fichero;
public JFileChooser dialogoArchivo ;
public Traducir(){
super("Traducir");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setSize(400, 400);
this.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
texto = new JTextField(400);
boton = new JButton("Seleccionar");
boton2 = new JButton("Limpiar");
boton3 = new JButton("Traducir");
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(boton,gbc);
boton.addActionListener(this);
gbc.gridx = 1;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(boton2,gbc);
boton2.addActionListener(this);
gbc.gridx = 3;
gbc.gridy = 0;
gbc.gridwidth = 1;
gbc.gridheight = 1;
gbc.weightx = 1.0;
gbc.weighty = 0.0;
gbc.fill = gbc.HORIZONTAL;
add(boton3,gbc);
boton3.addActionListener(this);
gbc.gridx = 0;
gbc.gridy = 1;
gbc.gridwidth = 4;
gbc.gridheight = 1;
gbc.weightx = 1.0;
gbc.weighty = 1.0;
gbc.fill = GridBagConstraints.HORIZONTAL;
add(texto,gbc);
texto.addActionListener(this);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e){
if(e.getSource()==boton){
Container frame = this;
JFileChooser dialogoArchivo = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"Avi", "avi");
dialogoArchivo.setFileFilter(filter);
int returnVal = dialogoArchivo.showOpenDialog(frame);
if (returnVal == JFileChooser.APPROVE_OPTION) {
String t = dialogoArchivo.getCurrentDirectory()+"\\"+ dialogoArchivo.getSelectedFile();
String ruta = dialogoArchivo.getCurrentDirectory()+"\\"+ dialogoArchivo.getSelectedFile();
texto.setText(t);
File fichero = dialogoArchivo.getSelectedFile();
}
File file = dialogoArchivo.getSelectedFile();
}
if(e.getSource()==boton2){
String t2 = "";
texto.setText(t2);
}
if(e.getSource()==boton3){
try
{
String [] linea2 = new String [];
String linea1 = "cmd /c start C:\\Workspace\\Ventana\\src\\a.bat";
String linea3 = "C:/Program Files (x86)/VideoLAN/VLC/vlc.exe";
Process procesos = Runtime.getRuntime().exec(linea3);
}
catch( Exception e1)
{
e1.printStackTrace();
}
}
}
}