-
Bug
-
Resolution: Fixed
-
P2
-
1.0
-
1.0.2
-
sparc
-
solaris_2.4
-
Not verified
}
public void setCause(String cause)
{
this.cause = cause;
}
public String getEvaluation()
{
return evaluation;
}
public void setEvaluation(String evaluation)
{
this.evaluation = evaluation;
}
public int getDuplicateOf()
{
return duplicateOf;
}
public void setDuplicateOf(int duplicateOf)
{
this.duplicateOf = duplicateOf;
}
public String getInterestList()
{
return interestList;
}
public void setInterestList(String interestList)
{
this.interestList = interestList;
}
public String getKeywords()
{
return keywords;
}
public void setKeywords(String keywords)
{
this.keywords = keywords;
}
public boolean getAccepted()
{
return accepted;
}
public void setAccepted(boolean accepted)
{
this.accepted = accepted;
}
}
---- end ----
---- begin drmbugtool.java ----
import dream.report.*;
import java.applet.*;
import java.util.*;
import java.awt.*;
public class drmbugtool extends Applet
{
static String submitter;
public static void main(String args[])
{
drmbugtool b;
Frame f;
if (args.length != 1)
{
System.out.println("usage: java drmbugtool username");
System.exit(1);
}
submitter = args[0];
f = new Frame("DReAM Report Tool");
b = new drmbugtool();
f.resize(190, 110);
b.init();
b.start();
f.add("Center", b);
f.show();
}
public void init()
{
setLayout(new BorderLayout());
add("Center", new TopLevelPanel(submitter));
}
public boolean handleEvent(Event e)
{
switch (e.id)
{
case Event.WINDOW_DESTROY:
System.exit(0);
return true;
default:
return false;
}
}
}
class SuperCheckbox extends Checkbox
{
private Component[] children;
public SuperCheckbox(Component[] children, String string,
CheckboxGroup group, boolean state)
{
super(string, group, state);
this.children = children;
for (int i = 0; i < children.length; i++)
{
children[i].enable(state);
}
}
public void setState(boolean state)
{
super.setState(state);
for (int i = 0; i < children.length; i++)
{
children[i].enable(state);
}
}
}
interface Callable
{
public abstract String submitterName();
public abstract int reportType();
}
class ReportCreator implements Runnable
{
ReportPanel panel;
Frame frame;
Thread thr;
public ReportCreator(Callable callable)
{
String[] categoria = { "foo", "bar" };
String[] subCategoria = { "baz", "bax" };
int ID = 73324;
int type = callable.reportType();
thr = new Thread(this);
try
{
panel = new ReportPanel(new Report(ID, type, callable.submitterName()),
categoria, subCategoria);
frame = new Frame("DReAM " + (type == Report.TYPE_BUG ? "bug" : "RFE")
+ " no. " + ID);
frame.setLayout(new BorderLayout());
frame.resize(650, 500);
frame.add("Center", panel);
frame.show();
}
catch (InvalidReportException e)
{
System.out.println("Yikes! Invalid report: " + e);
}
thr.start();
}
public void run()
{
System.out.println("foo");
try
{
Thread.sleep(5000);
}
catch (Exception e)
{
}
System.out.println("bar");
}
}
class StartButton extends Button
{
Callable c;
public StartButton(String s, Callable c)
{
super(s);
this.c = c;
}
public boolean action(Event e, Object o)
{
new ReportCreator(c);
return true;
}
}
class TopLevelPanel extends Panel implements Callable
{
TextField ID = new TextField(6);
Component[] cID = { ID };
CheckboxGroup type = new CheckboxGroup();
Checkbox bug = new Checkbox("Bug", type, true);
Checkbox rfe = new Checkbox("RFE", type, false);
Component[] ctype = { bug, rfe };
CheckboxGroup action = new CheckboxGroup();
Checkbox edit = new SuperCheckbox(cID, "Edit report ID:", action, false);
Checkbox create = new SuperCheckbox(ctype, "Create new report", action, true);
Button go = new StartButton("Start", this);
String submitter;
public TopLevelPanel(String submitter)
{
GridBagLayout layout = new GridBagLayout();
GridBagConstraints c;
this.submitter = submitter;
setLayout(layout);
c = new GridBagConstraints();
c.weightx = 0.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.RELATIVE;
layout.setConstraints(edit, c);
c = new GridBagConstraints();
c.weightx = 1.0;
c.anchor = GridBagConstraints.EAST;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(ID, c);
c = new GridBagConstraints();
c.weightx = 1.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(create, c);
c = new GridBagConstraints();
c.weighty = 1.5;
c.anchor = GridBagConstraints.SOUTH;
c.gridheight = GridBagConstraints.REMAINDER;
c.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(go, c);
add(edit);
add(ID);
add(create);
add(go);
}
public String submitterName()
{
return submitter;
}
public int reportType()
{
if (bug.getState())
{
return Report.TYPE_BUG;
}
else if (rfe.getState())
{
return Report.TYPE_RFE;
} else {
return 2345;
}
}
}
---- end ----
If I run the drmbugtool application from java, I get the following excetion:
java.lang.ArrayIndexOutOfBoundsException: 128
at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:724)
at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:978)
at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:407)
at java.awt.Container.layout(Container.java:240)
at java.awt.Component.validate(Component.java:526)
at java.awt.Container.validate(Container.java:250)
at java.awt.Container.validate(Container.java:254)
at java.awt.Window.show(Window.java:95)
at ReportCreator.<init>(drmbugtool.java:108)
at StartButton.action(drmbugtool.java:145)
at java.awt.Component.handleEvent(Component.java:900)
at java.awt.Component.postEvent(Component.java:838)
at sun.awt.motif.MButtonPeer.action(MButtonPeer.java:39)
at java.lang.Thread.run(Thread.java)
If I uncomment the line labeled with "COMMENT ME OUT" in
dream/report/ReportPanel.java, then everything works (but the layout
produced by the GridBagLayout is incorrect).
I am surprised that this change should eliminate the exception, since I have
several instances of a similar layout pattern in my code (as a brief examination
will show).
Consider the following classes:
---- begin dream/report/ReportPanel.java ----
package dream.report;
import java.awt.*;
class TextFrame extends Frame
{
TextArea text = new TextArea(80, 10);
public TextFrame(String title)
{
super(title);
resize(750, 300);
add("Center", text);
}
public String getText()
{
return text.getText();
}
public void setText(String text)
{
this.text.setText(text);
}
}
class PopButton extends Button
{
Window window;
public PopButton(String title, Window window)
{
super(title);
this.window = window;
}
public boolean action(Event e, Object o)
{
window.show();
return true;
}
}
public class ReportPanel extends Panel
{
Report report;
CheckboxGroup priority = new CheckboxGroup();
Checkbox priority1 = new Checkbox("1", priority, false);
Checkbox priority2 = new Checkbox("2", priority, false);
Checkbox priority3 = new Checkbox("3", priority, false);
Checkbox priority4 = new Checkbox("4", priority, false);
Checkbox priority5 = new Checkbox("5", priority, false);
CheckboxGroup severity = new CheckboxGroup();
Checkbox severity1 = new Checkbox("1", severity, false);
Checkbox severity2 = new Checkbox("2", severity, false);
Checkbox severity3 = new Checkbox("3", severity, false);
Choice category = new Choice();
Choice subCategory = new Choice();
Choice status = new Choice();
TextField engineer = new TextField(8);
TextField synopsis = new TextField(40);
TextFrame description;
TextFrame workAround;
TextFrame comments;
TextFrame evaluation;
TextField duplicateOf = new TextField(6);
public ReportPanel(Report report, String[] categories, String[] subCategories)
{
String[] statuses = { "not yet investigated",
"can't reproduce yet",
"investigated - cause of problem known",
"too risky to fix",
"fix in progress",
"no resources available now",
"code freeze - can't fix now",
"fixed",
"integrated fix",
"closed" };
GridBagLayout l = new GridBagLayout();
GridBagConstraints c;
String titleFrag = (report.getType() == Report.TYPE_BUG ? "Bug" : "RFE")
+ " no. " + report.getID();
Component tmp;
setLayout(l);
tmp = new Label("Priority:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority1, c);
add(priority1);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority2, c);
add(priority2);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority2, c);
add(priority2);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority3, c);
add(priority3);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority4, c);
add(priority4);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority5, c);
add(priority5);
tmp = new Label("Severity:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
c = new GridBagConstraints();
c.weightx = 13.3;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(severity1, c);
add(severity1);
c = new GridBagConstraints();
c.weightx = 13.3;
c.anchor = GridBagConstraints.CENTER;
// c.gridwidth = GridBagConstraints.RELATIVE;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(severity2, c);
add(severity2);
c = new GridBagConstraints();
c.weightx = 13.3;
c.anchor = GridBagConstraints.CENTER;
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(severity3, c);
add(severity3);
tmp = new Label("Category:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
for (int i = 0; i < categories.length; i++)
{
category.addItem(categories[i]);
}
c = new GridBagConstraints();
c.weightx = 40.0;
c.gridwidth = 5;
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(category, c);
add(category);
tmp = new Label("Subcategory:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.gridwidth = GridBagConstraints.RELATIVE;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
for (int i = 0; i < subCategories.length; i++)
{
subCategory.addItem(subCategories[i]);
}
c = new GridBagConstraints();
c.weightx = 40.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(subCategory, c);
add(subCategory);
tmp = new Label("Status:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
for (int i = 0; i < statuses.length; i++)
{
status.addItem(statuses[i]);
}
c = new GridBagConstraints();
c.weightx = 40.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = 5;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(status, c);
add(status);
tmp = new Label("Responsible engineer:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.gridwidth = GridBagConstraints.RELATIVE; // COMMENT ME OUT
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
c = new GridBagConstraints();
c.weightx = 40.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(engineer, c);
add(engineer);
tmp = new Label("Synopsis:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
c.gridwidth = 1;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
c = new GridBagConstraints();
c.weightx = 90.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(synopsis, c);
add(synopsis);
// description = new TextFrame(titleFrag + " description");
// tmp = new PopButton("Description", description);
// c = new GridBagConstraints();
// c.weightx = 25.0;
// c.anchor = GridBagConstraints.CENTER;
// c.gridwidth = 3;
// c.fill = GridBagConstraints.HORIZONTAL;
// l.setConstraints(tmp, c);
// add(tmp);
// workAround = new TextFrame(titleFrag + " workarounds");
// tmp = new PopButton("Workarounds", workAround);
// c = new GridBagConstraints();
// c.weightx = 25.0;
// c.anchor = GridBagConstraints.CENTER;
// c.gridwidth = 3;
// // c.fill = GridBagConstraints.HORIZONTAL;
// l.setConstraints(tmp, c);
// add(tmp);
// comments = new TextFrame(titleFrag + " comments");
// tmp = new PopButton("Comments", comments);
// c = new GridBagConstraints();
// c.weightx = 25.0;
// c.anchor = GridBagConstraints.CENTER;
// c.gridwidth = 3;
// // c.fill = GridBagConstraints.HORIZONTAL;
// l.setConstraints(tmp, c);
// add(tmp);
// evaluation = new TextFrame(titleFrag + " evaluation");
// tmp = new PopButton("Evaluation", evaluation);
// c = new GridBagConstraints();
// c.weightx = 25.0;
// c.anchor = GridBagConstraints.CENTER;
// c.gridwidth = GridBagConstraints.REMAINDER;
// c.fill = GridBagConstraints.HORIZONTAL;
// l.setConstraints(tmp, c);
// add(tmp);
tmp = new Label("Duplicate of:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
c.gridwidth = 1;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
c = new GridBagConstraints();
c.weightx = 90.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(synopsis, c);
add(duplicateOf);
}
}
---- end ----
---- begin dream/report/Report.java ----
package dream.report;
import dream.report.InvalidReportException;
public class Report
{
/** the ID number of a report */
private int ID = -1;
/** the type of a report - bug or rfe */
private int type = -1;
public static final int TYPE_BUG = 0;
public static final int TYPE_RFE = 1;
/** the category of a bug or rfe */
private String category;
/** the subcategory of a bug or rfe */
private String subCategory;
/** the priority of a report indicates how important we think it is */
private int priority = 0;
public final static int PRI_HIGHEST = 1;
public final static int PRI_LOWEST = 5;
/** the severity of a report indicates its impact on the user */
private int severity = 0;
public final static int SEV_HIGHEST = 1;
public final static int SEV_LOWEST = 3;
/** the status of our dealings with a report */
private int status = -1;
public final static int STAT_MIN = 0;
/** not yet investigated */
public final static int STAT_NYI = 0;
/** can't reproduce yet */
public final static int STAT_CNR = 1;
/** investigated - cause of problem known */
public final static int STAT_CPK = 2;
/** too risky to fix */
public final static int STAT_RSK = 3;
/** fix in progress */
public final static int STAT_FIP = 4;
/** no resources available now */
public final static int STAT_NRA = 5;
/** code freeze - can't fix now */
public final static int STAT_CFN = 6;
/** fixed */
public final static int STAT_FIX = 7;
/** integrated fix */
public final static int STAT_INT = 8;
/** closed */
public final static int STAT_CLO = 9;
public final static int STAT_MAX = 9;
/** the engineer responsible for this report */
private String engineer;
/** the submitter of this report */
private String submitter;
/** a synopsis of this report */
private String synopsis;
/** a detailed description of this report */
private String description;
/** workarounds for this report, if any */
private String workAround;
/** comments pertaining to this report */
private String comments;
/** the cause of the problem or rfe */
private String cause;
/** our evaluation of the report */
private String evaluation;
/** whether the report is a duplicate of another */
private int duplicateOf = -1;
/** email addresses of other interested parties */
private String interestList;
/** key words */
private String keywords;
/** whether we have accepted this report or not */
private boolean accepted;
public Report(int ID, int type, String submitter) throws InvalidReportException
{
this.ID = ID;
if (type != TYPE_BUG && type != TYPE_RFE)
{
throw new InvalidReportException("report is of some weird type " + type);
}
this.type = type;
this.submitter = submitter;
}
public int getID()
{
return ID;
}
public int getType()
{
return type;
}
public String getCategory()
{
return category;
}
public void setCategory(String category)
{
this.category = category;
}
public String getSubCategory()
{
return subCategory;
}
public void setSubCategory(String subCategory)
{
this.subCategory = subCategory;
}
public int getPriority()
{
return priority;
}
public void setPriority(int priority) throws InvalidReportException
{
if (priority < PRI_HIGHEST || priority > PRI_LOWEST)
{
throw new InvalidReportException("invalid report priority " + priority);
}
this.priority = priority;
}
public int getSeverity()
{
return severity;
}
public void setSeverity(int severity) throws InvalidReportException
{
if (severity < SEV_HIGHEST || severity > SEV_LOWEST)
{
throw new InvalidReportException("invalid report severity " + severity);
}
this.severity = severity;
}
public int getStatus()
{
return status;
}
public void setStatus(int status) throws InvalidReportException
{
if (status < STAT_MIN || status > STAT_MAX)
{
throw new InvalidReportException("invalid report status " + status);
}
this.status = status;
}
public String getEngineer()
{
return engineer;
}
public void setEngineer(String engineer)
{
this.engineer = engineer;
}
public String getSubmitter()
{
return submitter;
}
public String getSynopsis()
{
return synopsis;
}
public void setSynopsis(String synopsis)
{
this.synopsis = synopsis;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public String getWorkAround()
{
return workAround;
}
public void setWorkAround(String workAround)
{
this.workAround = workAround;
}
public String getComments()
{
return comments;
}
public void setComments(String comments)
{
this.comments = comments;
}
public String getCause()
{
return cause;
public void setCause(String cause)
{
this.cause = cause;
}
public String getEvaluation()
{
return evaluation;
}
public void setEvaluation(String evaluation)
{
this.evaluation = evaluation;
}
public int getDuplicateOf()
{
return duplicateOf;
}
public void setDuplicateOf(int duplicateOf)
{
this.duplicateOf = duplicateOf;
}
public String getInterestList()
{
return interestList;
}
public void setInterestList(String interestList)
{
this.interestList = interestList;
}
public String getKeywords()
{
return keywords;
}
public void setKeywords(String keywords)
{
this.keywords = keywords;
}
public boolean getAccepted()
{
return accepted;
}
public void setAccepted(boolean accepted)
{
this.accepted = accepted;
}
}
---- end ----
---- begin drmbugtool.java ----
import dream.report.*;
import java.applet.*;
import java.util.*;
import java.awt.*;
public class drmbugtool extends Applet
{
static String submitter;
public static void main(String args[])
{
drmbugtool b;
Frame f;
if (args.length != 1)
{
System.out.println("usage: java drmbugtool username");
System.exit(1);
}
submitter = args[0];
f = new Frame("DReAM Report Tool");
b = new drmbugtool();
f.resize(190, 110);
b.init();
b.start();
f.add("Center", b);
f.show();
}
public void init()
{
setLayout(new BorderLayout());
add("Center", new TopLevelPanel(submitter));
}
public boolean handleEvent(Event e)
{
switch (e.id)
{
case Event.WINDOW_DESTROY:
System.exit(0);
return true;
default:
return false;
}
}
}
class SuperCheckbox extends Checkbox
{
private Component[] children;
public SuperCheckbox(Component[] children, String string,
CheckboxGroup group, boolean state)
{
super(string, group, state);
this.children = children;
for (int i = 0; i < children.length; i++)
{
children[i].enable(state);
}
}
public void setState(boolean state)
{
super.setState(state);
for (int i = 0; i < children.length; i++)
{
children[i].enable(state);
}
}
}
interface Callable
{
public abstract String submitterName();
public abstract int reportType();
}
class ReportCreator implements Runnable
{
ReportPanel panel;
Frame frame;
Thread thr;
public ReportCreator(Callable callable)
{
String[] categoria = { "foo", "bar" };
String[] subCategoria = { "baz", "bax" };
int ID = 73324;
int type = callable.reportType();
thr = new Thread(this);
try
{
panel = new ReportPanel(new Report(ID, type, callable.submitterName()),
categoria, subCategoria);
frame = new Frame("DReAM " + (type == Report.TYPE_BUG ? "bug" : "RFE")
+ " no. " + ID);
frame.setLayout(new BorderLayout());
frame.resize(650, 500);
frame.add("Center", panel);
frame.show();
}
catch (InvalidReportException e)
{
System.out.println("Yikes! Invalid report: " + e);
}
thr.start();
}
public void run()
{
System.out.println("foo");
try
{
Thread.sleep(5000);
}
catch (Exception e)
{
}
System.out.println("bar");
}
}
class StartButton extends Button
{
Callable c;
public StartButton(String s, Callable c)
{
super(s);
this.c = c;
}
public boolean action(Event e, Object o)
{
new ReportCreator(c);
return true;
}
}
class TopLevelPanel extends Panel implements Callable
{
TextField ID = new TextField(6);
Component[] cID = { ID };
CheckboxGroup type = new CheckboxGroup();
Checkbox bug = new Checkbox("Bug", type, true);
Checkbox rfe = new Checkbox("RFE", type, false);
Component[] ctype = { bug, rfe };
CheckboxGroup action = new CheckboxGroup();
Checkbox edit = new SuperCheckbox(cID, "Edit report ID:", action, false);
Checkbox create = new SuperCheckbox(ctype, "Create new report", action, true);
Button go = new StartButton("Start", this);
String submitter;
public TopLevelPanel(String submitter)
{
GridBagLayout layout = new GridBagLayout();
GridBagConstraints c;
this.submitter = submitter;
setLayout(layout);
c = new GridBagConstraints();
c.weightx = 0.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.RELATIVE;
layout.setConstraints(edit, c);
c = new GridBagConstraints();
c.weightx = 1.0;
c.anchor = GridBagConstraints.EAST;
c.fill = GridBagConstraints.HORIZONTAL;
c.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(ID, c);
c = new GridBagConstraints();
c.weightx = 1.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(create, c);
c = new GridBagConstraints();
c.weighty = 1.5;
c.anchor = GridBagConstraints.SOUTH;
c.gridheight = GridBagConstraints.REMAINDER;
c.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(go, c);
add(edit);
add(ID);
add(create);
add(go);
}
public String submitterName()
{
return submitter;
}
public int reportType()
{
if (bug.getState())
{
return Report.TYPE_BUG;
}
else if (rfe.getState())
{
return Report.TYPE_RFE;
} else {
return 2345;
}
}
}
---- end ----
If I run the drmbugtool application from java, I get the following excetion:
java.lang.ArrayIndexOutOfBoundsException: 128
at java.awt.GridBagLayout.GetLayoutInfo(GridBagLayout.java:724)
at java.awt.GridBagLayout.ArrangeGrid(GridBagLayout.java:978)
at java.awt.GridBagLayout.layoutContainer(GridBagLayout.java:407)
at java.awt.Container.layout(Container.java:240)
at java.awt.Component.validate(Component.java:526)
at java.awt.Container.validate(Container.java:250)
at java.awt.Container.validate(Container.java:254)
at java.awt.Window.show(Window.java:95)
at ReportCreator.<init>(drmbugtool.java:108)
at StartButton.action(drmbugtool.java:145)
at java.awt.Component.handleEvent(Component.java:900)
at java.awt.Component.postEvent(Component.java:838)
at sun.awt.motif.MButtonPeer.action(MButtonPeer.java:39)
at java.lang.Thread.run(Thread.java)
If I uncomment the line labeled with "COMMENT ME OUT" in
dream/report/ReportPanel.java, then everything works (but the layout
produced by the GridBagLayout is incorrect).
I am surprised that this change should eliminate the exception, since I have
several instances of a similar layout pattern in my code (as a brief examination
will show).
Consider the following classes:
---- begin dream/report/ReportPanel.java ----
package dream.report;
import java.awt.*;
class TextFrame extends Frame
{
TextArea text = new TextArea(80, 10);
public TextFrame(String title)
{
super(title);
resize(750, 300);
add("Center", text);
}
public String getText()
{
return text.getText();
}
public void setText(String text)
{
this.text.setText(text);
}
}
class PopButton extends Button
{
Window window;
public PopButton(String title, Window window)
{
super(title);
this.window = window;
}
public boolean action(Event e, Object o)
{
window.show();
return true;
}
}
public class ReportPanel extends Panel
{
Report report;
CheckboxGroup priority = new CheckboxGroup();
Checkbox priority1 = new Checkbox("1", priority, false);
Checkbox priority2 = new Checkbox("2", priority, false);
Checkbox priority3 = new Checkbox("3", priority, false);
Checkbox priority4 = new Checkbox("4", priority, false);
Checkbox priority5 = new Checkbox("5", priority, false);
CheckboxGroup severity = new CheckboxGroup();
Checkbox severity1 = new Checkbox("1", severity, false);
Checkbox severity2 = new Checkbox("2", severity, false);
Checkbox severity3 = new Checkbox("3", severity, false);
Choice category = new Choice();
Choice subCategory = new Choice();
Choice status = new Choice();
TextField engineer = new TextField(8);
TextField synopsis = new TextField(40);
TextFrame description;
TextFrame workAround;
TextFrame comments;
TextFrame evaluation;
TextField duplicateOf = new TextField(6);
public ReportPanel(Report report, String[] categories, String[] subCategories)
{
String[] statuses = { "not yet investigated",
"can't reproduce yet",
"investigated - cause of problem known",
"too risky to fix",
"fix in progress",
"no resources available now",
"code freeze - can't fix now",
"fixed",
"integrated fix",
"closed" };
GridBagLayout l = new GridBagLayout();
GridBagConstraints c;
String titleFrag = (report.getType() == Report.TYPE_BUG ? "Bug" : "RFE")
+ " no. " + report.getID();
Component tmp;
setLayout(l);
tmp = new Label("Priority:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority1, c);
add(priority1);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority2, c);
add(priority2);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority2, c);
add(priority2);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority3, c);
add(priority3);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority4, c);
add(priority4);
c = new GridBagConstraints();
c.weightx = 8.0;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(priority5, c);
add(priority5);
tmp = new Label("Severity:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
c = new GridBagConstraints();
c.weightx = 13.3;
c.anchor = GridBagConstraints.CENTER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(severity1, c);
add(severity1);
c = new GridBagConstraints();
c.weightx = 13.3;
c.anchor = GridBagConstraints.CENTER;
// c.gridwidth = GridBagConstraints.RELATIVE;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(severity2, c);
add(severity2);
c = new GridBagConstraints();
c.weightx = 13.3;
c.anchor = GridBagConstraints.CENTER;
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(severity3, c);
add(severity3);
tmp = new Label("Category:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
for (int i = 0; i < categories.length; i++)
{
category.addItem(categories[i]);
}
c = new GridBagConstraints();
c.weightx = 40.0;
c.gridwidth = 5;
c.anchor = GridBagConstraints.WEST;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(category, c);
add(category);
tmp = new Label("Subcategory:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.gridwidth = GridBagConstraints.RELATIVE;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
for (int i = 0; i < subCategories.length; i++)
{
subCategory.addItem(subCategories[i]);
}
c = new GridBagConstraints();
c.weightx = 40.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(subCategory, c);
add(subCategory);
tmp = new Label("Status:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
for (int i = 0; i < statuses.length; i++)
{
status.addItem(statuses[i]);
}
c = new GridBagConstraints();
c.weightx = 40.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = 5;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(status, c);
add(status);
tmp = new Label("Responsible engineer:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
// c.gridwidth = GridBagConstraints.RELATIVE; // COMMENT ME OUT
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
c = new GridBagConstraints();
c.weightx = 40.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(engineer, c);
add(engineer);
tmp = new Label("Synopsis:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
c.gridwidth = 1;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
c = new GridBagConstraints();
c.weightx = 90.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(synopsis, c);
add(synopsis);
// description = new TextFrame(titleFrag + " description");
// tmp = new PopButton("Description", description);
// c = new GridBagConstraints();
// c.weightx = 25.0;
// c.anchor = GridBagConstraints.CENTER;
// c.gridwidth = 3;
// c.fill = GridBagConstraints.HORIZONTAL;
// l.setConstraints(tmp, c);
// add(tmp);
// workAround = new TextFrame(titleFrag + " workarounds");
// tmp = new PopButton("Workarounds", workAround);
// c = new GridBagConstraints();
// c.weightx = 25.0;
// c.anchor = GridBagConstraints.CENTER;
// c.gridwidth = 3;
// // c.fill = GridBagConstraints.HORIZONTAL;
// l.setConstraints(tmp, c);
// add(tmp);
// comments = new TextFrame(titleFrag + " comments");
// tmp = new PopButton("Comments", comments);
// c = new GridBagConstraints();
// c.weightx = 25.0;
// c.anchor = GridBagConstraints.CENTER;
// c.gridwidth = 3;
// // c.fill = GridBagConstraints.HORIZONTAL;
// l.setConstraints(tmp, c);
// add(tmp);
// evaluation = new TextFrame(titleFrag + " evaluation");
// tmp = new PopButton("Evaluation", evaluation);
// c = new GridBagConstraints();
// c.weightx = 25.0;
// c.anchor = GridBagConstraints.CENTER;
// c.gridwidth = GridBagConstraints.REMAINDER;
// c.fill = GridBagConstraints.HORIZONTAL;
// l.setConstraints(tmp, c);
// add(tmp);
tmp = new Label("Duplicate of:");
c = new GridBagConstraints();
c.weightx = 10.0;
c.anchor = GridBagConstraints.EAST;
c.gridwidth = 1;
// c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(tmp, c);
add(tmp);
c = new GridBagConstraints();
c.weightx = 90.0;
c.anchor = GridBagConstraints.WEST;
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
l.setConstraints(synopsis, c);
add(duplicateOf);
}
}
---- end ----
---- begin dream/report/Report.java ----
package dream.report;
import dream.report.InvalidReportException;
public class Report
{
/** the ID number of a report */
private int ID = -1;
/** the type of a report - bug or rfe */
private int type = -1;
public static final int TYPE_BUG = 0;
public static final int TYPE_RFE = 1;
/** the category of a bug or rfe */
private String category;
/** the subcategory of a bug or rfe */
private String subCategory;
/** the priority of a report indicates how important we think it is */
private int priority = 0;
public final static int PRI_HIGHEST = 1;
public final static int PRI_LOWEST = 5;
/** the severity of a report indicates its impact on the user */
private int severity = 0;
public final static int SEV_HIGHEST = 1;
public final static int SEV_LOWEST = 3;
/** the status of our dealings with a report */
private int status = -1;
public final static int STAT_MIN = 0;
/** not yet investigated */
public final static int STAT_NYI = 0;
/** can't reproduce yet */
public final static int STAT_CNR = 1;
/** investigated - cause of problem known */
public final static int STAT_CPK = 2;
/** too risky to fix */
public final static int STAT_RSK = 3;
/** fix in progress */
public final static int STAT_FIP = 4;
/** no resources available now */
public final static int STAT_NRA = 5;
/** code freeze - can't fix now */
public final static int STAT_CFN = 6;
/** fixed */
public final static int STAT_FIX = 7;
/** integrated fix */
public final static int STAT_INT = 8;
/** closed */
public final static int STAT_CLO = 9;
public final static int STAT_MAX = 9;
/** the engineer responsible for this report */
private String engineer;
/** the submitter of this report */
private String submitter;
/** a synopsis of this report */
private String synopsis;
/** a detailed description of this report */
private String description;
/** workarounds for this report, if any */
private String workAround;
/** comments pertaining to this report */
private String comments;
/** the cause of the problem or rfe */
private String cause;
/** our evaluation of the report */
private String evaluation;
/** whether the report is a duplicate of another */
private int duplicateOf = -1;
/** email addresses of other interested parties */
private String interestList;
/** key words */
private String keywords;
/** whether we have accepted this report or not */
private boolean accepted;
public Report(int ID, int type, String submitter) throws InvalidReportException
{
this.ID = ID;
if (type != TYPE_BUG && type != TYPE_RFE)
{
throw new InvalidReportException("report is of some weird type " + type);
}
this.type = type;
this.submitter = submitter;
}
public int getID()
{
return ID;
}
public int getType()
{
return type;
}
public String getCategory()
{
return category;
}
public void setCategory(String category)
{
this.category = category;
}
public String getSubCategory()
{
return subCategory;
}
public void setSubCategory(String subCategory)
{
this.subCategory = subCategory;
}
public int getPriority()
{
return priority;
}
public void setPriority(int priority) throws InvalidReportException
{
if (priority < PRI_HIGHEST || priority > PRI_LOWEST)
{
throw new InvalidReportException("invalid report priority " + priority);
}
this.priority = priority;
}
public int getSeverity()
{
return severity;
}
public void setSeverity(int severity) throws InvalidReportException
{
if (severity < SEV_HIGHEST || severity > SEV_LOWEST)
{
throw new InvalidReportException("invalid report severity " + severity);
}
this.severity = severity;
}
public int getStatus()
{
return status;
}
public void setStatus(int status) throws InvalidReportException
{
if (status < STAT_MIN || status > STAT_MAX)
{
throw new InvalidReportException("invalid report status " + status);
}
this.status = status;
}
public String getEngineer()
{
return engineer;
}
public void setEngineer(String engineer)
{
this.engineer = engineer;
}
public String getSubmitter()
{
return submitter;
}
public String getSynopsis()
{
return synopsis;
}
public void setSynopsis(String synopsis)
{
this.synopsis = synopsis;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public String getWorkAround()
{
return workAround;
}
public void setWorkAround(String workAround)
{
this.workAround = workAround;
}
public String getComments()
{
return comments;
}
public void setComments(String comments)
{
this.comments = comments;
}
public String getCause()
{
return cause;