Any help are appreciated....running using crimson editor...
Below are my codes:
PT2_10.java
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");
PT2_10()
{ Container c = getContentPane();
c.setLayout(new GridLayout(5,3));
c.add(label1);c.add(label2);c.add(label3);
c.add(a);c.add(b);c.add(c);
c.add(label4);c.add(label5);c.add(label6);
c.add(anga);c.add(angb);c.add(angc);
c.add(cal);c.add(clr);
setSize(1000,1000);
setTitle("Triangle Solver");
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
----------------------------------------------------------------------------------------
TestPT2_10.java
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.