que tal otra vez yo con mis preguntas tengo el siguiente codigo para imprimirlo en consola me esta funcionando bien el problema es cuando lo hago grafico
public class Controlador extends Thread{
public void run(){
while(true){
SimpleDateFormat x= new SimpleDateFormat("h:mm:ss a");
Date today= new Date();
String resp= new String(x.format(today.getTime()));
if(resp.equals("8:47:30 PM"))
System.out.println("es la otra otra hora");
try {
sleep(700);
}
catch(InterruptedException e) {
return;
}
}
}
}
///////esto es lo que estoy tratando de hacer
public class Window extends javax.swing.JFrame implements Runnable{
public Window() {
initComponents();
}
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
jTextArea1 = new javax.swing.JTextArea();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jTextArea1.setColumns(20);
jTextArea1.setRows(5);
jScrollPane1.setViewportView(jTextArea1);
jMenu1.setText("menu");
jMenuItem1.setText("Item");
jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem1ActionPerformed(evt);
}
});
jMenu1.add(jMenuItem1);
jMenuBar1.add(jMenu1);
setJMenuBar(jMenuBar1);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 510, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.addContainerGap(19, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap(12, Short.MAX_VALUE)
.add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 438, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(22, 22, 22))
);
pack();
}
private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {
this.run();
}
public void run(){
while(true){
SimpleDateFormat x= new SimpleDateFormat("h:mm:ss a");
Date today= new Date();
String resp= new String(x.format(today.getTime()));
el problema esta aqui que no puedo poner el metodo sleep(700) entonces se me come toda la maquina
}
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Window().setVisible(true);
}
});
}
}