I am producing a library for personal use; in this particular class, extending JPanel
, and my code still for some random reason, produces a StackOverflowError
any tips?
public class XJPanel extends JPanel
{
static boolean isManaged = false;
public XJPanel() {
}
public XJPanel(LayoutManager arg0) {
super(arg0);
isManaged = true;
}
public XJPanel(boolean arg0) {
super(arg0);
// TODO Auto-generated constructor stub
}
public XJPanel(LayoutManager arg0, boolean arg1) {
super(arg0, arg1);
isManaged = true;
}
public GridBagConstraints getConstraints()
{
if(isManaged = true)
{
return new GridBagConstraints();
}
throw new NullPointerException("No Layout Manager Found");
}
/*
public XJPanel add(Component arg0)
{
JPanel p = getRoot();
p.add(arg0);
return null;
}
private JPanel getRoot() {
return this;
}*/
the error it reads is exactly as follows. I think I understand what a StackOverflowError
is, but I'd like to know why the error message includes the package declaration -- it contains no code, so... why?
Exception in thread "main" java.lang.StackOverflowError
at javar.swing.XJPanel.getRoot(XJPanel.java:61)
at javar.swing.XJPanel.add(XJPanel.java:55)
at javar.swing.XJPanel.add(XJPanel.java:1)
...
at javar.swing.XJPanel.add(XJPanel.java:56)
at javar.swing.XJPanel.add(XJPanel.java:1)
at javar.swing.XJPanel.add(XJPanel.java:56)
the javar.swing.XJPanel.add(XJPanel.java:1) being my package declaration.
Note:
I'm sorry for being such a jerk, @SimonC I guess I had a case of the grumps, I'm well rested now and ready to shape up.