Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Post Reply
Bookmark Topic
Watch Topic
New Topic
programming forums
Java
Mobile
Certification
Databases
Caching
Books
Engineering
Micro Controllers
OS
Languages
Paradigms
IDEs
Build Tools
Frameworks
Application Servers
Open Source
This Site
Careers
Other
Pie Elite
all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Campbell Ritchie
Tim Cooke
Ron McLeod
paul wheaton
Jeanne Boyarsky
Sheriffs:
Paul Clapham
Devaka Cooray
Saloon Keepers:
Tim Holloway
Roland Mueller
Himai Minh
Bartenders:
Forum:
Swing / AWT / SWT
Help JInternalFrame
Rodrigo Talles
Greenhorn
Posts: 1
posted 10 years ago
Number of slices to send:
Optional 'thank-you' note:
Send
I need to close my JInternalFrame when a click a button. In my second class.
//my first class
import java.awt.EventQueue; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JMenu; import javax.swing.JMenuBar; import javax.swing.JMenuItem; import javax.swing.JPanel; import javax.swing.border.EmptyBorder; public class Principal extends JFrame { private static final long serialVersionUID = 1L; private JPanel contentPane; Login tela=new Login(); /** * Launch the application. */ public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Principal frame = new Principal(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } public void setSenha(String login, String senha){ System.out.println(login); System.out.println(senha); } /** * Create the frame. */ public Principal() { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setBounds(100, 100, 450, 300); contentPane = new JPanel(); contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); setContentPane(contentPane); contentPane.setLayout(null); JMenuBar menuBar = new JMenuBar(); menuBar.setBounds(0, 0, 97, 21); contentPane.add(menuBar); JMenu mnNewMenu = new JMenu("Principal"); menuBar.add(mnNewMenu); JMenuItem mntmNewMenuItem = new JMenuItem("Login"); mntmNewMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { contentPane.add(tela); tela.setVisible(true); /*JInternalFrame internalFrame = new JInternalFrame("Login"); internalFrame.setBounds(70, 50, 330, 184); contentPane.add(internalFrame); internalFrame.setVisible(true);*/ } }); mnNewMenu.add(mntmNewMenuItem); JMenuItem mntmNewMenuItem_1 = new JMenuItem("Cadastro\r\n"); mntmNewMenuItem_1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { tela.setVisible(false); if(tela.passe==false){ System.out.println("Logue Primeiro"); }else{System.out.println("Ok Cadastro");}; } }); mnNewMenu.add(mntmNewMenuItem_1); JMenuItem mntmSair = new JMenuItem("Sair"); mntmSair.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { System.out.println(tela.login); System.out.println(tela.senha); System.exit(0); } }); mnNewMenu.add(mntmSair); } }
//my second class
import java.awt.EventQueue; import javax.swing.JInternalFrame; import javax.swing.JLabel; import javax.swing.JRootPane; import java.awt.Color; import javax.swing.JFrame; import javax.swing.border.LineBorder; import javax.swing.JTextField; import javax.swing.JButton; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class Login extends JInternalFrame { /** * */ private static final long serialVersionUID = 4681925295517182120L; private JTextField txtLogin; private JTextField txtSenha; public boolean passe; String login, senha; public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { public void run() { try { Login frame = new Login(); frame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); } /** * Create the frame. */ public Login() { setClosable(true); setRootPaneCheckingEnabled(false); putClientProperty("JInternalFrame.isPalette", Boolean.TRUE); getRootPane().setWindowDecorationStyle(JRootPane.NONE); setTitle("Login"); setFrameIcon(null); setBorder(new LineBorder(new Color(0, 0, 0))); setEnabled(false); setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE); setBackground(new Color(240, 240, 240)); setBounds(10, 32, 414, 219); getContentPane().setLayout(null); JLabel lblTeste = new JLabel("Login"); lblTeste.setBounds(55, 77, 31, 16); getContentPane().add(lblTeste); txtLogin = new JTextField(); txtLogin.setBounds(91, 75, 114, 20); getContentPane().add(txtLogin); txtLogin.setColumns(10); JLabel lblSenha = new JLabel("Senha"); lblSenha.setBounds(50, 113, 36, 16); getContentPane().add(lblSenha); txtSenha = new JTextField(); txtSenha.setBounds(91, 111, 114, 20); getContentPane().add(txtSenha); txtSenha.setColumns(10); JButton btnLogar = new JButton("Logar"); btnLogar.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { passe=true; Acesso acesso = new Acesso(); acesso.Acesso(txtLogin.getText(), txtSenha.getText()); //HERE I NEED CLOSE MY JINTERNALFRAME } }); btnLogar.setBounds(302, 156, 98, 26); getContentPane().add(btnLogar); } }
Consider Paul's
rocket mass heater
.
reply
reply
Bookmark Topic
Watch Topic
New Topic
Boost this thread!
Similar Threads
Can someone please help
Need help on login frame in java.
Plz help to add new window on current one!
Browse and Load a Text File
simple web browser in java
More...