Ver Mensaje Individual
  #9 (permalink)  
Antiguo 09/08/2014, 04:33
yesod91
 
Fecha de Ingreso: julio-2014
Ubicación: España
Mensajes: 83
Antigüedad: 9 años, 9 meses
Puntos: 2
Respuesta: Hilo isRunning()

El problema es que C.join() no me deja ponerlo, no me da la opción...la opción de isRunning() la tuve que crear yo a mano...

Código PHP:
    public boolean isRunning(){
        return 
mRun;
    } 
Aqui esta la otra parte de código.

Código PHP:
public class AutoClick extends JFrame implements RunnableEventListener{
    static 
AutoClick AC null;
    static 
Thread Hilo null;
    
Contador C null;
    
Thread HiloC null;
    
int x,ylastTime 3lastTimeContador=0random=0;
    
String s=""j="";
    
    private static final 
long serialVersionUID = -448017304606349615L;
    private 
JPanel contentPane;
    private 
JTextField CoorXFieldCoorYFieldTiempoMinTiempoMax;
    private 
JButton EjecutarPararSalir;
    private 
JLabel CoorXCoorYTiempoHastaClickTiempoClickOpAvanzadasTiempoDeseadoLabelMinLabelMax;

    
/**
     * Launch the application.
     * Guardar las coordenadas x, y en una variable y, cuando llegue el tiempo a 0, comprobar que son iguales para mover
     * o no el ratón
     */
    
public static void main(String[] args) {
        
AC = new AutoClick();
        
Hilo = new Thread(AC);
        
Hilo.start();
    }
         public 
AutoClick() {
        
initComponents();
        
// Propiedades del JFrame
        
this.setAlwaysOnTop(true);
        
this.setVisible(true);
        
this.setLocation(new Point(600280));
        
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
this.setBounds(100100282289);
        
this.setLocationRelativeTo(null);
        
this.setResizable(false);
        
// Iniciamos el timer1 -> Captura las coordenadas del ratón
        
timer1.start();
        
//Instanciamos un objeto de tipo InputMap
        
InputMap map = new InputMap();
        
// Funciones para genera un evento de la tecla enter
        
map.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER0false), "pressed");
        
map.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER0true), "released");
        
// Le asignamos el evento al siguiente botón            
        
Parar.setInputMap(0map);
public 
void Timer3() throws InterruptedException {
        try {
            
timer2.start();
            
quitarAlways(true);
        } 
finally {}
    }
    public 
void quitarAlways(boolean valor){
        
this.setAlwaysOnTop(valor);
    }
    private 
void initComponents() {
        
contentPane = new JPanel();
        
contentPane.setBorder(new EmptyBorder(5555));
        
setContentPane(contentPane);
        
contentPane.setLayout(null);
        
        
// Añadirmos los JLabel del entorno gráfico        
        
CoorX = new JLabel();
        
CoorX.setText("Coordenada X");
        
CoorX.setBounds(20119614);
        
contentPane.add(CoorX);
        
        
CoorY = new JLabel();
        
CoorY.setText("Coordenada Y");
        
CoorY.setBounds(1261110214);
        
contentPane.add(CoorY);
        
        
TiempoHastaClick= new JLabel();
        
TiempoHastaClick.setText("Tiempo hasta el siguiente autoclick:");
        
TiempoHastaClick.setBounds(107421014);
        
contentPane.add(TiempoHastaClick);
        
        
TiempoClick = new JLabel();
        
TiempoClick.setText("0");
        
TiempoClick.setMinimumSize(new Dimension(3012));
        
TiempoClick.setBounds(219747214);
        
contentPane.add(TiempoClick);
        
        
OpAvanzadas = new JLabel();
        
OpAvanzadas.setText("Opciones Avanzadas");
        
OpAvanzadas.setFont(new Font("Tahoma"Font.BOLD12));
        
OpAvanzadas.setBounds(2011112415);
        
contentPane.add(OpAvanzadas);
        
        
TiempoDeseado = new JLabel();
        
TiempoDeseado.setText("Establecer tiempo deseado en minutos");
        
TiempoDeseado.setBounds(2014424414);
        
contentPane.add(TiempoDeseado);
        
        
LabelMin = new JLabel();
        
LabelMin.setText("Tiempo m\u00EDnimo");
        
LabelMin.setBounds(3016710214);
        
contentPane.add(LabelMin);
        
        
LabelMax = new JLabel();
        
LabelMax.setText("Tiempo m\u00E1ximo");
        
LabelMax.setBounds(3019510214);
        
contentPane.add(LabelMax);
        
        
// Añadimos las casillas para introducir texto
        
CoorXField = new JTextField();
        
CoorXField.setEditable(false);
        
CoorXField.setBounds(20439620);
        
contentPane.add(CoorXField);
        
        
CoorYField = new JTextField();
        
CoorYField.setEditable(false);
        
CoorYField.setBounds(1264310220);
        
contentPane.add(CoorYField);
        
        
JSeparator separator = new JSeparator();
        
separator.setBounds(09927610);
        
contentPane.add(separator);
        
        
TiempoMin = new JFormattedTextField();
        
TiempoMin.setBounds(1601643520);
        
contentPane.add(TiempoMin);
        
        
TiempoMax = new JFormattedTextField();
        
TiempoMax.setBounds(1601923520);
        
contentPane.add(TiempoMax);
        
        
// Añadimos los botones de interacción que podrá usar el usuario
        
Ejecutar = new JButton();
        
Ejecutar.addActionListener(new ActionListener() {
            public 
void actionPerformed(ActionEvent e) {
                
quitarAlways(false);
                
System.out.println("Running");
                
// Instancio la clase "Contador" como nuevo hilo para controlar su funcionamiento
                 
= new Contador() {
                    private static final 
long serialVersionUID = -1975397236546297348L;
                    public 
void run() {
                        try {
                            
// Mientras "Contador" esté funcionando, esta clase esta a la espera de que termine
                            
while (C.isRunning()){
                                
System.out.println("dentro");
                            }
                            
timer2.start();
                        } catch (
Exception e){
                            
e.printStackTrace();
                        }
                    }
                };
                
HiloC = new Thread(C);
                
HiloC.start();
            }
        });
        
Ejecutar.setText("Ejecutar");
        
Ejecutar.setBounds(102308223);
        
contentPane.add(Ejecutar);
        
        
Parar = new JButton();
        
Parar.addActionListener(new ActionListener() {
            public 
void actionPerformed(ActionEvent e) {
                 
timer1.stop();
                 
timer2.stop();
            }
        });
        
Parar.setText("Stop");
        
Parar.setBounds(1022307423);
        
contentPane.add(Parar);
        
        
Salir = new JButton();
        
Salir.addActionListener(new ActionListener() {
            public 
void actionPerformed(ActionEvent arg0) {
                
dispose();
                
System.exit(0);
            }
        });
        
Salir.setText("Salir");
        
Salir.setBounds(1892307523);
        
contentPane.add(Salir);
    }
    public 
void run() {
    }


Última edición por yesod91; 09/08/2014 a las 04:54