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

    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:

    item.addActionListener(this);


    }
    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!

    Thanks!

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    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 offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,529
    Blog Entries
    7
    Rep Power
    20

    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,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. JButton not appearing when running JAR
    By joet1984 in forum New To Java
    Replies: 0
    Last Post: 01-27-2013, 08: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, 05: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, 08: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
  •