Link/Show Form when clicking a Button in Java
Submitted by donbermoy on Wednesday, April 30, 2014 - 05:54.
Language
This is a continuation of Login Tutorial and Connecting to MS Access database using JCreator see here With this, I am showing you some twist that after a correct login in the program it will show another form in Java.
1. First create a java program with a filename of MainMenu.java.
2. Import the following libraries.
3. Initialize the following variables below.
4. Create a constructor named MainMenu.
5. Create a method setMain. Instead of using the Main args, we will just use this method and will call from the Login.java.
6. In your Login.java in this this previous link see here. Add the code below.
MainMenu menu = new MainMenu() and menu.setMain() was called when the button with a correct login is clicked and it will show the MainForm.
For more inquiries and need programmer for your thesis systems in any kind of programming languages, just contact my number below.
Best Regards,
Engr. Lyndon Bermoy
IT Instructor/System Developer/Android Developer/Freelance Programmer
Mobile: 09488225971
Landline: 826-9296
E-mail:[email protected]
Add and Follow me on Facebook: https://www.facebook.com/donzzsky
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
Visit and like my page on Facebook at: https://www.facebook.com/BermzISware
- import javax.swing.*;
- import java.awt.*;
- import java.awt.event.*;
- import java.io.*;
- public MainMenu() {
- super("This is another form");
- };
- public void setMain(){
- MainMenu p1= new MainMenu();
- p1.setSize(1275,950);
- p1.setLocation(2,2);
- p1.setVisible(true);
- p1.setResizable(false);
- }
- if((loginname.equalsIgnoreCase(txtuser.getText()))&&(loginpass.equalsIgnoreCase(txtpass.getText())))
- {
- MainMenu menu = new MainMenu();
- menu.setMain();
- dialogmessage = "Welcome - "+loginname;
- txtuser.setText("");
- txtpass.setText("");
- dispose();
- }
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Comments
Add new comment
- Add new comment
- 79 views