Results 1 to 3 of 3
  1. #1
    cyentw is offline Member
    Join Date
    Jan 2013
    Rep Power

    Default JButton Running Another Main Class (help me)

    Ok, so I need a JButton I have made to run another class. (Which will open a new GUI window.)

    Here is a segment of my code:


    public void actionPerformed(ActionEvent e) {

    if(e.getSource() == item)


    The class I am trying to run is called 'ItemWriter'
    The JButton is called 'item'

    Please help!


  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Blog Entries
    Rep Power

    Default Re: JButton Running Another Main Class (help me)

    You may need to give us more information and post more code including perhaps your ItemWriter, how you try to run it and what happens when you try to run it, what problems you may be having. Also, when posting code, please make sure that it is formatted and that you use [code] [/code] tags.

  3. #3
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: JButton Running Another Main Class (help me)

    If you want to start a public static void main(String[] args) method in that other class, just do so:

    Java Code:
    OtherClass.main(null); // no args passed
    kind regards,

    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. JButton not appearing when running JAR
    By joet1984 in forum New To Java
    Replies: 0
    Last Post: 01-27-2013, 09:01 PM
  2. setting JButton setEnabled() outside of main class
    By danborgir in forum New To Java
    Replies: 11
    Last Post: 05-07-2011, 04:03 PM
  3. Replies: 1
    Last Post: 01-23-2011, 06:19 PM
  4. Running main method class from another main class
    By tlrocketman in forum New To Java
    Replies: 3
    Last Post: 12-06-2010, 09:30 AM
  5. Replies: 1
    Last Post: 06-30-2009, 02:32 PM

Posting Permissions

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