Como chamar outro jframe ? estou colocando assim e não vai o que será?
ja coloquei
new teste().show();
Essa é a parte:
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == registrar)
{
new Telas.teste().show();
}
}
Código completo:
[code]package Telas;
import Telas.;
import Telas.T2;
import java.awt.;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class T1 extends JFrame implements ActionListener
{
JButton registrar,login,trocarsenha,regras,ajuda,suport,roundspeed,statisticas,forum,equipe,wiki,jornal,email ;
public T1()
{
this.setSize(1024,753);
//janela do programa
//JFrame frame = new JFrame("TribalWars");
//frame.setResizable(false);
//container onde serão adicionados todos componentes
Container container= this.getContentPane();
this.setTitle("TribalWars");
//carrega a imagem passando o nome da mesma
ImageIcon img = new ImageIcon("C:\\TribalWars\\Imagens\\03.JPG");
ImageIcon img2 =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\02.JPG");
ImageIcon imgtrocarsenha =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\Trocarsenha.JPG");
ImageIcon imglogin =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\Login.JPG");
ImageIcon imgregras =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\Regras.JPG");
ImageIcon imgajuda =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\Ajuda.JPG");
ImageIcon imgsuport =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\Suporte.JPG");
ImageIcon imgroundspeed =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\RoundsSpeed.JPG");
ImageIcon imgstatisticas =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\Estatisticas.JPG");
ImageIcon imgforum =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\forum.JPG");
ImageIcon imgequipe =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\Equipe.JPG");
ImageIcon imgwiki =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\wiki.JPG");
ImageIcon imgjornal =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\jornal.JPG");
ImageIcon imgemail =new ImageIcon("C:\\TribalWars\\Imagens\\Botoes\\email.JPG");
//------------------------------------------------------------------------------------------------------
registrar = new JButton(img2);
registrar.setSize(50,50);
registrar.setBounds(225,350,302,32);
//--------------------------------------------------------------------------------------------------------
trocarsenha = new JButton(imgtrocarsenha);
trocarsenha.setSize(10,10);
trocarsenha.setBounds(578,340,80,20);
//---------------------------------------------------------------------------------------------------------
login = new JButton(imglogin);
login.setSize(10,10);
login.setBounds(583,282,110,32);
//--------------------------------------------------------------------------------------------------------
regras = new JButton(imgregras);
regras.setSize(10,10);
regras.setBounds(135,47,50,16);
//---------------------------------------------------------------------------------------------
ajuda = new JButton(imgajuda);
ajuda.setSize(10,10);
ajuda.setBounds(191,47,43,16);
ajuda.setSelected(false);
//-----------------------------------------------------------------------------------
suport = new JButton(imgsuport);
suport.setSize(10,10);
suport.setBounds(245,47,55,15);
suport.setSelected(false);
//-----------------------------------------------------------------------------------
roundspeed = new JButton(imgroundspeed);
roundspeed.setSize(10,10);
roundspeed.setBounds(310,47,94,16);
roundspeed.setSelected(false);
//-----------------------------------------------------------------------------------
statisticas = new JButton(imgstatisticas);
statisticas.setSize(10,10);
statisticas.setBounds(410,47,80,16);
statisticas.setSelected(false);
//-----------------------------------------------------------------------------------
forum = new JButton(imgforum);
forum.setSize(10,10);
forum.setBounds(500,47,49,16);
forum.setSelected(false);
//----------------------------------------------------------------------------------
equipe = new JButton(imgequipe);
equipe.setSize(10,10);
equipe.setBounds(557,47,48,16);
equipe.setSelected(false);
//----------------------------------------------------------------------------------
wiki = new JButton(imgwiki);
wiki.setSize(10,10);
wiki.setBounds(611,47,35,16);
wiki.setSelected(false);
//----------------------------------------------------------------------------------
jornal = new JButton(imgjornal);
jornal.setSize(10,10);
jornal.setBounds(655,47,44,16);
jornal.setSelected(false);
//----------------------------------------------------------------------------------
email = new JButton(imgemail);
email.setSize(10,10);
email.setBounds(710,47,81,16);
email.setSelected(false);
//----------------------------------------------------------------------------------
//pega a altura e largura
int altura = img.getIconHeight();
int largura = img.getIconWidth();
//adiciona a imagem em um label
//---------------------------------
JLabel label = new JLabel(img);
label.add(registrar);
label.add(regras);
label.add(login);
label.add(trocarsenha);
label.add(ajuda);
label.add(suport);
label.add(roundspeed);
label.add(statisticas);
label.add(forum);
label.add(equipe);
label.add(wiki);
label.add(jornal);
label.add(email);
//---------------------------------
JLabel labelB = new JLabel();
labelB.setSize(100,100);
//adiciona a altura e largura em outro label
// JLabel label2 = new JLabel("Altura: "+altura+" Largura: "+largura);
//cria o JPanel para adicionar os labels
JPanel panel = new JPanel();
panel.add(label, BorderLayout.NORTH);
//panel.add(label2, BorderLayout.SOUTH);
//adiciona o panel no container
container.add(panel, BorderLayout.CENTER);
// frame.pack();
// frame.setVisible(true);
registrar.addActionListener(this);
login.addActionListener(this);
}
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new T1().setVisible(true);
}
});
}
/* public void actionPerformed(ActionEvent e)
{
if (e.getSource() == registrar)
{
chama_teste();
}
}*/
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == registrar)
{
new Telas.teste().show();
}
}
}[/code]