Texto em movimento horizontal

Queridos! to tentando fazer um painel que exibe mensagens em movimento horizontal, mas sem sucesso. já tentei rodar vídeo, mas fica muito pesado.
gotaria de pegar avisos do banco exibir em mensagens em movimento horizontal.
se alguem aí tiver um exemplos simples. Agradeço qualquer ajuda.

Você pode ir redefinindo sua posição em um intervalo de tempo em milisegundos, por exemplo.

Eu faria mais ou menos assim:

for (I = 0; I < Quant; I++ ) { Thread.sleep(400); // 400 milisegundos MyLabel.setBounds(x+1,y,n,m); }

Ou seja: o valor da variável Quant deve ser definido de acordo com o limite de quantas vezes você quer movimentar o jLabel. Depois você pode verificar:

if (x = PosicaoDesejada){ x = 1; // Volta para a posição inicial. }

O jLabel se move de 400 em 400 milisegundos.

Andre Rosa!

muito obrigado pela ajuda !
só hoje tive tempo de testar a dica.

abraço!

Boa tarde Andre, estou com o mesmo problema.
Porém com um agravante, preciso posicionar meu jlabel.
Vou tentar explicar o que preciso.
Bom, estou fazendo um software q em uma parte dele preciso pegar as notícias de um BD e mostra-las no software.
Até ai td tranquilo, consigo pegar as noticias d boa.
E até consigo mostra-las, porém qndo elas começam a percorrer a tela ela fica piscando.
E eu tbm preciso “esconder” a noticia na parte esquerda da tela e fazer com q ela va apareceno de acordo com o tempo.
e q a proxima noticia soh apareça na hora q a primeira noticia desapareca…

Conseguiu entender?!?!

Segue abaixo meu código… estou usando rmi… mais isso naum é problema…

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

import com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.LineBorder;
import pojo.Noticia;
import servicoremoto.ServicoRemoto;

public class PainelFrame extends JFrame {

    private JLabel lblSenha;
    private JLabel lblMesa;
    private JPanel pCabecalho;
    private JTextPane tpSenha;
    private JTextPane tpMesa;
    private JLabel lblMov;
    private JPanel pNot;

    public PainelFrame() {
        super("Gerenciador de Fila - Painel de Senha");
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setLayout(new BorderLayout());
        try {
            UIManager.setLookAndFeel(new WindowsClassicLookAndFeel());
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(PainelFrame.class.getName()).log(Level.SEVERE, null, ex);
        }

        pCabecalho = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();

        lblSenha = new JLabel("Senha");
        lblSenha.setFont(new Font("Arial", Font.ITALIC, 30));
        gbc.insets = new Insets(10, 10, 10, 10);
        gbc.gridx = 0;
        gbc.gridy = 0;
        pCabecalho.add(lblSenha, gbc);

        tpSenha = new JTextPane();
        tpSenha.setFont(new Font("Arial", Font.BOLD, 200));
        tpSenha.setText("00000");
        tpSenha.setEditable(false);
        tpSenha.setBorder(new LineBorder(Color.DARK_GRAY, 5, true));
        gbc.fill = GridBagConstraints.BOTH;
        gbc.gridx = 0;
        gbc.gridy = 1;
        pCabecalho.add(tpSenha, gbc);

        lblMesa = new JLabel("Mesa");
        lblMesa.setFont(new Font("Arial", Font.ITALIC, 30));
        gbc.fill = GridBagConstraints.NONE;
        gbc.gridx = 1;
        gbc.gridy = 0;
        pCabecalho.add(lblMesa, gbc);

        tpMesa = new JTextPane();
        tpMesa.setFont(new Font("Arial", Font.BOLD, 200));
        tpMesa.setText("C00");
        tpMesa.setEditable(false);
        tpMesa.setBorder(new LineBorder(Color.DARK_GRAY, 5, true));
        gbc.fill = GridBagConstraints.BOTH;
        gbc.gridx = 1;
        gbc.gridy = 1;
        pCabecalho.add(tpMesa, gbc);

        pNot = new JPanel(new FlowLayout(FlowLayout.RIGHT));

        lblMov = new JLabel();
        lblMov.setFont(new Font("Arial", Font.BOLD, 15));

        pNot.add(lblMov);

        this.add(pCabecalho, BorderLayout.PAGE_START);
        this.add(pNot, BorderLayout.PAGE_END);
    }

    public void display() {
        this.pack();
        this.setSize(new Dimension(1280, 1000));
        this.setResizable(false);
        this.setLocationRelativeTo(null);
        this.setVisible(true);
        this.lblMovimento();
    }

    public void lblMovimento() {
        ServicoRemoto remoteCal = ClienteRemoto.getInstance().getServicoRemoto();
        int teste;
        try {
            ArrayList<Noticia> noticias = (ArrayList<Noticia>) remoteCal.getNoticias();
            if (!noticias.isEmpty()) {
                for (Noticia noticia : noticias) {
                    teste = (int) (noticia.getNoticia().length() + (2 * this.getSize().getWidth()));
                    lblMov.setText(noticia.getNoticia());
                    for (int i = 0; i < teste; i++) {
                        Thread.sleep(1);
                        lblMov.setBounds(i, lblMov.getY(), lblMov.getWidth(), lblMov.getHeight());
                        if (i >= teste) {
                            break;
                        }
                    }
//                    Thread.sleep(5000);
                }
            }
        } catch (InterruptedException ex) {
            System.out.println(ex);
        } catch (RemoteException ex) {
            System.out.println(ex);
        } finally {
            lblMovimento();
        }
    }
}

Então é isso.

Atenciosamente,

Rafael Souza e Silva.

blz!
deu certo com a diqca do andre.
realmente ele da umas piscadas durante a mundança de lugar mesmo. Mas por enquanto doi a solução mais perfeita.
só tentei aqui com apenas uma mensagem. vou tentar com mais de uma.

Então galera…
dp de mta briga com isso aki…
consegui resolver… soh q “mudei” de concepção…
eu estava tentando fazer o lbl se mover da esquerda para a direita…
e agora ela se move da direita para a esquerda… sem ficar piscando igual antes…
segue abaixo o código… se tiverem alguma dúvida
é só me perguntar…

Att,

Rafael Souza e Silva

package painel;

import com.sun.java.swing.plaf.windows.WindowsLookAndFeel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.rmi.RemoteException;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextPane;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.border.LineBorder;
import pojo.Noticia;
import servicoremoto.ServicoRemoto;

public class PainelFrame extends JFrame {

    private JLabel lblSenha;
    private JLabel lblSenhaEstrangeiro;
    private JLabel lblMesa;
    private JLabel lblMesaEstrangeiro;
    private JPanel pCabecalho;
    private JTextPane tpSenha;
    private JTextPane tpMesa;
    private JLabel lblMov;
    private JPanel pNot;
    private JPanel pTable;

    public PainelFrame() {
        super("Gerenciador de Fila - Painel de Senha");
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);
        this.setLayout(new BorderLayout());
        try {
            UIManager.setLookAndFeel(new WindowsLookAndFeel());
        } catch (UnsupportedLookAndFeelException ex) {
            System.out.println(ex);
        }


        pCabecalho = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();

        lblSenha = new JLabel("Senha");
        lblSenha.setFont(new Font("Arial", Font.BOLD, 40));
        gbc.insets = new Insets(10, 10, 10, 10);
        gbc.fill = GridBagConstraints.BOTH;
        gbc.gridx = 0;
        gbc.gridy = 0;
        pCabecalho.add(lblSenha, gbc);

        lblSenhaEstrangeiro = new JLabel("(Password, Contraseña)");
        lblSenhaEstrangeiro.setFont(new Font("Arial", Font.ITALIC, 40));
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.gridwidth = 2;
        pCabecalho.add(lblSenhaEstrangeiro, gbc);

        tpSenha = new JTextPane();
        tpSenha.setFont(new Font("Arial", Font.BOLD, 250));
        tpSenha.setText("00000");
        tpSenha.setEditable(false);
        tpSenha.setBorder(new LineBorder(new Color(100,149,237), 5, true));
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.gridwidth = 3;
        pCabecalho.add(tpSenha, gbc);

        lblMesa = new JLabel("Mesa");
        lblMesa.setFont(new Font("Arial", Font.BOLD, 40));
        gbc.gridx = 3;
        gbc.gridy = 0;
        gbc.gridwidth = 1;
        pCabecalho.add(lblMesa, gbc);

        lblMesaEstrangeiro = new JLabel("(Table, Tabla)");
        lblMesaEstrangeiro.setFont(new Font("Arial", Font.ITALIC, 40));
        gbc.gridx = 4;
        gbc.gridy = 0;
        pCabecalho.add(lblMesaEstrangeiro, gbc);

        tpMesa = new JTextPane();
        tpMesa.setFont(new Font("Arial", Font.BOLD, 250));
        tpMesa.setText("C00");
        tpMesa.setEditable(false);
        tpMesa.setBorder(new LineBorder(Color.DARK_GRAY, 5, true));
        gbc.gridx = 3;
        gbc.gridy = 1;
        gbc.gridwidth = 2;
        pCabecalho.add(tpMesa, gbc);

        pTable = new JPanel();

        pNot = new JPanel(new FlowLayout(FlowLayout.LEFT));

        lblMov = new JLabel();
        lblMov.setFont(new Font("Arial", Font.BOLD, 40));

        pNot.add(lblMov);

        this.add(pCabecalho, BorderLayout.PAGE_START);
        this.add(pTable, BorderLayout.CENTER);
        this.add(pNot, BorderLayout.PAGE_END);
    }

    public void display() {
        this.setSize(new Dimension(1280, 1024));
        this.setLocation(-1280, 0);
        this.setUndecorated(true);
        this.setVisible(true);
        this.lblMovimento();
    }

    public void lblMovimento() {
        ServicoRemoto remoteCal = ClienteRemoto.getInstance().getServicoRemoto();
        String esp = "                                                                                                   ";
        try {
            ArrayList<Noticia> noticias = (ArrayList<Noticia>) remoteCal.getNoticias();
            if (!noticias.isEmpty()) {
                for (Noticia noticia : noticias) {
                    lblMov.setText(esp + noticia.getNoticia());
                    while (true) {
                        Thread.sleep(15);
                        lblMov.setBounds(lblMov.getX() - 1, lblMov.getY(), lblMov.getWidth(), lblMov.getHeight());
                        if (lblMov.getBounds().getMaxX() < 0) {
                            break;
                        }
                    }
                }
            }
        } catch (InterruptedException ex) {
            System.out.println(ex);
        } catch (RemoteException ex) {
            System.out.println(ex);
        } finally {
            lblMovimento();
        }
    }
}