Barra de Status Dúvida!

Olá pessoal sou novo por aqui e em Java também, mas andei brincando um pouco e ai surgiu a seguinte dúvida:

Tenho uma classe BarraStatus:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import java.awt.Toolkit;
import java.awt.event.KeyEvent;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;
import javax.swing.JLabel;

/**
 *
 * @author Denir R. Tavares
 */
public class BarraStatus {
    JLabel data, hora, usuario, caps, num, scroll;

    public JLabel Data(){
        data = new JLabel();
        Timer timer = new Timer();
        TimerTask task = new TimerTask() {
            public void run() {
                data.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date(System.currentTimeMillis())));
            }
        };
        timer.schedule(task, 1000, 1000);
        return data;
    }

    public JLabel Hora(){
        hora = new JLabel();
        Timer timer = new Timer();
        TimerTask task = new TimerTask() {
            public void run() {
                hora.setText(new SimpleDateFormat("HH:mm:ss").format(new Date(System.currentTimeMillis())));
            }
        };
        timer.schedule(task, 1000, 1000);
        return hora;
    }

    public JLabel Usuario(){

        return usuario;
    }

    public JLabel CapsLock(){
        boolean capsLigado = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
        if (capsLigado) {
            caps.setText("MAI");
        } else {
            caps.setText("min");
        }
        return caps;
    }

    public JLabel NumLock(){
        boolean capsLigado = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_NUM_LOCK);
        if (capsLigado) {
            num.setText("NUM");
        } else {
            num.setText("num");
        }
        return num;
    }

    public JLabel ScrollLock(){
        boolean capsLigado = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_SCROLL_LOCK);
        if (capsLigado) {
            scroll.setText("SCR");
        } else {
            scroll.setText("scr");
        }
        return scroll;
    }
}


E na minha classe JFrame estou envocando o seguinte dentro de initComponentes
public Principal() {
        initComponents();
        BarraStatus br = new BarraStatus();
        JLabel Data = br.Data();
        jlblData.setText(Data.getText());
    }

Dentro desta classe tenho uma barra de status com jlabels só que não aparece valor algum fica em branco. Como posso resolver esse problemão.

bom… vc ta retornando os labels…
queria saber como ta essa barra de status

la vc cria um label e atribui com esses q vc retorna? eh isso?
se for pode ser preciso dar um repaint e tal… como ta la?

[quote=redr4gon]bom… vc ta retornando os labels…
queria saber como ta essa barra de status

la vc cria um label e atribui com esses q vc retorna? eh isso?
se for pode ser preciso dar um repaint e tal… como ta la?[/quote]

É isso mesmo parceiro, em BarraStatus eu tenho os códigos ou métodos e no JFrame principal eu tenho as JLabels, ai eu só preciso chamar esses códigos esses códigos da BarraStatus pra executarem no JFrame Principal.

Tipo BarraStatus

public class BarraStatus {
    JLabel data, hora, usuario, caps, num, scroll;

    public JLabel Data(){
        Timer timer = new Timer();
        TimerTask task = new TimerTask() {
            public void run() {
                data.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date(System.currentTimeMillis()))); //Tem que retornar esse resultado
            }
        };
        timer.schedule(task, 1, 1000);
        return data;
    }

JFrame Principal

public class Principal extends javax.swing.JFrame {

    /** Creates new form Principal */
    public Principal() {
        initComponents();
        
        BarraStatus br = new BarraStatus();
        JLabel data = br.data;
        jlblData.setText(data.getText()); //Está retornando vazio

I ai parceiro, como corrijo isso???

Kra… fiz seu codigo aqui e mexi pouco nele e ja funcionou…
O provavel problema é na label jlblData que vc criou… vc nao mostra como criou ela entao talvez seja nela o problema
Tente colocar uma string qualquer ali no settext dela e veja se ele aparece no frame

Vou colocar o codigo que funcionou aqui pra vc testar ae… esse RedFrame eh um frame vazio sem nada então ele nem tem a ver com a historia =p
A classe main esta em outro lugar apenas criando essa classe e chamando o metodo executa()

Conselho de amigo… use padronização de nomenclatura pra escrever os codigos que fica melhor
http://www.oracle.com/technetwork/java/codeconvtoc-136057.html

[code]public class ClassRedTest extends RedFrame {

JLabel jlblData = new JLabel("teste");
JLabel data, hora, usuario, caps, num, scroll; 

public ClassRedTest (String title) throws HeadlessException {
	super(title);
	
    jlblData.setBounds(100, 120, 50, 100);
add( jlblData );
}


public JLabel getData(){  
    data = new JLabel();  
    Timer timer = new Timer();  
    TimerTask task = new TimerTask() {  
        public void run() {  
            data.setText(new SimpleDateFormat("dd/MM/yyyy").format(new Date(System.currentTimeMillis())));  
        }  
    };  
    timer.schedule(task, 1000, 1000);  
    return data;  
}  

public JLabel getHora(){  
    hora = new JLabel();  
    Timer timer = new Timer();  
    TimerTask task = new TimerTask() {  
        public void run() {  
            hora.setText(new SimpleDateFormat("HH:mm:ss").format(new Date(System.currentTimeMillis())));  
        }  
    };  
    timer.schedule(task, 1000, 1000);  
    return hora;  
}  

public JLabel Usuario(){  
    return usuario;  
}  

public JLabel CapsLock(){  
    boolean capsLigado = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);  
    if (capsLigado) {  
        caps.setText("MAI");  
    } else {  
        caps.setText("min");  
    }  
    return caps;  
}  

public JLabel NumLock(){  
    boolean capsLigado = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_NUM_LOCK);  
    if (capsLigado) {  
        num.setText("NUM");  
    } else {  
        num.setText("num");  
    }  
    return num;  
}  

public JLabel ScrollLock(){  
    boolean capsLigado = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_SCROLL_LOCK);  
    if (capsLigado) {  
        scroll.setText("SCR");  
    } else {  
        scroll.setText("scr");  
    }  
    return scroll;  
}  

public void executa() {
	JLabel data = getData();  
	jlblData.setText( data.getText() );  
}

} [/code]

Veja se foi util… Abraços.

Num deu certo velho, ta difícil resolver essa bagaça kkk.