automatizar proceso
buenas tardes me podrian colaborar con algo que me hace falta:
estoy aumatizando un bloquedo de pantalla durante 5 min, y visualiar un video
el codigo fuente es :
package SystemBlocker;
import java.awt.BorderLayout;
import java.util.Calendar;
import java.util.logging.Level;
import java.util.logging.Logger;
public class jFrameBlocked extends javax.swing.JFrame {
java.util.Calendar calendario;
int dia, mes, año, hora, minutos, segundos;
private javax.swing.JLabel label;
public static int alto;
public static int ancho;
Resolucion resolucion = new Resolucion();
/**
* Creates new form jFrameBlocked
*/
public jFrameBlocked() {
this.setUndecorated(true);//quita bordes a jframe
initComponents();
resolucion.tamaño();// obtenemos el tamaño de la pantalla
this.setDefaultCloseOperation( DO_NOTHING_ON_CLOSE );//evita cerra jframe con ALT+C
this.setExtendedState( MAXIMIZED_BOTH );//maximizado
this.setAlwaysOnTop(true);//siempre al frente
//nueva instancia de jBlocked pasando como parametros e este JFrame
new jBlocked( this ).block();
inicio();
reloj();
ColocarImagen();
}
private void inicio() {
label = new javax.swing.JLabel();
getContentPane().add(label);
label.setHorizontalAlignment(0);
setBounds(0, 0, 200, 100);
setLocationRelativeTo(null);
setDefaultCloseOperation(3);
}
private void reloj() {
calendario = new java.util.GregorianCalendar();
segundos = calendario.get(Calendar.SECOND);
javax.swing.Timer timer = new javax.swing.Timer(1000, new java.awt.event.ActionListener() {
@ Override
public void actionPerformed(java.awt.event.ActionEvent ae) {
java.util.Date actual = new java.util.Date();
calendario.setTime(actual);
dia = calendario.get(Calendar.DAY_OF_MONTH);
mes = (calendario.get(Calendar.MONTH) + 1);
año = calendario.get(Calendar.YEAR);
hora = calendario.get(Calendar.HOUR_OF_DAY);
minutos = calendario.get(Calendar.MINUTE);
segundos = calendario.get(Calendar.SECOND);
System.out.println(hora);
System.out.println(minutos);
System.out.println(segundos);
String hour = String.format("%02d : %02d : %02d", hora, minutos, segundos);
String date = String.format("%02d / %02d / %02d", dia, mes, año);
label.setText("<html><center>" + hour + "<br>" + date);
}
}
);
if(hora== 15 && minutos== 39){
try {
Thread.sleep(1000);
Thread.sleep(1000);
System.exit(0);
}
catch (InterruptedException ex) {
Logger.getLogger(jFrameBlocked.class.getName()).log(Level.SEVERE, null, ex);
}
}
if(hora== 15 && minutos== 40){
new jFrameBlocked().setVisible(true);
}
timer.start();
}
public void ColocarImagen() {
Fondo p = new Fondo(ancho,alto,"foto.jpg");
this.add( p , BorderLayout.CENTER);
p.repaint();
}
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
Entrar = new javax.swing.JButton();
fecha = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
Entrar.setText("Entrar");
Entrar.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
EntrarActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 344, Short.MAX_VALUE)
.addComponent(Entrar))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(fecha)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(fecha)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 247, Short.MAX_VALUE)
.addComponent(Entrar)
.addContainerGap())
);
pack();
}// </editor-fold>
private void EntrarActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
try {
Thread.sleep(1000);
this.dispose();
Thread.sleep(1000);
System.exit(0);
} catch (InterruptedException ex) {
Logger.getLogger(jFrameBlocked.class.getName()).log(Level.SEVERE, null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see <a href="http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html" title="http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html">http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html</a>
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(jFrameBlocked.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(jFrameBlocked.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(jFrameBlocked.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(jFrameBlocked.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new jFrameBlocked().setVisible(false);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton Entrar;
private javax.swing.JLabel fecha;
// End of variables declaration
}
<blockcode>.
este es solamente la clase con el main
- Inicie sesión o regístrese para enviar comentarios
Comentarios recientes
hace 8 semanas 6 horas
hace 12 semanas 19 horas
hace 19 semanas 4 días
hace 27 semanas 4 días
hace 30 semanas 2 días
hace 31 semanas 6 días
hace 35 semanas 15 horas
hace 35 semanas 15 horas
hace 41 semanas 14 horas
hace 42 semanas 1 día