Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: how to get return values from a button to main program.

  1. #1
    Junior Member
    Join Date
    Feb 2013
    Posts
    21
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to get return values from a button to main program.

    hello,

    I have a main program which has a button Authenticate. On click of authenticate open a form for auth which has USERNAME FIELS AND PASSWORD.
    If entered fields are true then enable editing of jtable in main program..

    Basically something like this :
    //main program
    Authenticate.addActionListener(new ActionListener()
    {
    public void actionPerformed(ActionEvent ae)
    {
    UpdateAuth ua=new UpdateAuth();// opens form which has username and pass for authentication
    ua.setVisible(true);

    //need code here for enabling table
    if(s=="mactus")
    {
    enable table editing
    }
    //table.repaint();
    }

    });


    // form open for auth..(class UpdateAuth )

    private String SigninMouseClicked(java.awt.event.MouseEvent evt) {
    String aname=Aname.getText();
    String apass=Apassword.getText();
    if(aname.equals("") && apass.equals(""))
    {
    JOptionPane.showMessageDialog(null,"Enter login name or password","Error",JOptionPane.ERROR_MESSAGE);
    }
    if(!(aname.equals("") && apass.equals("")))
    {
    if(aname.equals("harshil") && apass.equals("harshil123"))
    {
    String s="mactus"; /// if username and password is success enable table editing in main program
    return s;

    }
    else if (!aname.equals("mactus") && !apass.equals("mactus123"))
    {
    Aname.setText("");
    Apassword.setText("");
    }
    }
    return null;
    }


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: how to get return values from a button to main program.

    Can you explain what the problem with the code is?

    Please edit your post and wrap your code with
    [code=java]
    <YOUR CODE HERE>
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Return letter grade to main method
    By jmanv888 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 15th, 2012, 04:48 PM
  2. [SOLVED] Return all values in an ArrayList from a method
    By IanSawyer in forum Collections and Generics
    Replies: 1
    Last Post: March 28th, 2012, 09:53 AM
  3. Need help my values wont return
    By sajeed in forum What's Wrong With My Code?
    Replies: 6
    Last Post: January 7th, 2012, 08:46 AM
  4. Replies: 5
    Last Post: August 11th, 2011, 12:39 PM
  5. Return the rgb values from a jpg image
    By newparticipant in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 25th, 2011, 03:47 PM

Tags for this Thread