Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2006
    Posts
    8

    Question Unanswered: Can a java have two main classes

    Hello,all
    I want to ask about my java program can I use a java class " main class " and create a "GUI "another java class with a main class too, that when we run it we got an interface page . This interface has an " Enter " button that leads to the next main class.

    Is this possible in java and if not how can I create a GUI interface to my main class ?
    Last edited by Eng_Girl; 02-15-06 at 07:53.

  2. #2
    Join Date
    Feb 2006
    Posts
    11
    Hi,
    You can create two different main class (one for GUI and another for your processing logic or any), for the second main class you can create a jar file. Now from the first main class after clicking the button it should route to the second main class, now this is possible. You can create a process object in first main class(gui) and using this process object you can fire a exec statement for the jar file created for the second main class.

    GUI -> process obj -> exec -> jar(second main class)

    let me know if any other information is required.

    Nouman Memon
    Patni Computers

  3. #3
    Join Date
    Feb 2006
    Posts
    8
    Thanks for your reply I guess I should write the code for further explanation,
    I already make a jar file for my 2nd main class "CAR2006",but how can I fire an action listener that will take me to it, One more thing I created a password for this window, but it didn't work can you plz check this code for me ?

    .
    .
    .
    import CAR2006.CAR2006;

    public class GUI extends JFrame {

    private JButton Enter = new JButton ("Enter") ;
    private JPasswordField textField1;


    public GUI (){

    super("Graphical User Interface ");

    Container c = getContentPane();
    c.setLayout(new FlowLayout());

    c.add(Enter);

    textField1 = new JPasswordField("",5);

    c.add(textField1);


    Enter.addActionListener (new ActionListener() {
    public void actionPerformed(ActionEvent e) {

    char[] pass= textField1.getPassword();
    char[] passMatch={'1','2','3','4'};
    if(pass==passMatch)
    new CAR2006();


    }
    });


    setSize(550, 470);
    setVisible(true);

    }


    public static void main(String[] args) {
    GUI G =new GUI();

    }

    }

  4. #4
    Join Date
    Jan 2005
    Posts
    362

    Class

    Quote Originally Posted by Eng_Girl
    Hello,all
    I want to ask about my java program can I use a java class " main class " and create a "GUI "another java class with a main class too, that when we run it we got an interface page . This interface has an " Enter " button that leads to the next main class.

    Is this possible in java and if not how can I create a GUI interface to my main class ?
    There is no problem with this but do not give at two files on the same folder the same name.
    dimis

Posting Permissions

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