Problemas ao abrir Janela ao clicar no Botão usando Swing

Estou desenvolvendo uma aplicação desktop só que não estou conseguindo abrir uma janela quando clico no botão
por exemplo “Login” Já tentei criar objetos da classe que quero invocar. mas nada deu certo.
Quero saber como posso fazer isso, onde declarar esta funções.


posta seu código ae, pra dar uma olhada…

O Código abaixo, é a tela principal do programa. agora está a questão!
Como agora que faço pra chamar a tela de Login , de cadastro…
Preciso Urgente de ideia.

package pacote1;

import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import java.awt.GraphicsConfiguration;
import java.awt.HeadlessException;

import javax.swing.JFrame;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JButton;
import java.awt.Rectangle;
import javax.swing.JTable;
import java.awt.GridBagLayout;

import javax.swing.BoxLayout;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JToolBar;
import javax.swing.JDesktopPane;
import java.awt.GridBagConstraints;
import javax.swing.JInternalFrame;
import java.awt.TextArea;
import javax.swing.JTextPane;
import javax.swing.JComboBox;
import java.awt.Canvas;
import java.awt.ComponentOrientation;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.Color;
import javax.swing.JTextField;
import javax.swing.JPasswordField;
import javax.swing.JTree;
import javax.swing.JDialog;
import java.awt.Dimension;
import javax.swing.JLabel;
import javax.swing.ImageIcon;
import javax.swing.JSlider;
import java.awt.Choice;
import javax.swing.SwingConstants;

public class InterDesk extends JFrame {

private static final long serialVersionUID = 1L;
private JPanel jContentPane = null;
private JPanel caixaText=null;//coloquei so para testar tirar depois
private JMenuBar jJMenuBar = null;
private JMenu jMenu = null;
private JMenu jMenu1 = null;
private JMenu jMenu2 = null;
private JMenu jMenu3 = null;
private JMenu jMenu4 = null;
private JMenuItem jMenuItem = null;
private JMenuItem jMenuItem3 = null;
private JMenu jMenu5 = null;
private JMenuItem jMenuItem6 = null;
private JMenu jMenu6 = null;
private JMenuItem jMenuItem7 = null;
private JButton jButton = null;
private JMenu jMenu7 = null;
private JMenuItem jMenuItem8 = null;
private JMenuItem jMenuItem9 = null;
private JButton jButton1 = null;
private JLabel jLabel2 = null;
private JLabel jLabel3 = null;
private JMenu jMenu10 = null;
private JMenuItem jMenuItem10 = null;
private JMenuItem jMenuItem11 = null;
private JMenuItem jMenuItem12 = null;
private JMenuItem jMenuItem13 = null;
private JMenuItem jMenuItem1 = null;
public InterDesk() throws HeadlessException {
	// TODO Auto-generated constructor stub
	super();
	initialize();
}

public InterDesk(GraphicsConfiguration gc) {
	super(gc);
	// TODO Auto-generated constructor stub
	initialize();
}

public InterDesk(String title) throws HeadlessException {
	super(title);
	// TODO Auto-generated constructor stub
	initialize();
}

public InterDesk(String title, GraphicsConfiguration gc) {
	super(title, gc);
	// TODO Auto-generated constructor stub
	initialize();
}

/**
 * This method initializes jJMenuBar
 *
 * @return javax.swing.JMenuBar
 */
private JMenuBar getJJMenuBar() {
	if (jJMenuBar == null) {
		jJMenuBar = new JMenuBar();
		jJMenuBar.add(getJMenu());
		jJMenuBar.add(getJMenu1());
		jJMenuBar.add(getJMenu2());
		jJMenuBar.add(getJMenu3());
		jJMenuBar.add(getJMenu6());
	}
	return jJMenuBar;
}

/**
 * This method initializes jMenu
 *
 * @return javax.swing.JMenu
 */
private JMenu getJMenu() {
	if (jMenu == null) {
		jMenu = new JMenu();
		jMenu.setText("Cadastrar");
		jMenu.add(getJMenu4());
	}
	return jMenu;
}

/**
 * This method initializes jMenu1
 *
 * @return javax.swing.JMenu
 */
private JMenu getJMenu1() {
	if (jMenu1 == null) {
		jMenu1 = new JMenu();
		jMenu1.setText("Serviços");
		jMenu1.add(getJMenuItem12());
		jMenu1.add(getJMenuItem13());
		jMenu1.add(getJMenu10());
	}
	return jMenu1;
}

/**
 * This method initializes jMenu2
 *
 * @return javax.swing.JMenu
 */
private JMenu getJMenu2() {
	if (jMenu2 == null) {
		jMenu2 = new JMenu();
		jMenu2.setText("Consulta");
		jMenu2.add(getJMenu5());
	}
	return jMenu2;
}

/**
 * This method initializes jMenu3
 *
 * @return javax.swing.JMenu
 */
private JMenu getJMenu3() {
	if (jMenu3 == null) {
		jMenu3 = new JMenu();
		jMenu3.setText("Relatórios");
		jMenu3.add(getJMenu7());
	}
	return jMenu3;
}

/**
 * This method initializes jMenu4
 *
 * @return javax.swing.JMenu
 */
private JMenu getJMenu4() {
	if (jMenu4 == null) {
		jMenu4 = new JMenu();
		jMenu4.setText("Cadastramento");
		jMenu4.add(getJMenuItem());
		jMenu4.add(getJMenuItem1());
		jMenu4.addSeparator();
		jMenu4.add(getJMenuItem3());


	}
	return jMenu4;
}

/**
 * This method initializes jMenuItem
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getJMenuItem() {
	if (jMenuItem == null) {
		jMenuItem = new JMenuItem();
		jMenuItem.setText("Cadastrar...");
	}
	return jMenuItem;
}

/**
 * This method initializes jMenuItem3
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getJMenuItem3() {
	if (jMenuItem3 == null) {
		jMenuItem3 = new JMenuItem();
		jMenuItem3.setText("Imóveis");
	}
	return jMenuItem3;
}

/**
 * This method initializes jMenu5
 *
 * @return javax.swing.JMenu
 */
private JMenu getJMenu5() {
	if (jMenu5 == null) {
		jMenu5 = new JMenu();
		jMenu5.setText("Consultar");
		jMenu5.add(getJMenuItem7());
		jMenu5.addSeparator();
		jMenu5.add(getJMenuItem6());
	}
	return jMenu5;
}

/**
 * This method initializes jMenuItem6
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getJMenuItem6() {
	if (jMenuItem6 == null) {
		jMenuItem6 = new JMenuItem();
		jMenuItem6.setText("Imóveis");
	}
	return jMenuItem6;
}

/**
 * This method initializes jMenu6
 *
 * @return javax.swing.JMenu
 */
private JMenu getJMenu6() {
	if (jMenu6 == null) {
		jMenu6 = new JMenu();
		jMenu6.setText("Ajuda");
	}
	return jMenu6;
}

/**
 * This method initializes jMenuItem7
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getJMenuItem7() {
	if (jMenuItem7 == null) {
		jMenuItem7 = new JMenuItem();
		jMenuItem7.setText("Cliente e Funcionários");
	}
	return jMenuItem7;
}

/**
 * This method initializes jButton
 *
 * @return javax.swing.JButton
 */
private JButton getJButton() {
	if (jButton == null) {
		jButton = new JButton();
		jButton.setBounds(new Rectangle(13, 33, 100, 51));
		jButton.setIcon(new ImageIcon("C:/Arquivos de programas/Adobe/Reader 8.0/Reader/HowTo/PTB/Images/A_Secure_Sm_N.png"));
		jButton.setText("Login");










		jButton.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent e) {
				System.out.println("mouseClicked()"); // TODO Auto-generated Event stub mouseClicked()
			}
		});
		jButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
			}
		});
		jButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {
				System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
			}
		});
		jButton.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent e) {

				Login a= new Login();



				 // TODO Auto-generated Event stub actionPerformed()
			}
		});
	}
	return jButton;
}

/**
 * This method initializes jMenu7
 *
 * @return javax.swing.JMenu
 */
private JMenu getJMenu7() {
	if (jMenu7 == null) {
		jMenu7 = new JMenu();
		jMenu7.setText("Gerar Relatório");
		jMenu7.add(getJMenuItem8());
		jMenu7.add(getJMenuItem9());
	}
	return jMenu7;
}

/**
 * This method initializes jMenuItem8
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getJMenuItem8() {
	if (jMenuItem8 == null) {
		jMenuItem8 = new JMenuItem();
		jMenuItem8.setText("Vendas do Mês");
	}
	return jMenuItem8;
}

/**
 * This method initializes jMenuItem9
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getJMenuItem9() {
	if (jMenuItem9 == null) {
		jMenuItem9 = new JMenuItem();
		jMenuItem9.setText("Locação");
	}
	return jMenuItem9;
}

/**
 * This method initializes jButton1
 *
 * @return javax.swing.JButton
 */
private JButton getJButton1() {
	if (jButton1 == null) {
		jButton1 = new JButton();
		jButton1.setBounds(new Rectangle(13, 95, 100, 51));
		jButton1.setIcon(new ImageIcon("C:/Arquivos de programas/Arquivos comuns/Adobe/Help/en_US/Adobe Reader/8.0/images/A_ValidityCross_Sm_N.png"));
		jButton1.setText("Fechar");
	}
	return jButton1;
}

/**
 * This method initializes jMenu10
 *
 * @return javax.swing.JMenu
 */
private JMenu getJMenu10() {
	if (jMenu10 == null) {
		jMenu10 = new JMenu();
		jMenu10.setText("Relatórios");
		jMenu10.add(getJMenuItem10());
		jMenu10.add(getJMenuItem11());
	}
	return jMenu10;
}

/**
 * This method initializes jMenuItem10
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getJMenuItem10() {
	if (jMenuItem10 == null) {
		jMenuItem10 = new JMenuItem();
		jMenuItem10.setText("Imoveis Locados");
	}
	return jMenuItem10;
}

/**
 * This method initializes jMenuItem11
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getJMenuItem11() {
	if (jMenuItem11 == null) {
		jMenuItem11 = new JMenuItem();
		jMenuItem11.setText("Pagamento");
	}
	return jMenuItem11;
}

/**
 * This method initializes jMenuItem12
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getJMenuItem12() {
	if (jMenuItem12 == null) {
		jMenuItem12 = new JMenuItem();
		jMenuItem12.setText("Vendas...");
	}
	return jMenuItem12;
}

/**
 * This method initializes jMenuItem13
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getJMenuItem13() {
	if (jMenuItem13 == null) {
		jMenuItem13 = new JMenuItem();
		jMenuItem13.setText("Locação...");
	}
	return jMenuItem13;
}

/**
 * This method initializes jMenuItem1
 *
 * @return javax.swing.JMenuItem
 */
private JMenuItem getJMenuItem1() {
	if (jMenuItem1 == null) {
		jMenuItem1 = new JMenuItem();
		jMenuItem1.setText("CadastrarUsuário");
	}
	return jMenuItem1;
}

/**
 * @param args
 */
public static void main(String[] args) {
	// TODO Auto-generated method stub
	SwingUtilities.invokeLater(new Runnable() {
		public void run() {
			InterDesk thisClass = new InterDesk();
			thisClass.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
			thisClass.setVisible(true);
		}
	});
}

/**
 * This method initializes this
 *
 * @return void
 */
private void initialize() {
	this.setSize(831, 754);
	this.setBackground(Color.black);
	this.setJMenuBar(getJJMenuBar());
	this.setContentPane(getJContentPane());
	this.setTitle("Sigsmobil 0.1");
}

/**
 * This method initializes jContentPane
 *
 * @return javax.swing.JPanel
 */
private JPanel getJContentPane() {
	if (jContentPane == null) {
		jLabel3 = new JLabel();
		jLabel3.setBounds(new Rectangle(159, 14, 1153, 695));
		jLabel3.setIcon(new ImageIcon("E:/Interface/src/logo5.JPG"));
		jLabel3.setHorizontalTextPosition(SwingConstants.CENTER);
		jLabel3.setHorizontalAlignment(SwingConstants.CENTER);
		jLabel3.setText("");
		jLabel2 = new JLabel();
		jLabel2.setBounds(new Rectangle(136, 644, 253, 16));
		jLabel2.setText("Copyright ChaSheShi Software");
		jContentPane = new JPanel();
		jContentPane.setLayout(null);
		jContentPane.add(getJButton(), null);
		jContentPane.add(getJButton1(), null);
		jContentPane.add(jLabel2, null);
		jContentPane.add(jLabel3, null);
	}
	return jContentPane;
}

} // @jve:decl-index=0:visual-constraint=“168,7”

Obrigado!

Pessoal! me dê uma LUZ!

Quem sabe swing!! to precisando de algumas dicas pra continuar…

Fala cara, blza?

Então, até onde eu sei, no método actionPerformed() vc precisa verificar qual foi o componente acionado.
Se for o botão “Login” vc dá um new Login(); chamando assim a classe Login.
Como vc fez no código, mas na classe login precisa ter o setVisible(true).
Se não tiver, depois de instanciar um objeto dessa classe, é só chamar

Login a= new Login(); a.setVisible(true);
Eu não conheço outro jeito.
Tenta isso awe.

Abraço

[quote=Thiago Luis]Fala cara, blza?

Então, até onde eu sei, no método actionPerformed() vc precisa verificar qual foi o componente acionado.
Se for o botão “Login” vc dá um new Login(); chamando assim a classe Login.
Como vc fez no código, mas na classe login precisa ter o setVisible(true).
Se não tiver, depois de instanciar um objeto dessa classe, é só chamar

Login a= new Login(); a.setVisible(true);
Eu não conheço outro jeito.
Tenta isso awe.

Abraço[/quote]

O Botão Login deu certinho… Valew Mesmo! Do jeito que eu queria.
agora como que faço para chamar alguma janela quando clico em algum item no menu
Por exemplo: Vou Menu Cadastro para abrir a janela imoveis
private JMenuItem getJMenuItem6() {
if (jMenuItem6 == null)
{
jMenuItem6 = new JMenuItem();
jMenuItem6.setText(“Imóveis”);
}
return jMenuItem6;
}

Como que faço?

Cara, eu não manjo muito de menus, mas achei alguma coisa:
http://www.javafree.org/artigo/848994/JMenu-com-acao-no-clique.html
Tavlez te ajude, mas é preciso adaptar algumas coisas, pois não tem submenus. Mas deve ser padrão como actionPerformed().
Se der erro, posta ai e a gente vai tentando.

Abraço

[quote=Thiago Luis]Cara, eu não manjo muito de menus, mas achei alguma coisa:
http://www.javafree.org/artigo/848994/JMenu-com-acao-no-clique.html
Tavlez te ajude, mas é preciso adaptar algumas coisas, pois não tem submenus. Mas deve ser padrão como actionPerformed().
Se der erro, posta ai e a gente vai tentando.

Abraço[/quote]

Eu sei que aqui não é local adequado para perguntar sobre outro assunto.
mas como que faço para colocar lembretes no menu?

Tipo assim:
Abro a janela Login e aparece um campo Tipo “balaozinho ou outra coisa” informando como digitar

já tentei esta função ToolTipText.Se possivel me explicar onde coloco a função, como fazer para auxiliar o usuario.
valew… A janela já consegui abri seguindo seus conselhos. valew!

[quote=Mr. Smith][quote=Thiago Luis]Cara, eu não manjo muito de menus, mas achei alguma coisa:
http://www.javafree.org/artigo/848994/JMenu-com-acao-no-clique.html
Tavlez te ajude, mas é preciso adaptar algumas coisas, pois não tem submenus. Mas deve ser padrão como actionPerformed().
Se der erro, posta ai e a gente vai tentando.

Abraço[/quote]

Eu sei que aqui não é local adequado para perguntar sobre outro assunto.
mas como que faço para colocar lembretes no menu?

Tipo assim:
Abro a janela Login e aparece um campo Tipo “balaozinho ou outra coisa” informando como digitar

já tentei esta função ToolTipText.Se possivel me explicar onde coloco a função, como fazer para auxiliar o usuario.
valew… A janela já consegui abri seguindo seus conselhos. valew!
[/quote]
Fala cara,

Veja no seu outro post sobre MENSSAGEM AO PASSAR O MOUSE EM CIMA DOS CAMPOS DA JANELA.
Para os menus deve ser o mesmo esquema.

Abraço