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 10 of 10

Thread: Java, calling another public class from within the main class giving problems.

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Post Java, calling another public class from within the main class giving problems.

    Hi all,
    there is a problem when i run the main program, it will open the public class an infinite number of times, until you cancel the program manually.

    main class program.
    //This will be the login screen for CardLayoutDemo
     
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
     
    public class login2{
    	public static void main(String [] args){
    		JFrame f1=new JFrame("Keith");
    		Container cp=f1.getContentPane();
    		cp.setLayout(new FlowLayout());
     
    		JButton login=new JButton("Login");
     
            ActionListener a1 = new ActionListener() {
    	public void actionPerformed(ActionEvent e) {
    			CardLayoutDemo t1=new CardLayoutDemo();
                    }
                    };
     
    		login.addActionListener(a1);
    		cp.add(login);
    		f1.pack();
    		f1.setDefaultCloseOperation(f1.EXIT_ON_CLOSE);
    		f1.setSize(300,300);
    		f1.setVisible(true);
    	}
    }

    public program.
    /*
     * CardLayoutDemo.java requires no other files.
     */
     
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
     
     class CardLayoutDemo implements ItemListener{
     
        JPanel cards; //a panel that uses CardLayout
        final static String BUTTONPANEL = "Main Menu";
        final static String TEXTPANEL = "Choose Your Destenation";
        final static String FamilyDetails = "Submit Your Family Details ";
        final static String AddCombo = "Add/Remove Combo Box";
        final static String UserReview = "Write A User Review";
        private JComboBox combo;
      	private JTextField txtBox;
      	private ImageIcon image1;
    	private JLabel label1;
    	private ImageIcon image2;
    	private JLabel holiday;
     
     
        public void addComponentToPane(Container pane) {
     
            //Put the JComboBox in a JPanel to get a nicer look.
            JPanel comboBoxPane = new JPanel(); //use FlowLayout
            String comboBoxItems[] = { BUTTONPANEL, TEXTPANEL, FamilyDetails, AddCombo, UserReview  };
            JComboBox cb = new JComboBox(comboBoxItems);
            cb.setEditable(false);
            cb.addItemListener(this);
            comboBoxPane.add(cb);
     
            //Create the "cards".
    		JPanel card1 = new JPanel();
    		JLabel l20=new JLabel("Welcome to your hotel reservation app");
    		JLabel l21=new JLabel("Please use the following drop down menu to go to the required area");
    		card1.add(l20); card1.add(l21);
     
            image1 = new ImageIcon(getClass().getResource("hotel342.jpg"));
    		label1=new JLabel(image1);
     
    		card1.add(label1);
            card1.add(new JLabel("For more information or if you are having any trouble"));
            card1.add(new JLabel("using this app please go to the following webpage"));
            card1.add(new JLabel("www.tripadviser.com or call 617-670-6300"));
     
    		//
    		//
    		//CHoose your destination
            final JPanel card2 = new JPanel();
            card2.add(new JLabel("Please choose your destination based upon on the following list given."));
     
    		final JCheckBox show1, show2, show3, show4, show5, show6, show7, show8, show9, show10;
     
    		show1 = new JCheckBox("Would you like to go to Japan?");
    		card2.add(show1);
    		show2= new JCheckBox("Would you like to go to America?");
    		card2.add(show2);
    		show3= new JCheckBox("Would you like to go to Brazil?");
    		card2.add(show3);
    		show4= new JCheckBox("Would you like to go to Africa?");
    		card2.add(show4);
    		show5= new JCheckBox("Would you like to go to Barcelona?");
    		card2.add(show5);
    		show6= new JCheckBox("Would you like to go to China?");
    		card2.add(show6);
    		show7= new JCheckBox("Would you like to go to Canada?");
    		card2.add(show7);
    		show8= new JCheckBox("Would you like to go to France?");
    		card2.add(show8);
    		show9= new JCheckBox("Would you like to go to England?");
    		card2.add(show9);
    		show10= new JCheckBox("Would you like to go to Australia?");
    		card2.add(show10);
     
    		final JLabel label1=new JLabel();
    		card2.add(label1);
    		final JLabel label2=new JLabel();
    		card2.add(label2);
    		final JLabel label3=new JLabel();
    		card2.add(label3);
    		final JLabel label4=new JLabel();
    		card2.add(label4);
    		final JLabel label5=new JLabel();
    		card2.add(label5);
    		final JLabel label6=new JLabel();
    		card2.add(label6);
    		final JLabel label7=new JLabel();
    		card2.add(label7);
    		final JLabel label8=new JLabel();
    		card2.add(label8);
    		final JLabel label9=new JLabel();
    		card2.add(label9);
    		final JLabel label10=new JLabel();
    		card2.add(label10);
     
    		label1.setForeground(Color.RED);
    		label2.setForeground(Color.BLUE);
    		label3.setForeground(Color.GREEN);
    		label4.setForeground(Color.YELLOW);
    		label5.setForeground(Color.PINK);
    		label6.setForeground(Color.BLACK);
    		label7.setForeground(Color.ORANGE);
    		label8.setForeground(Color.GRAY);
    		label9.setForeground(Color.CYAN);
    		label10.setForeground(Color.MAGENTA);
     
    		label1.setBackground(Color.BLACK);
    		label1.setOpaque(true);
    		label2.setBackground(Color.BLACK);
    		label2.setOpaque(true);
    		label3.setBackground(Color.BLACK);
    		label3.setOpaque(true);
    		label4.setBackground(Color.BLACK);
    		label4.setOpaque(true);
    		label5.setBackground(Color.BLACK);
    		label5.setOpaque(true);
    		label6.setBackground(Color.WHITE);
    		label6.setOpaque(true);
    		label7.setBackground(Color.BLACK);
    		label7.setOpaque(true);
    		label8.setBackground(Color.BLACK);
    		label8.setOpaque(true);
    		label9.setBackground(Color.BLACK);
    		label9.setOpaque(true);
    		label10.setBackground(Color.BLACK);
    		label10.setOpaque(true);
     
    		JPanel season=new JPanel();
    		season.setBackground(Color.GREEN);
    		JLabel seasons=new JLabel("Please choose the season, in which you would like to travel");
    		Font f=new Font("Serif", Font.BOLD,14);
    		seasons.setFont(f);
    		seasons.setForeground(Color.BLUE);
    		JRadioButton spring=new JRadioButton("Spring Holiday");
            JRadioButton summer=new JRadioButton("Summer Hoilday");
            JRadioButton autumn=new JRadioButton("Autumn Holiday");
            JRadioButton winter=new JRadioButton("Winter Holiday");
            season.add(spring);
            season.add(summer);
            season.add(autumn);
            season.add(winter);
    		card2.add(seasons);
            card2.add(season);
     
    	show1.addItemListener(
    	    new ItemListener() {
    	        public void itemStateChanged(ItemEvent e) {
    				label1.setText("You have choosen Japan as your destination.");
    	            if(e.getStateChange() == ItemEvent.SELECTED)
    	            	label1.setVisible(true);
    	            	else
    	            	label1.setVisible(false);
    	        }
    	    }
    	);
     
    	show2.addItemListener(
    	    new ItemListener() {
    	        public void itemStateChanged(ItemEvent e) {
    				label2.setText("You have choosen America as your destination.");
    	            if(e.getStateChange() == ItemEvent.SELECTED)
    	            	label2.setVisible(true);
    	            	else
    	            	label2.setVisible(false);
    	        }
    	    }
    	);
     
    		show3.addItemListener(
    	    new ItemListener() {
    	        public void itemStateChanged(ItemEvent e) {
    				label3.setText("You have choosen Brazil as your destination.");
    	            if(e.getStateChange() == ItemEvent.SELECTED)
    	            	label3.setVisible(true);
    	            	else
    	            	label3.setVisible(false);
    	        }
    	    }
    	);
     
    		show4.addItemListener(
    	    new ItemListener() {
    	        public void itemStateChanged(ItemEvent e) {
    				label4.setText("You have choosen Africa as your destination.");
    	            if(e.getStateChange() == ItemEvent.SELECTED)
    	            	label4.setVisible(true);
    	            	else
    	            	label4.setVisible(false);
    	        }
    	    }
    	);
     
    		show5.addItemListener(
    	    new ItemListener() {
    	        public void itemStateChanged(ItemEvent e) {
    				label5.setText("You have choosen Barcelona as your destination.");
    	            if(e.getStateChange() == ItemEvent.SELECTED)
    	            	label5.setVisible(true);
    	            	else
    	            	label5.setVisible(false);
    	        }
    	    }
    	);
     
    		show6.addItemListener(
    	    new ItemListener() {
    	        public void itemStateChanged(ItemEvent e) {
    				label6.setText("You have choosen China as your destination.");
    	            if(e.getStateChange() == ItemEvent.SELECTED)
    	            	label6.setVisible(true);
    	            	else
    	            	label6.setVisible(false);
    	        }
    	    }
    	);
     
    		show7.addItemListener(
    	    new ItemListener() {
    	        public void itemStateChanged(ItemEvent e) {
    				label7.setText("You have choosen Canada as your destination.");
    	            if(e.getStateChange() == ItemEvent.SELECTED)
    	            	label7.setVisible(true);
    	            	else
    	            	label7.setVisible(false);
    	        }
    	    }
    	);
     
    		show8.addItemListener(
    	    new ItemListener() {
    	        public void itemStateChanged(ItemEvent e) {
    				label8.setText("You have choosen France as your destination.");
    	            if(e.getStateChange() == ItemEvent.SELECTED)
    	            	label8.setVisible(true);
    	            	else
    	            	label8.setVisible(false);
    	        }
    	    }
    	);
     
    		show9.addItemListener(
    	    new ItemListener() {
    	        public void itemStateChanged(ItemEvent e) {
    				label9.setText("You have choosen England as your destination.");
    	            if(e.getStateChange() == ItemEvent.SELECTED)
    	            	label9.setVisible(true);
    	            	else
    	            	label9.setVisible(false);
    	        }
    	    }
    	);
     
    		show10.addItemListener(
    	    new ItemListener() {
    	        public void itemStateChanged(ItemEvent e) {
    				label10.setText("You have choosen Australia as your destination.");
    	            if(e.getStateChange() == ItemEvent.SELECTED)
    	            	label10.setVisible(true);
    	            	else
    	            	label10.setVisible(false);
    	        }
    	    }
    	);
     
            //end of chose your destination
    		//
    		//
            //Submit your family details
            JPanel card4 =new JPanel();
            JPanel p10=new JPanel();
            JPanel p11=new JPanel();
            JPanel p12=new JPanel();
            JPanel p13=new JPanel();
            JPanel p14=new JPanel();
     
            p10.setLayout(new GridLayout(6,2));
            p11.setLayout(new GridLayout(4,1));
            p12.setLayout(new GridLayout(2,2));
            p14.setLayout(new GridLayout(3,2));
     
            p11.setBackground(Color.YELLOW);
            p13.setBackground(Color.BLUE);
     
            JLabel manager=new JLabel("Please note, there must only one person in charge ");
            JLabel manager1=new JLabel("of submitting the family details.");
            JLabel manager2=new JLabel("However two numbers are required if the person managing ");
            JLabel manager3=new JLabel("the information cannot be contacted.");
            JLabel checkin=new JLabel("Family Check-in Date:");
            JLabel checkout=new JLabel("Family Check-out Date:");
            JLabel Name=new JLabel("Faimly Last Name:");
            JLabel fName=new JLabel("First Name:");
     
            JLabel Adults=new JLabel("Adults:>>>");
            JLabel Children=new JLabel("Children:>>>");
            String number[]={"1","2","3","4","5","6","7","8","9","10"};
            JComboBox familynumber=new JComboBox(number);
            String number1[]={"1","2","3","4","5","6","7","8","9","10"};
            JComboBox childrenumber=new JComboBox(number1);
     
            JTextField  tf10=new JTextField("DD/MM/YYYY",5);
            JTextField  tf11=new JTextField("DD/MM/YYYY",5);
            JTextField  tf12=new JTextField(5);
            JTextField  tf13=new JTextField(5);
     
            JButton submit=new JButton("Submit Your Information");
     
            JLabel room=new JLabel("Please select the room type for your party:");
            JRadioButton single=new JRadioButton("Single Room");
            JRadioButton double1=new JRadioButton("Double Room");
            JRadioButton ensuite=new JRadioButton("Ensuite Room");
            JRadioButton familyr=new JRadioButton("Family Room");
            JRadioButton firstc=new JRadioButton("First Class Room");
     
            image2 = new ImageIcon(getClass().getResource("holiday.jpg"));
    		holiday=new JLabel(image2);
     
            p11.add(manager);
            p11.add(manager1);
            p11.add(manager2);
            p11.add(manager3);
     
            p10.add(checkin); p10.add(tf10);
            p10.add(checkout); p10.add(tf11);
            p10.add(Name); p10.add(tf12);
            p10.add(fName); p10.add(tf13);
     
            p12.add(Adults); p12.add(familynumber);
            p12.add(Children); p12.add(childrenumber);
     
            p14.add(room);
            p14.add(single); p14.add(double1);
            p14.add(ensuite); p14.add(familyr); p14.add(firstc);
     
            p13.add(submit);
     
            submit.addActionListener(new ActionListener(){
      		public void actionPerformed(ActionEvent e){
      		JOptionPane.showMessageDialog(null, "Thank you for submitting your information", "Information", JOptionPane.INFORMATION_MESSAGE);
      		}
      		});
     
    		card4.add(p11);
    		card4.add(p10);
    		card4.add(p12);
    		card4.add(p14);
    		card4.add(p13);
    		card4.add(holiday);
            //end of submit your family details
    		//
    		//
            //Add/remove combo box
            JPanel card3 =new JPanel();
            String items[] = {"Honda", "Ford", "BMW", "Audi"};
      		combo = new JComboBox(items);
      		JButton button1 = new JButton("Add");
      		txtBox = new JTextField(20);
      		button1.addActionListener(new ActionListener(){
      		public void actionPerformed(ActionEvent e){
      		if (!txtBox.getText().equals("")){
      		int a = 0;
      		for(int i = 0; i < combo.getItemCount(); i++){
      		if(combo.getItemAt(i).equals(txtBox.getText())){
      		a = 1;
      		break;
      		}
      		}
      		if (a == 1)
     		JOptionPane.showMessageDialog(null,"Combo has already this item.");
      		else
      		combo.addItem(txtBox.getText());
      		}
      		else{
      		JOptionPane.showMessageDialog(null,"Please enter text in Text Box");
      		}
      		}
      		});
      		JButton button2 = new JButton("Remove");
      		button2.addActionListener(new ActionListener(){
      		public void actionPerformed(ActionEvent e){
      		if (combo.getItemCount() > 0)
      		combo.removeItemAt(0);
      		else
      		JOptionPane.showMessageDialog(null,"Item not available");
      		}
      		});
      		card3.add(txtBox);
      		card3.add(combo);
      		card3.add(button1);
      		card3.add(button2);
            //end of combo box
    		//
    		//
            //Write a user review
    		JPanel card5 =new JPanel();
     
    		JPanel p21=new JPanel();
    		JPanel p22=new JPanel();
     
    		final JTextArea ta5=new JTextArea(16,16);
    		final JTextField tf6=new JTextField(10);
    		JButton send=new JButton("Send");
     
            send.addActionListener(new ActionListener(){
      		public void actionPerformed(ActionEvent e){
      		ta5.setText(tf6.getText());
      		}
      		});
     
      		card5.add(ta5);
      		card5.add(tf6);
      		card5.add(send);
            //end of write a user review
    		//
    		//
            //Create the panel that contains the "cards".
            cards = new JPanel(new CardLayout());
            cards.add(card1, BUTTONPANEL);
            cards.add(card2, TEXTPANEL);
            cards.add(card3, AddCombo);
            cards.add(card4, FamilyDetails);
            cards.add(card5, UserReview);
     
            pane.add(comboBoxPane, BorderLayout.PAGE_START);
            pane.add(cards, BorderLayout.CENTER);
        }
     
     
        public void itemStateChanged(ItemEvent evt) {
            CardLayout cl = (CardLayout)(cards.getLayout());
            cl.show(cards, (String)evt.getItem());
        }
     
        /**
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event-dispatching thread.
         */
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("Keith");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     
            //Create and set up the content pane.
            CardLayoutDemo demo = new CardLayoutDemo();
            demo.addComponentToPane(frame.getContentPane());
     
            //Display the window.
            frame.pack();
            frame.setSize(500,700);
            frame.setVisible(true);
        }
     
        public CardLayoutDemo() {
            //Schedule a job for the event-dispatching thread:
            //creating and showing this application's GUI.
            javax.swing.SwingUtilities.invokeLater(new Runnable() {
                public void run() {
                    createAndShowGUI();
                }
            });
        }
    }


  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: Java, calling another public class from within the main class giving problems.

    it will open the public class an infinite number of times,
    Sounds like a recursive loop. Make sure the code does not have recursive calls.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Java, calling another public class from within the main class giving problems.

    Checked and there is not, any other thoughts?

  4. #4
    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: Java, calling another public class from within the main class giving problems.

    there is not
    There are. Here's how to find it:
    Change the lines around the constructor to include these extra lines:
        static int cnt = 0;          //<<<<<<<<<<<<< for debugging
     
        public CardLayoutDemo() {  //  Original constructor
             if(cnt++ > 3)  return; //<<<<<<<<<<<    count number of calls and exit early
             Thread.dumpStack();    //  show stack - who called us

    This will give a stack dump every time the constructor is called and stop giving the dump after 3 times so there isn't too much output.

    Look in the stack dump to see where the constructor is called.

    java.lang.Exception: Stack trace
    	at java.lang.Thread.dumpStack(Unknown Source)
    	at CardLayoutDemo.<init>(CardLayoutDemo.java:465)
    	at CardLayoutDemo$16.actionPerformed(CardLayoutDemo.java:485)
    Here the constructor (<init>) was called on line 485
    If you don't understand my answer, don't ignore it, ask a question.

  5. The Following User Says Thank You to Norm For This Useful Post:

    RandomGaisha (November 26th, 2012)

  6. #5
    Junior Member
    Join Date
    Nov 2012
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Java, calling another public class from within the main class giving problems.

    Sorry but could you dumb it down a little bit there, i do not understand what you mean, and my CardLayoutDemo code only goes to line 462?

  7. #6
    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: Java, calling another public class from within the main class giving problems.

    Replace the one line of the constructor with the 4 lines that I posted. The second line of what I posted is the original constructor. There is one new line before it and 2 new lines after it.

    my CardLayoutDemo code only goes to line 462?
    My source code has other things in it that change their location. I put the main() method in the class with the code that it executes instead of having a separate, useless class for the main() method.

    do not understand what you mean,
    Sorry, let me explain. The code has a recursive call in it that will cause lots of print out from the dump. I want to shorten that output. I added a static int variable: cnt that will count the number of times the constructor is called (cnt++). When the value of cnt is > 3 the code returns which causes other problems that end the endless looping. The call to Thread.dumpStack() prints out the current contents of the call stack which shows where the constructor was called from. That allows you to see where the recursive loop is.
    If you don't understand my answer, don't ignore it, ask a question.

  8. The Following User Says Thank You to Norm For This Useful Post:

    RandomGaisha (November 26th, 2012)

  9. #7
    Junior Member
    Join Date
    Nov 2012
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Java, calling another public class from within the main class giving problems.

    omg dude you are awesome, thanks a million for that ^_^.
    If you would be so kind to look at this problem now.
    now that is solved i was getting an error for (CardLayoutDemo) is not a statement and ( expected

    could you have a look at this.
    		JLabel l1=new JLabel("Username:");
    		JLabel l2=new JLabel("Password:");
    		final JTextField tf1=new JTextField(5);
    		final JTextField tf2=new JTextField(5);
    		JButton login=new JButton("Login");
     
            final String user = "pass";
            final String passwd = "pass";
            cp.add(l1); cp.add(tf1);
            cp.add(l2); cp.add(tf2);
     
     
     
            ActionListener a1 = new ActionListener() {
    	public void actionPerformed(ActionEvent e) {
    		 String myText1 = tf1.getText();
    		 String myText2 = tf2.getText();
                      if ((myText1.equals(user)) && (myText2.equals(passwd)))
    						CardLayoutDemo t1=new CardLayoutDemo();
                    }
                    };

    the errors are as shown.

    \Login.java:31: not a statement
    						CardLayoutDemo t1=new CardLayoutDemo();
    						^
    notes\Login.java:31: ';' expected
    						CardLayoutDemo t1=new CardLayoutDemo();
    						                     ^
    2 errors
    Last edited by Norm; November 26th, 2012 at 02:01 PM. Reason: added / in code tag

  10. #8
    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: Java, calling another public class from within the main class giving problems.

    One problem is the poor formatting makes it hard to read the code.
    Another problem is the lack of {}s following the if statement.

    What you have posted won't compile so I can't test that to see what the error is.
    If you don't understand my answer, don't ignore it, ask a question.

  11. #9
    Junior Member
    Join Date
    Nov 2012
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Java, calling another public class from within the main class giving problems.

    sorry about that, its basically just adding a condition to the to the "login" button in the main screen "login", and then calling "DemoCardLayout" if the both the text fields are true.

    //This will be the login screen for CardLayoutDemo
     
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
     
    public class Login{
    	public static void main(String [] args){
    		JFrame f1=new JFrame("Keith");
    		Container cp=f1.getContentPane();
    		cp.setLayout(new FlowLayout());
     
    		JLabel l1=new JLabel("Username:");
    		JLabel l2=new JLabel("Password:");
    		final JTextField tf1=new JTextField(5);
    		final JTextField tf2=new JTextField(5);
    		JButton login=new JButton("Login");
     
            final String user = "pass";
            final String passwd = "pass";
            cp.add(l1); cp.add(tf1);
            cp.add(l2); cp.add(tf2);
     
     
     
            ActionListener a1 = new ActionListener() {
    	public void actionPerformed(ActionEvent e) {
    		 String myText1 = tf1.getText();
    		 String myText2 = tf2.getText();
                      if ((myText1.equals(user)) && (myText2.equals(passwd)))
    						CardLayoutDemo t1=new CardLayoutDemo();
                    }
                    };
     
    		login.addActionListener(a1);
    		cp.add(login);
    		f1.pack();
    		f1.setDefaultCloseOperation(f1.EXIT_ON_CLOSE);
    		f1.setSize(300,300);
    		f1.setVisible(true);
    	}
    }

  12. #10
    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: Java, calling another public class from within the main class giving problems.

    Where did you fix the formatting and add the {}s?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Replies: 2
    Last Post: November 18th, 2012, 02:09 PM
  2. need to make basic class and implementation class (base class without void main)
    By javanewbie101 in forum Object Oriented Programming
    Replies: 1
    Last Post: September 19th, 2012, 08:03 PM
  3. create a test class (main method) to start(run) the class in Java
    By curious725 in forum Java Theory & Questions
    Replies: 5
    Last Post: August 1st, 2012, 03:21 AM
  4. Replies: 3
    Last Post: June 17th, 2012, 06:22 PM
  5. What's difference between public class and abstract class?
    By Java95 in forum Java Theory & Questions
    Replies: 7
    Last Post: January 24th, 2012, 07:37 AM

Tags for this Thread