não consigo posicionar os itens no JPanel alguém ajuda?

1 resposta
P
package visao;

import java.awt.Color;
import java.awt.Container;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

/**
 *
 * @author Paulo
 */
public class JanelaTipo extends JFrame implements ActionListener{
    private final Container c;
    private final JLabel lblTeste;
    private final JTextField txTest;
    private final JComboBox jcSelect;
    private final JButton btCadastro,btVoltar;
    private final JPanel jpCliente,jpFuncionario,jpUsuario;
    private LayoutManager FlowLayout;

    public JanelaTipo()  {
         
        
        super("Gerenciamento de Membros");
        //TEXTFIELD
        this.txTest = new JTextField();
        this.txTest.setBounds(10, 10, 100, 30);
        //JLABEL
        this.lblTeste = new JLabel("TESTANDO");
        this.lblTeste.setBounds(0, 0, 0, 0);
        
        //PANELCLIENTE
        this.jpCliente = new JPanel();
        this.jpCliente.setLayout(null);
        this.jpCliente.setBounds(100,25,405,320);
        this.jpCliente.setBackground(Color.red);        
        this.jpCliente.setVisible(false);
        
        //PANELUSER
        this.jpUsuario = new JPanel();
        this.jpUsuario.setBounds(100,25,405,320);
        this.jpUsuario.setBackground(Color.cyan);
        this.jpUsuario.setVisible(false);
        
        //PANELFUNC
        this.jpFuncionario = new JPanel();
        this.jpFuncionario.setBounds(100,25,405,320);
        this.jpFuncionario.setBackground(Color.yellow);
        this.jpFuncionario.setVisible(false);
        
        //JBUTTON
        this.btCadastro = new JButton("Cadastrar");
        this.btCadastro.setBounds(0,0,495,25);
        this.btCadastro.addActionListener(this);
        this.btCadastro.setActionCommand("btCadastro");
        
        this.btVoltar = new JButton("Voltar");
        this.btVoltar.setBounds(0, 345,495, 25);
        this.btVoltar.addActionListener(this);
        this.btVoltar.setActionCommand("btVoltar");
        
        //JCombobox
        this.jcSelect = new JComboBox();
        this.jcSelect.setBounds(0, 26, 100, 200);
        
        
        //itensJCombobox
        jcSelect.addActionListener(this);
        jcSelect.addItem("Selecionar");
        jcSelect.addItem("Usuario");
        jcSelect.addItem("Cliente");
        jcSelect.addItem("Funcionario");
        
        super.getContentPane().add(this.jcSelect);
        super.getContentPane().add(this.btCadastro);
        super.getContentPane().add(this.btVoltar);
        super.getContentPane().add(this.jpCliente);
        super.getContentPane().add(this.jpFuncionario);
        super.getContentPane().add(this.jpUsuario);
        
        
        //JANELA
        this.c = super.getContentPane();
        super.setLayout(null);
        super.setSize(500, 400);
        super.setLocationRelativeTo(null);    
        super.setResizable(false);
        super.setDefaultCloseOperation(super.EXIT_ON_CLOSE);
        super.setVisible(true);
    }

    @Override
    public void actionPerformed(ActionEvent e) {
        if(e.getActionCommand().equals(this.btVoltar.getActionCommand())){
            JanelaMembros x = new JanelaMembros();
            dispose();
    }   
        
        JComboBox itemselecionado =(JComboBox)e.getSource();  
        String selecionado = (String)itemselecionado.getSelectedItem().toString();  
        System.out.println(selecionado);
        if (selecionado.equalsIgnoreCase("Usuario")){  
            this.jpUsuario.setVisible(true);
            this.jpCliente.setVisible(false);
            this.jpFuncionario.setVisible(false);
            
      } 
        if (selecionado.equalsIgnoreCase("Cliente")){
            this.jpUsuario.setVisible(false);
            this.jpCliente.setVisible(true);
            this.jpFuncionario.setVisible(false);
        }
        if(selecionado.equalsIgnoreCase("Funcionario")){
            this.jpUsuario.setVisible(false);
            this.jpCliente.setVisible(false);
            this.jpFuncionario.setVisible(true);
        } 
        if(selecionado.equalsIgnoreCase("Selecionar")){
            this.jpUsuario.setVisible(false);
            this.jpCliente.setVisible(false);
            this.jpFuncionario.setVisible(false);
        }
        
        
        }
    
    

}

1 Resposta

ViniGodoy

http://docs.oracle.com/javase/tutorial/uiswing/layout/index.html

Criado 15 de dezembro de 2013
Ultima resposta 16 de dez. de 2013
Respostas 1
Participantes 2