***** abrir/chamar uma nova tela em client/server *****

2 respostas
mictexx

//////Eu tenho essa classe abaixo(“Painels.class”), que é uma tela com esses campos e botoes

classe Painels…

/////esse aqui é o metodo

public void socios2()

{

setTitle(Mictex Locadora 2004 - .:: Win2K / Oracle 9i / Java ::.”);

setBackground(Color.lightGray);

setSize(780, 220);

setResizable(false);
addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});

pj = new Panel();

pj.setLayout(new BorderLayout());

p1 = new Panel();

list1 = new java.awt.List(2,false);

list1.addItemListener(this);

l6 = new Label("Código: ");

p1.add(l6);

p1.add(list1);

pj.add(p1, North);
p2 = new Panel();

p2.setLayout(new GridLayout(5,3));

l1 = new Label("Nome: ", Label.RIGHT);

l2 = new Label("Endereço: ", Label.RIGHT);

l3 = new Label("CPF: ", Label.RIGHT);

l4 = new Label("RG: ", Label.RIGHT);

l5 = new Label("Telefone: ", Label.RIGHT);

l6 = new Label("email: ", Label.RIGHT);

l7 = new Label("Nascimento: ", Label.RIGHT);

l8 = new Label("ddmmrr: ", Label.RIGHT);

l9 = new Label("ddmmrr: ", Label.RIGHT);

t1 = new TextField(40);

t2 = new TextField(40);

t3 = new TextField(40);

t4 = new TextField(40);

t5 = new TextField(40);

t6 = new TextField(40);

t7 = new TextField(40);

t8 = new TextField(40);

t9 = new TextField(40);

p2.add(l1); p2.add(t1);p2.add(new Label());

p2.add(l2); p2.add(t2);p2.add(new Label());

p2.add(l3); p2.add(t3);p2.add(new Label());

p2.add(l4); p2.add(t4);p2.add(new Label());

p2.add(l5); p2.add(t5);p2.add(new Label());

p2.add(l6); p2.add(t6);p2.add(new Label());

p2.add(l7); p2.add(t7);p2.add(new Label());

p2.add(l; p2.add(t;p2.add(new Label());

p2.add(l9); p2.add(t9);p2.add(new Label());

pj.add(p2, Center);
p3 = new Panel();

b1 = new Button(Incluir); b1.addActionListener(this); p3.add(b1);

b2 = new Button(Alterar); b2.addActionListener(this); p3.add(b2);

b3 = new Button(Excluir); b3.addActionListener(this); p3.add(b3);

b4 = new Button(Consultar); b4.addActionListener(this); p3.add(b4);

b5 = new Button(Sair); b5.addActionListener(this); p3.add(b5);

pj.add(p3, South);

add(pj);
}

/////////////Em uma outra classe “TesteDB1.class”

eu acrescentei as linhas:

Painels T = new Painels();
T.socios2();

////////////quando estou chamando esse metodo da outra classe(por um botão) não abre uma nova tela,

ai que entra minha dúvida:

a primeira classe abre uma telinha de cadastro;

quando eu clicar no botao dessa tela teria que executar o comando abaixo:

Painels T = new Painels();

T.socios2();

e abrir uma nova tela.

Por que não esta abrindo uma nova tela?

OBS: todas compilam com sucesso!!!

Grato Michel :cry:

2 Respostas

_fs

Cara, coloca o seu trecho de código onde isto era para acontecer.

ps.: quando postar código, coloque-o entre as tags [ code]seucodigo[ /code], assim ele fica endentado :smiley:

ps2.: não precisa colocar o titulo do topico todo chamativo e em caixa alta, até onde sei todo mundo lê todos os topicos :wink:

mictexx

O TRECHO ESTA ABAIXO DETALHADO ASSIM:

"////////////////////////TRECHO -----INICIO-----------aqui

na public void ler"


import java.awt.<em>;

import java.awt.event.</em>;

import java.sql.<em>;

import java.util.</em>;
public class TesteBD1 extends Frame implements ActionListener, ItemListener

{

Panel p, p1, p2, p3;

Button b1, b2, b3, b4, b5, b6;

java.awt.List list1;

TextField t1, t2, t3, t4, t5;

Label l1, l2, l3, l4, l5, l6;

String urlODBC = jdbc:odbc:TesteBD;

Vector listaDeFuncionarios;
TesteBD1()

{

setTitle(">> Cadastro de Contatos - .:: Oracle 9i / Java ::.");

setSize(780, 220);

setResizable(false);
addWindowListener(new WindowAdapter(){public void windowClosing(WindowEvent e){System.exit(0);}});
p = new Panel();
p.setLayout(new BorderLayout());
p1 = new Panel();
list1 = new java.awt.List(2,false);
list1.addItemListener(this);
l6 = new Label("Escolha: ");
p1.add(l6);
p1.add(list1);
p.add(p1, "North");

p2 = new Panel();
p2.setLayout(new GridLayout(5,3));
l1 = new Label("Nome: ", Label.RIGHT);
l2 = new Label("Endereço: ", Label.RIGHT);
l3 = new Label("Salário: ", Label.RIGHT);
l4 = new Label("Data de contratação: ", Label.RIGHT);
l5 = new Label("Optante (Sim/Não): ", Label.RIGHT);
t1 = new TextField(40);
t2 = new TextField(40);
t3 = new TextField(40);
t4 = new TextField(40);
t5 = new TextField(40);
p2.add(l1); p2.add(t1);p2.add(new Label());
p2.add(l2); p2.add(t2);p2.add(new Label());
p2.add(l3); p2.add(t3);p2.add(new Label());
p2.add(l4); p2.add(t4);p2.add(new Label());
p2.add(l5); p2.add(t5);p2.add(new Label());
p.add(p2, "Center");

p3 = new Panel();
b1 = new Button("Limpar");       b1.addActionListener(this); p3.add(b1);
b2 = new Button("Incluir");      b2.addActionListener(this); p3.add(b2);
b3 = new Button("Alterar");      b3.addActionListener(this); p3.add(b3);
b4 = new Button("Excluir");      b4.addActionListener(this); p3.add(b4);
b5 = new Button("Ler da Tabela");b5.addActionListener(this); p3.add(b5);
b6 = new Button("Encerrar");     b6.addActionListener(this); p3.add(b6);
p.add(p3, "South");

add(p);

}

public void actionPerformed(ActionEvent evt)

{

String arg = evt.getActionCommand();

if (arg.equals(Limpar))

limpar();

else

if (arg.equals(Ler da Tabela))

ler();

else

if (arg.equals(Excluir))

excluir();

else

if (arg.equals(Incluir))

incluir();

else

if (arg.equals(Alterar))

alterar();

else

if (arg.equals(Encerrar))

System.exit(0);

}
public void itemStateChanged(ItemEvent evt)

{

int qual = list1.getSelectedIndex();

atualizaTela(qual);

}
public void limpar()

{

t1.setText("");

t2.setText("");

t3.setText("");

t4.setText("");

t5.setText(Não);

}
public void ler()

{

String nome, endereco, contratacao, optou;

float salario;

////////////////////////TRECHO -----INICIO-----------aqui

Painels T = new Painels();


  T.socios2();
  System.out.println("Tentei " );

///////////////////////TRECHO ------FIM-----------aqui

Funcionario f = null;
listaDeFuncionarios = new Vector();
list1.removeAll();

try
{
  Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  Connection con = DriverManager.getConnection (urlODBC,"agenda","agenda1");
  Statement stmt = con.createStatement();
  String query = "SELECT * FROM Funcionarios ORDER BY nome";
  ResultSet rs = stmt.executeQuery(query);



  while (rs.next())
  {
  	

  
  
    nome        = rs.getString(1);
    endereco    = rs.getString(2);
    salario     = rs.getFloat(3);
    contratacao = rs.getString(4);
    optou       = rs.getString(5);

    f = new Funcionario(nome,endereco,salario,contratacao,optou);
    listaDeFuncionarios.addElement(f);
    list1.add(f.devolveNome());
    atualizaTela(0);

}

Criado 18 de fevereiro de 2004
Ultima resposta 18 de fev. de 2004
Respostas 2
Participantes 2