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.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Terminated with code 0 but cannot run.

  1. #1
    Junior Member
    Join Date
    Nov 2013
    Thanked 0 Times in 0 Posts

    Question Terminated with code 0 but cannot run.

    Any help are appreciated....running using crimson editor...
    Below are my codes:


    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    import java.text.*;

    public class PT2_10 extends JFrame
    { JLabel label1 = new JLabel("a");
    JLabel label2 = new JLabel("b");
    JLabel label3 = new JLabel("c");
    JLabel label4 = new JLabel("Angle a");
    JLabel label5 = new JLabel("Angle b");
    JLabel label6 = new JLabel("Angle c");
    JTextField a = new JTextField("");
    JTextField b = new JTextField("");
    JTextField c = new JTextField("");
    JTextField anga = new JTextField("");
    JTextField angb = new JTextField("");
    JTextField angc = new JTextField("");
    JButton cal = new JButton("Calculate");
    JButton clr = new JButton("Clear");

    { Container c = getContentPane();
    c.setLayout(new GridLayout(5,3));

    setTitle("Triangle Solver");




    public class TestPT2_10
    public static void main(String [ ] args)
    PT2_10 myPT2_10 = new PT2_10();

    I got the following error:
    ---------- Capture Output ----------
    > "C:\Program Files (x86)\Java\jdk1.6.0_21\bin\java.exe" TestPT2_10
    Exception in thread "main" java.lang.IllegalArgumentException: adding container's parent to itself
    at java.awt.Container.checkAddToSelf(Container.java:4 20)
    at java.awt.Container.addImpl(Container.java:1038)
    at java.awt.Container.add(Container.java:365)
    at PT2_10.<init>(PT2_10.java:26)
    at TestPT2_10.main(TestPT2_10.java:5)
    > Terminated with exit code 1.

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 688 Times in 675 Posts

    Default Re: Terminated with code 0 but cannot run.

    Welcome to the Forum. You can read this FAQ to learn how to post code correctly along with other useful tips for newcomers.

    The practice of putting multiple comments on a single line is annoying because it makes your code difficult to read, even worse that they're all crammed together with no whitespace. Are you trying to conserve electrons?

    Single-letter variable names are rarely acceptable and are contributing to the error you're getting. Give your variables better names, put each statement on its own line, add some whitespace to make your program readable, and you may discover the source of your error. If not, come back with your code formatted and posted correctly, and we'll help you further.

Similar Threads

  1. Replies: 7
    Last Post: May 8th, 2013, 02:33 PM
  2. Need some help getting this code to run...
    By xJavaLover in forum What's Wrong With My Code?
    Replies: 11
    Last Post: February 5th, 2013, 06:43 AM
  3. Replies: 2
    Last Post: November 18th, 2012, 01:09 PM
  4. Replies: 1
    Last Post: October 7th, 2011, 03:32 AM
  5. How to run this code?
    By jackdear44 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: April 1st, 2010, 11:37 PM