How Do I Run A Class From Another Class?

Hiya everyone, id like to know how to run a class from another class.
Ive got a Login class which extends a JFrame and a Personnel class which also extends a JFrame. When i press the login button (in Login class), ive got it to decide if password/login are acceptable and if they are, I want the Login class to close then run the Personnel class.
Im just after the code which says to close this class and run the Personnel class. How do i do that?
Ive researched this but couldnt get an understandable answer!
Help would be much appreciated, Ant...

This is the Login Class:
public class MainMenu extends javax.swing.JFrame {
    Statement statement = null;
    int currentRecord;
    ResultSet rs = null;
    String name = null, job = null, mission = null, login = null, password = null;
    String loginVal;
    String passwordVal;
    /** Creates new form MainMenu */
    public MainMenu() {
        initComponents();
        try{
            Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
            String filename = System.getProperty("user.dir") + "/src/Personnel.mdb";
            String database = "jdbc:odbc:Driver={Microsoft Access Driver (*.mdb)};DBQ=" + filename;
            Connection conn = DriverManager.getConnection( database , "","");
            statement = conn.createStatement();
            System.out.println("Connected...ok");
        } catch (Exception e) {
            System.err.println("Got a connection Problem!");
            System.err.println(e.getMessage());
    private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {                                        
        loginVal = txtLogin.getText();
        passwordVal = txtPassword.getText();
        String name = null, job = null, mission = null, login = null, password = null;
        try{
            rs = statement.executeQuery("SELECT Login,Password FROM Personnel WHERE Login = '" + loginVal + "' ");
            System.out.println("TRYING SELECT CLAUSE");
            if(rs.next()){
                System.out.println("THERE IS A NEXT RECORD");
                login = rs.getString(1);
                password = rs.getString(2);
                System.out.println("GOT THE NEXT RECORD");
                System.out.println(login + password);
            System.out.println("Query Complete");
        }catch(Exception s){
            //s.printStackTrace();
            System.out.println("NO RECORDS EXIST FOR THIS LOGIN ID");
        if(passwordVal.equals(password)){
            System.out.println("Access Granted"); //CLOSE MAIN AND RUN CONTROL CLASS
        } else{
            System.out.println("Access Denied"); //RE-RUN CLASS
    }                 

Similar Messages

  • How do you call a method from  another class without extending as a parent?

    How do you call a method from another class without extending it as a parent? Is this possible?

    Why don't you just create an instance of the class?
    Car c = new Car();
    c.drive("fast");The drive method is in the car class, but as long as the method is public, you can use it anywhere.
    Is that what you were asking or am I totally misunderstanding your question?
    Jen

  • HT1347 How do I run two libraries from one computer?

    How do I run two libraries from one computer? One library is on the computer's hard drive, the second library is on an external hard drive. The computer that had the external hard drive crashed and I need to fix the iTunes library on it. How can I do this without corrupting the library on my internal hard drive?

    Launch iTunes with the Shift key held down and either create a new library or choose the one on the external drive. Any rented movies downloaded from another computer won't play.
    (81212)

  • How can i run an applet from a webpage????

    can someone PLEASE tell me how i can run an applet from my webpage. a detailed response would be extremely appreciated.
    sam

    Here's a web page that you can use as skeleton. You should be able to start with that.
    <HTML>
    <HEAD>
    <TITLE>Title</TITLE>
    </HEAD>
    <BODY>
    <APPLET CODE="your.class" WIDTH=400 HEIGHT=300 IGNORE=""></APPLET>
    </BODY>
    </HTML>

  • If I imported a CD into my iTunes library from one computer how can I listen to it from another computer?

    If I imported a CD into my iTunes library from one computer how can I listen to it from another computer?  I imported music from a CD into my compter at work and when I got home and went to my iTunes account none of the songs were in my library.  I also noticed that on my Work computer there were a couple songs that I had to click on the little 'cloud' icon before I could listen to them (these were not songs I imported they were songs that were already in my library).  Not sure if this makes semse...help.

    jamie171 wrote:
    My question is since I have imported them into my iTunes library from one computer why can't I access them from my iTunes library from another computer that I have authorized to access whats in my library?  Is there no way to import songs only once into the library and then access them from all my authorized computers?
    Only if you have iTunes Match or of the computers are on the same local network.

  • HT1386 How do I unsync my phone from another person's account?

    How do I unsync my phone from another person's account? Another family member's phone was synced into the computer. As I tried to sync my phone it automatically synced into the account of the other phone. How do I sync my phone under my name so I can sync what is on my phone?

    Create another user profile on the computer so that you can log in as yourself and have your own copy of iTunes.

  • How can I edit my website from another computer? and how can I create a new website next to the one, I have already? Can anyone help, please?

    How can I edit my website from another computer? and how can I create a new website next to the one, I already have? Can anyone help, please?

    Move the domain.sites file from one computer to the other.
    The file is located under User/Library/Application Support/iWeb/domain.sites.  Move this file to the same location on the other computer and double click and iWeb will open it.  Remember, it is your User Library that you want and not your System Library, as you will not find iWeb there.
    Just create a new site on the same domain file and it will appear below the other site.  If you want them side by side then duplicate your domain file and have one site per a domain file and they can then be side by side.

  • How do I control my mac from another mac not in the same network?

    How do I control my mac from another mac not in the same network? Thanks

    You can do it manually, but it is much simpler if you use a tool such as Back To My Mac, LogMeIn, or something like that. Those programs enable you to connect to your computer through your router without you having to adjust the router settings manually.

  • How to open Adobe Reader file from another native IOS application?

    There is an existing thread, but I want to re-open it because I think this is an important feature that we need badly.  I was wondering if there is any plan to add this feature so we can open PDFs directly into Adobe from the web / other apps.
    How to open Adobe Reader file from another native IOS application?
    Basically, we just want to use a custom URL scheme to open a specific document in the App.  Currently, this only opens the app but does not load the file.
    APB

    Not to hijack the conversation but I can explain why this would be useful for both the above case and another.
    What I believe Pavel is talking about is setting up a "URL Scheme" for the Adobe Acrobat iOS application so that you can easily open a PDF specifically in Adobe Acrobat iOS from other native applications and even from web applications opened within Safari. This is particularly useful if your application requires some of the specific features in Adobe Reader iOS to grant them the best experience possible and you want to encourage this.
    Another case: If you're using Adobe Livecycle's document security modules (that encrypts PDF files so that Adobe Acrobat must "phone home" to decrypt and view the document), these PDF's can only be viewed inside the Adobe Acrobat application and appear as blank in most other PDF readers. Having a URL scheme allows your application utilising this functionality to have a 1 click step to view the PDF rather than the current non-user friendly process:
    - Within Safari, touch the PDF link (appears as blank in the default Safari PDF reader, which in itself is confusing)
      - Touch "Open in..."
      - Touch "Adobe Acrobat"
    We have an immediate need for this functionality for the example above. I can resubmit it in a separate post if necessary.

  • My slide presentation (with sound) is done. How can I change one song from another?

    My slide presentation (with songs) is done. How can I change one song from another?

    Do you still have your Aperture Slideshow project? Then open the slideshow and select the one of the green audio file clips in the film strip that you want to replace. Press the "delete" key and drag another audio file from the Media Browser directly onto the slide, where the sound should start.

  • Can we run one report from another Report in reports 6i

    Actually my requirement is i want to run 4 reports from another report(driver report) by passing parameter same as the driver report.
    i want to see the out put on the screen report by report next to driver report output.is it possible?? actually i got the solution for printing or taking file. but i want to show the output on the screen.
    Edited by: user9165808 on Feb 16, 2010 3:21 AM

    I used SRW.RUN_REPORT () . But my question that is it possible to show report in batches on screen??
    Edited by: user9165808 on Feb 19, 2010 4:23 AM

  • HT3529 How do I disconnect one iphone from another iphone's iMessage?

    How do I disconnect one iphone from another iphone's iMessage?

    He needs to get his own Apple ID.
    Have him logout from your Apple ID at settings>>iCloud .
    He should then set up his own Apple ID.

  • Considering a Macbook pro 13".  want to use garage band - how do i run line in from my guitar.  There is not a mic/line input that I can see in specs.

    Considering buying a Macbook pro 13".  Want to use garage band - how do i run line in from my guitar.  There is not a mic/line input that I can see in specs.

    Simple. GarageBand question, GarageBand forum where all those users are jacked into their Macs and can tell you how. Also look to the right of your post to the column, "More Like This."---------------------------------------------->
    https://discussions.apple.com/community/ilife/garageband

  • Hi I am new on the Mac, I need help, how can I run my apps from my library on my Mac Pro?  All my apps I was used in my iPad, thanks guys!!!!

    Hi I am new on the Mac, I need help, how can I run my apps from my library on my Mac Pro?  All my apps I was used in my iPad, thanks guys!!!!

    The Mac OS X and iOS versions are separate products

  • How can I watch apple tv from another country?

    How can I watch apple tv from another coutry?

    I live in country A and when I log on to the itunes store I´m automatically connected to that country´s store.But I know that certain films I would like to rent are possible to rent in the US Itunes store. To rent from the US store you have to register an apple id in that store and to do that you have to have a valid billing adress within the US and a valid credit card from the US. Is there any other way I can connect to the US Itunes store from another country?

  • HT1473 How do I play music/playlists from another iTunes account without having to transfer the purchases to my account?

    How do I play music/playlists from another iTunes account without having to transfer the purchases to my account?

    Get copies of the song files and add them to your iTunes library.

Maybe you are looking for

  • ITunes No Longer Runs--iTunes Helper Resources Not a Valid File Name

    I made a dumb mistake (I think) and tried to install iTunes onto an SD card.  At first, my computer would only let me open iTunes if the SD card was installed.  I tried to reinstall to the C drive, but keep getting the "I Tunes Helper Resources not a

  • Http Header for a SOAP message using SAAJ.

    Hello java community, I need to set the 'SOAPAction' field in the HTTP Header of a soap message. I am using SAAJ to build the message. Does anyone know how to do this? Help is greatly appreciated as always.

  • Three way calls issue

    Hello, I am having difficulty with my phone. First problem. I can make three way calls, but I can't end a call with one person without having to end the call with both individuals. I was on a very important phone call today, long distance, and this r

  • How to compare date values in XQuery

    begin select sysdate into x_date from dual; select xmlquery( '<A> { [b]for $a in ora:view("TableA") let $id = $a/ROW/ID/text() where $a/ROW/TRANS_DATE >= x_date return .. </A>' returning content} into temp from dual; end; This gives me invalid variab

  • XD03 - maximum no. of search hits

    Hi, When we search customer master (XD03) system by default is restricting the max. no. of entries to 5000.  Do you know where I can get rid of it or extend this limit ?  Actual issue is that user wants to see search term of all customers, but it is