Dúvida sobre layouts [RESOLVIDO]

E aí galera, blz?!?!

seguinte, estou com um problema com layouts e não consegui pensar em nd para resolver isto.
O problema é o seguinte:

Tenho uma Frame q é um painel onde mostro senha, mesa, noticias e agora estou colocando um player de video.
Neste frame uso o BorderLayout ai na parte de cima do frame tem um label em movimento, no qual fica passando noticias.
Na parte de baixo tem os campos onde mostro a senha, mesa, etc…
e no meio eu tenho o player…
porém o border layout e dividido em 3 (West, Center, East)…

Ai eu preciso aumentar o tamanho do player e colocar outra coisa do outro lado… estou pensano em um “player” de powerpoint…
e ficar meio a meio de tamanho…

mas como eu disse… o borderlayout é dividido em 3…

tem como eu fazer esses 3 transformarem em 1 só e setar um flowlayout no panel q vai dentro dele?!?!!

ou então mudar o layout do meu frame… porém não consegui pensar em nenhum outro para fazer isso…

segue abaixo o código…

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.io.IOException;
import java.io.ObjectInputStream;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.URL;
import java.rmi.RemoteException;
import java.util.ArrayList;
import javax.media.CannotRealizeException;
import javax.media.Manager;
import javax.media.NoPlayerException;
import javax.media.Player;
import javax.media.bean.playerbean.MediaPlayer;
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 javax.swing.text.MutableAttributeSet;
import javax.swing.text.SimpleAttributeSet;
import javax.swing.text.StyleConstants;
import javax.swing.text.StyledDocument;
import pojo.Atendimento;
import pojo.Noticia;
import servicoremoto.ServicoRemoto;

public class PainelFrame extends JFrame {

    private ServerSocket server;
    private int port = 7777;
    private Socket socket;
    private JLabel lblSenha;
    private JLabel lblSenha1;
    private JLabel lblMesa;
    private JLabel lblMesa1;
    private JPanel pCabecalho;
    private JTextPane tpSenha;
    private JTextPane tpMesa;
    private JTextPane tpDpto;
    private JLabel lblMov;
    private JPanel pNot;
    private JPanel pMedia;
    private MediaPlayer mediaPlayer;

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

        pCabecalho = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        pCabecalho.setBackground(new Color(12, 55, 79));

        lblSenha = new JLabel("Senha");
        lblSenha.setFont(new Font("Arial", Font.BOLD, 80));
        lblSenha.setForeground(Color.WHITE);
        gbc.fill = GridBagConstraints.HORIZONTAL;
        gbc.gridx = 0;
        gbc.gridy = 0;
        pCabecalho.add(lblSenha, gbc);

        lblSenha1 = new JLabel();
        lblSenha1.setFont(new Font("Arial", Font.ITALIC, 60));
        lblSenha1.setForeground(Color.WHITE);
        gbc.fill = GridBagConstraints.VERTICAL;
        gbc.gridx = 1;
        gbc.gridy = 0;
        gbc.gridwidth = 2;
        pCabecalho.add(lblSenha1, gbc);

        tpSenha = new JTextPane();
        StyledDocument doc2 = tpSenha.getStyledDocument();
        MutableAttributeSet set2 = new SimpleAttributeSet();
        StyleConstants.setAlignment(set2, StyleConstants.ALIGN_CENTER);
        StyleConstants.setFontSize(set2, 250);
        StyleConstants.setFontFamily(set2, "Arial");
        StyleConstants.setBold(set2, true);
        StyleConstants.setForeground(set2, Color.BLACK);
        doc2.setParagraphAttributes(0, 0, set2, true);
        tpSenha.setEditable(false);
        tpSenha.setBorder(new LineBorder(Color.WHITE, 5, true));
        tpSenha.setBackground(Color.GRAY);
        tpSenha.setPreferredSize(new Dimension(721, 299));
        gbc.gridx = 0;
        gbc.gridy = 1;
        gbc.gridwidth = 3;
        pCabecalho.add(tpSenha, gbc);

        lblMesa = new JLabel("Mesa");
        lblMesa.setFont(new Font("Arial", Font.BOLD, 80));
        lblMesa.setForeground(Color.WHITE);
        gbc.fill = GridBagConstraints.BOTH;
        gbc.gridx = 3;
        gbc.gridy = 0;
        gbc.gridwidth = 1;
        pCabecalho.add(lblMesa, gbc);

        lblMesa1 = new JLabel();
        lblMesa1.setFont(new Font("Arial", Font.ITALIC, 60));
        lblMesa1.setForeground(Color.WHITE);
        gbc.fill = GridBagConstraints.VERTICAL;
        gbc.gridx = 4;
        gbc.gridy = 0;
        pCabecalho.add(lblMesa1, gbc);

        tpMesa = new JTextPane();
        StyledDocument doc = tpMesa.getStyledDocument();
        MutableAttributeSet set = new SimpleAttributeSet();
        StyleConstants.setAlignment(set, StyleConstants.ALIGN_CENTER);
        StyleConstants.setFontSize(set, 250);
        StyleConstants.setFontFamily(set, "Arial");
        StyleConstants.setBold(set, true);
        StyleConstants.setForeground(set, Color.WHITE);
        doc.setParagraphAttributes(0, 0, set, true);
        tpMesa.setEditable(false);
        tpMesa.setBorder(new LineBorder(Color.WHITE, 5, true));
        tpMesa.setBackground(new Color(12, 55, 79));
        tpMesa.setPreferredSize(new Dimension(500, 299));
        gbc.insets = new Insets(0, 5, 0, 0);
        gbc.gridx = 3;
        gbc.gridy = 1;
        gbc.gridwidth = 2;
        gbc.gridheight = 2;
        pCabecalho.add(tpMesa, gbc);

        tpDpto = new JTextPane();
        StyledDocument doc3 = tpDpto.getStyledDocument();
        MutableAttributeSet set3 = new SimpleAttributeSet();
        StyleConstants.setAlignment(set3, StyleConstants.ALIGN_CENTER);
        StyleConstants.setFontSize(set3, 80);
        StyleConstants.setFontFamily(set3, "Arial");
        StyleConstants.setItalic(set3, true);
        StyleConstants.setForeground(set3, Color.WHITE);
        doc3.setParagraphAttributes(0, 0, set3, true);
        tpDpto.setEditable(false);
        tpDpto.setBorder(new LineBorder(Color.WHITE, 5, true));
        tpDpto.setBackground(new Color(12, 55, 79));
        gbc.fill = GridBagConstraints.BOTH;
        gbc.insets = new Insets(5, 0, 0, 0);
        gbc.gridx = 0;
        gbc.gridy = 2;
        gbc.gridwidth = 5;
        pCabecalho.add(tpDpto, gbc);

        pMedia = new JPanel();
        pMedia.setBorder(new LineBorder(Color.yellow));
        pMedia.setBackground(new Color(12, 55, 79));


        Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);

        try {
            mediaPlayer = new MediaPlayer();
            Player player = Manager.createRealizedPlayer(new URL("file:/F:/javaVideo/Fig21_06_07/bailey.mpg"));
            mediaPlayer.setSize(pMedia.getWidth(), pMedia.getHeight());
            mediaPlayer.setPlayer(player);
            pMedia.add(mediaPlayer);
            mediaPlayer.setPlaybackLoop(true);
            mediaPlayer.start(); // start playing the media clip
        } catch (CannotRealizeException ex) {
            System.out.println(ex);
        } catch (NoPlayerException ex) {
            System.out.println(ex);
        } catch (IOException ex) {
            System.out.println(ex);
        }

        pNot = new JPanel(new FlowLayout(FlowLayout.LEFT));
        pNot.setBackground(new Color(12, 55, 79));

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

        pNot.add(lblMov);

        this.getContentPane().add(pNot, BorderLayout.NORTH);
        this.getContentPane().add(pMedia, BorderLayout.CENTER);
        this.getContentPane().add(pCabecalho, BorderLayout.SOUTH);
    }

    public void display() {
        this.setSize(new Dimension(1280, 1024));
        this.setLocation(1280, 0);
        this.setUndecorated(true);
        this.setVisible(true);
        Thread t = new Thread(new lblMovimento(lblMov));
        t.start();
        Thread t1 = new Thread(new lblTroca(lblSenha1, lblMesa1));
        t1.start();
        this.handleConnection();
    }

    public void handleConnection() {
        while (true) {
            try {
                socket = server.accept();
                Thread t = new Thread(new novaSenha(tpSenha, tpMesa, socket, tpDpto, mediaPlayer));
                t.setPriority(t.MAX_PRIORITY);
                t.start();
                t.join();
            } catch (InterruptedException ex) {
                System.out.println(ex);
            } catch (IOException e) {
                System.out.println(e);
            }
        }
    }
}

class lblTroca implements Runnable {

    private JLabel lblSenha;
    private JLabel lblMesa;
    private String[] stringsSenha = {"Password", "Contraseña"};
    private String[] stringsMesa = {"Table", "Tabla"};
    private int i = 0;

    public lblTroca(JLabel lblSenha, JLabel lblMesa) {
        this.lblSenha = lblSenha;
        this.lblMesa = lblMesa;
    }

    public void run() {
        try {
            while (true) {
                lblSenha.setText(stringsSenha[i]);
                lblMesa.setText(stringsMesa[i]);
                Thread.sleep(5000);
                i++;
                if (i == 2) {
                    i = 0;
                }
            }
        } catch (InterruptedException ex) {
            System.out.println(ex);
        } finally {
            new Thread(new lblTroca(lblSenha, lblMesa));
        }
    }
}

class novaSenha implements Runnable {

    JTextPane tpSenha;
    JTextPane tpMesa;
    JTextPane tpDpto;
    Socket socket;
    Atendimento atendimento;
    boolean teste;
    int qtde;
    MediaPlayer mediaPlayer;

    public novaSenha(JTextPane tpSen, JTextPane tpMe, Socket sock, JTextPane tpDp, MediaPlayer mp) {
        this.tpSenha = tpSen;
        this.tpMesa = tpMe;
        this.socket = sock;
        this.tpDpto = tpDp;
        this.mediaPlayer = mp;
    }

    public void run() {

        try {
            ObjectInputStream ois = new ObjectInputStream(socket.getInputStream());
            atendimento = (Atendimento) ois.readObject();
            addAtendimento(atendimento);

            ois.close();
            socket.close();
        } catch (IOException e) {
            System.out.println(e);
        } catch (ClassNotFoundException e) {
            System.out.println(e);
        }
    }

    public synchronized void addAtendimento(Atendimento a) {
        if (a != null) {
            exibirAtendimento(true);
        } else {
            exibirAtendimento(false);
        }
    }

    public void exibirAtendimento(boolean tipo) {
        synchronized (this) {
            if (tipo) {
                tpSenha.setText(atendimento.getSenha());
                tpMesa.setText(atendimento.getMesa().getNumMesa());
                tpDpto.setText(atendimento.getServico().toUpperCase());
                new AePlayWave("D:\\Workspace\\wave\\dingdong.wav").start();
                System.out.println(mediaPlayer.getBounds());
                try {
                    this.wait(3000);
                } catch (InterruptedException ex) {
                    System.out.println(ex);
                }
            } else {
                tpSenha.setText(null);
                tpMesa.setText(null);
            }

        }

    }
}

class lblMovimento implements Runnable {

    JLabel lblMov;
    int desloc = 0;

    public lblMovimento(JLabel label) {
        lblMov = label;
    }

    public void run() {
        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());
                    desloc = (int) lblMov.getBounds().getMaxX();
                    while (true) {
                        Thread.sleep(15);
                        lblMov.setBounds(desloc - 1, lblMov.getY(), lblMov.getWidth(), lblMov.getHeight());
                        desloc -= 1;
                        if (lblMov.getBounds().getMaxX() < 0) {
                            break;
                        }
                    }
                }
            }
        } catch (InterruptedException ex) {
            System.out.println(ex);
        } catch (RemoteException ex) {
            System.out.println(ex);
        } finally {
            Thread t = new Thread(new lblMovimento(lblMov));
            t.start();
        }
    }
}

Então é isso galera…

Antecipadamente,

Obrigado.

Rafael Souza e Silva.

Bom dia,

Não vou entrar na parte de código, pois você sabe o que está fazendo :smiley:

O que você pode fazer é inserir um JPanel (para o player) dentro do JPanel principal (o que têm o BorderLayout) e usar outro layout dentro dele.
Todas as vezes que você precisar de uma layout diferenciado para um segmento do BorderLayout, você insere um JPanel naquele segmento e usa o layout de sua preferência.

Mesmo se eu tiver entendido errado, esses efeitos que você quer, você consegue com composições de JPanel’s, cada um com o layout necessário, conforme você citou na pergunta.

Ou então, você pode pesquisar layouts mais complexos, não necessariamente os do pacote JAVA, mas de bibliotecas externas. Há alguns de grid, que divide o JPanel em células e você vai posicionando. Ou ha outros que divide em linhas e você vai posicionando os elementos por linha… bom, aí a quantidade de opções é extensa…

Voce pode criar um Layout composto, onde voce tem um JPanel que representa o Player com um LayoutManager proprio, e adiciona esse panel em um JPanel maior que é a sua janela.

Obrigado a todos…

consegui o q queria usando layout composto msm…

Vlwss pela dica…

:smiley: