Ir para conteúdo
  • 0

[Resolvido] [Interface]Urgente


Karamujo

Pergunta

Quando eu inicio meu programa ele abre normalmente, clico no menu de conexao


ele tambem abre de boa 


TSERs5q.png


Ai quando clico em fechar ele fecha os jFrame eu teria que so fechar o 2 jframe


Editado por Karamujo
Link para o comentário
Compartilhar em outros sites

18 respostass a esta questão

Posts Recomendados

entao ai se eu coloco assim fechas as 2 janelas

quero so fechar a de configuraçao do host

AH kkkkk

 

Tenta:

 

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

 

Ou:

 

DO_NOTHING_ON_CLOSE 

HIDE_ON_CLOSE 

Editado por stalker112
Link para o comentário
Compartilhar em outros sites

São 2 frames diferentes??

Sim

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        telaConfig tc = new telaConfig();
        tc.setVisible(true);
        tc.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        tc.setLocationRelativeTo(null);
    }       
 
e seto essas config nele o evento e o Performed
Link para o comentário
Compartilhar em outros sites

 

Sim

    private void jMenuItem3ActionPerformed(java.awt.event.ActionEvent evt) {                                           
        telaConfig tc = new telaConfig();
        tc.setVisible(true);
        tc.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        tc.setLocationRelativeTo(null);
    }       
 
e seto essas config nele o evento e o Performed

 

To baixando e eclipse... vou ver...

Editado por leonardosc
Link para o comentário
Compartilhar em outros sites

Muda do EXIT ON CLOSE pra DISPOSE_ON_CLOSE

 

code d exemplo qfiz

	public static void main(String[] args)
	{
		
		JFrame frame = new JFrame("Janela principal");
		frame.setSize(600, 700);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
		JButton b = new JButton();
		b.addActionListener(actionListener ->
		{
			JFrame frame2 = new JFrame("Janela 2");
			frame2.setSize(200, 200);
			frame2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
			frame2.setLocationRelativeTo(null);
			frame2.setVisible(true);
		});
		frame.add(b);
		
	}

http://prntscr.com/87qlxp

Editado por leonardosc
Link para o comentário
Compartilhar em outros sites

AH kkkkk

 

Tenta:

 

setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);

 

Ou:

 

DO_NOTHING_ON_CLOSE 

HIDE_ON_CLOSE 

 

Muda do EXIT ON CLOSE pra DISPOSE_ON_CLOSE

 

code d exemplo qfiz

	public static void main(String[] args)
	{
		
		JFrame frame = new JFrame("Janela principal");
		frame.setSize(600, 700);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
		JButton b = new JButton();
		b.addActionListener(actionListener ->
		{
			JFrame frame2 = new JFrame("Janela 2");
			frame2.setSize(200, 200);
			frame2.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
			frame2.setLocationRelativeTo(null);
			frame2.setVisible(true);
		});
		frame.add(b);
		
	}

http://prntscr.com/87qlxp

vlw viados e que demorei para testar

logo-forum.png

 

 

Sua dúvida foi marcada como [Resolvido] e movido à área de dúvidas resolvidas.

 

 

Atenciosamente,

Gamer's Board

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...