Results 1 to 2 of 2

Thread: [RESOLVED] Call one class from another

Threaded View

  1. #1

    Thread Starter
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,344

    Resolved [RESOLVED] Call one class from another

    Hi,

    I am working on an exercise for class which, work and everything but I am having trouble figuring out how to have my classes setup to be called from multli locations. I know you can use:

    java Code:
    1. private JButton Play = new JButton();
    2.  
    3.    PlayGame gameHandler
    4.   Play = new JButton();
    5.   Play.setText("Play");
    6.    Play.setVisible(true);
    7.    Play.addActionListener(gameHandler);
    8.  
    9.  class PlayGame implements ActionListener {
    10.         public void actionPerformed(ActionEvent e) {
    11.             for (int i = 0; i < 9; i++) {
    12.                  btnKeypad[i].setText(" ");
    13.                 btnKeypad[i].setEnabled(true);
    14.             }
    15.         }
    16.     }

    to call a function from a button. However, how would I call the function from within another function?

    Thanks,


    Nightwalker
    Last edited by Nightwalker83; Mar 9th, 2012 at 07:14 PM. Reason: Forgot to add the actionlistener
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width