Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!

Gillian Bladen-Clark

+ Follow
since Dec 13, 2003
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Gillian Bladen-Clark

I have an applet that has an inner class that extends JComponent. This inner class has a paint method that draws a number of Stars. The Star class is defined as a separate class that implements Shape in the same package. A Star is made from a GeneralPath. This all works fine. My problem is that I don't know how to fill the Stars that I have drawn. I get a NullPointerException.
Here's the code (empty methods and imports omitted to keep it brief).
public class StarApplet
extends JApplet {
DrawingPane pane = new DrawingPane();
public void init() {
setSize(600, 400);
class DrawingPane
extends JComponent {
public void paint(Graphics g) {
Graphics2D g2D = (Graphics2D) g;
Star star = new Star(0, 0, 10, 15);
float delta = 40f; // increment between stars
float starty = 0f; // staring y position
float startx = 0f;
for (int i = 0; i < 8; i++) {
starty += delta;
startx = 0f;
for (int k = 0; k < 8; k++) {
startx += delta;
g2D.draw(star.atLocation(startx, starty));
g2D.fill( (Shape) star);
And this is my Star class
class Star {
/**start point of general path that forms the star*/
private Float start;
/**path that defines the star*/
private GeneralPath path;
private float sideLength;
private float centreSquareSize;
public Star(float x,float y,float centreSquareSize,float sideLength){ // has to be float as this is what moveTo needs so it saves us some casting overhead
start = new Point2D.Float(x,y);
this.sideLength = sideLength;
this.centreSquareSize = centreSquareSize;
/**Called by the constructor to do all the work in defining the star*/
private void createStar() {
Point2D.Float point = start;
path = new GeneralPath();
path.moveTo(point.x,point.y); //Adds a point to the path by moving to the specified coordinates.
point = goTo(path,point,sideLength,-centreSquareSize);
point = goTo(path,point,centreSquareSize,-sideLength);
point = goTo(path,point,centreSquareSize,sideLength);
point = goTo(path,point,sideLength,centreSquareSize);
point = goTo(path,point,-sideLength,centreSquareSize);
point = goTo(path,point,-centreSquareSize,sideLength);
point = goTo(path,point,-centreSquareSize,-sideLength);
private Point2D.Float goTo(GeneralPath path, Float point, float xFactor, float yFactor) {
path.lineTo(point.x+xFactor,point.y+yFactor); //Adds a point to the path by drawing a straight line from the current coordinates to the new specified coordinates.
point = (Point2D.Float)path.getCurrentPoint();
return point;
public Shape atLocation(float x, float y) {
start.setLocation(x, y);
return path;
public Shape getShape(){
return path;
16 years ago
I have used collaboration cards also known as CRC cards. It's where you (and your team) get some pieces of card and start thinking about the candidate classes in your system and how they will interact with each other. e.g. if you identified that you needed a Personnel Officer class and an Engineer class you would create a card for each. You would then start thinking about the responsibilites of each of these classes. e.g. a Personnel Officer might be responsible for Preparing An Employment Contract for an Engineer. These responsibilities will become methods. When you can see how each class needs to interact with other classes, it gives you stronger ideas about coupling and cohesion and helps you make decisions early on about which classes need to reside in the same package etc. The cards are very useful when planning large systems where many analysts and developers will be involved in the design.
In my humble opinion, integration testing is testing the changed or new application with it's immediate system neighbours e.g. if you had a new barcode scanning device in a warehouse system, then integration testing might be testing it against whatever sends data to it and whatever receives it's data. System testing would be testing the whole chain of events that included the barcode reader e.g. The entire ordering, warehousing and dispatch operations.
16 years ago
I didn't have it installed correctly. I installed it and harmony has been restored. Thanks for your help.
16 years ago
This is probably a silly question but I can't get applets to run in my browser. I have the 1.42 SDK installed (everything that came with JBuilder 9) but on pages that require java, I am prompted to get the plug in from sun. When I start the installation, it's appears that I am downloading the whole SDK again. I think what I need to do is just change a setting in my browser somewhere so that it can find my JRE. I am using IE 6.0.2800.
16 years ago
Thanks for taking the time and trouble to try it out. It's a strange one for sure - I'm using the same SDK so I don't really understand what's causing me the problem.
16 years ago
The StringTokenizer is designed to do all the work of deciding what is a word separator for you - in your case, a comma.
I suggest you read line by line then get the tokens. e.g.

And the code for the file reading class is:

[ January 05, 2004: Message edited by: Gillian Bladen-Clark ]
16 years ago
I am working on a parser that checks for regular expressions in text files. I set up a variety of strings to define what I'm looking for then call a
method that compiles the string into a pattern and tells me whether the current line matches the pattern.
For efficiency, I defined these strings as statics.
This all works fine but when I process a very large file, I find that it
eventually grinds to a halt. m.matches calls java.util.regex.match()
which is recursive so I expect to a few occurrences of match() in the
stack. However, if I watch the call stack, I see that the number of calls
to java.util.regex.match() grows bigger and bigger as the program
progresses for the same value of toFind i.e. the same pattern.
To reproduce this problem, here is a cut-down version.

Just run it against a text file containing say 300 lines of text e.g.

etc etc
Put a breakpoint at this line

in the java.util.regex.pattern class - public static final class GroupHead extends Node
(This is line 3900 in my source dated 1.87 02/07/10).
When the breakpoint is reached, look at the stack then continue.
The stack grows each time this breakpoint is reached.
Any ideas why the stack is growing so big ?
[ January 05, 2004: Message edited by: Gillian Bladen-Clark ]
16 years ago
You could use something like:

You'd have to call this method in a loop going through all the files you want to copy. Perhaps someone else will know if there's a method that will call the operating systems own file copying method directly.
[ January 04, 2004: Message edited by: Gillian Bladen-Clark ]
16 years ago
I found the javax.print.attribute.standard which has an OrientationRequested class described in the API. I haven't used this myself so I can't help further but it looks a likely candidate for what you need.
16 years ago
Multi-dimensional arrays remind me of the old riddle:
As I was going to St. Ives,
I met a man with seven wives.
Each wife had seven sacks,
Each sack had seven cats,
Each cat had seven kits.
Kits, cats, sacks, and wives,
How many were going to St. Ives?
These names of the kittens could be held in an array :
String[7][7][7][7] kittens;
The first dimension is the 7 wives. Each wife has 7 sacks (2nd dimension), each sack has 7 cats (3rd dimension), each cat has 7 kittens (4th dimension). e.g. kittens[1][2][3][4] holds the name of his second wife's third sack's fourth cat's fifth kitten.
16 years ago
Thanks for your help, Ernest. I guess it must be something in the Timer class that is calling start() - I shall dig a bit deeper as you suggested.
I have just started learning about threads so apologies if this is obvious to you. From what I have read, there are two main ways of using threads
a) define a class as a subclass of thread, override the run() method and call start() to start a thread (which invokes the overridden run() method)
b) define a class as implementing the runnable interface, define run().
From the example I saw, when you use method b), a timer was used but there was no call to start(). The thread seems to commence when you construct an object of your class. So where is the run() method being called from ?
[ January 02, 2004: Message edited by: Gillian Bladen-Clark ]
As an example, a CharSequence is a readable sequence of characters. String, StringBuffer and java.nio.CharBuffer all implement the CharSequence interface. So if a method expects a variable of type CharSequence, you can pass it a variable of any of these types - String, StringBuffer or java.nio.CharBuffer.
[ December 19, 2003: Message edited by: Gillian Bladen-Clark ]
[ December 19, 2003: Message edited by: Gillian Bladen-Clark ]
16 years ago
Try this. The output displayed via my toString() method was:
toString() just needs to build a string representation of your object.
The constructor just makes your instance's array variable point to the same array passed in (aTable).
public class Trial {
public static void main(String[] args) {
int[][] table = new int[7][7]; //initialises array
//---------------sets all values in array to -1---------
for (int row = 0; row < table.length; row++) {
for (int col = 0; col < table[row].length; col++) {
table[row][col] = -1;
//--------------input values into array-------------------
table[1][2] = 2;
table[1][6] = 3;
table[2][1] = 2;
table[2][3] = 5;
table[3][2] = 5;
table[3][4] = 9;
table[4][3] = 9;
table[4][5] = 1;
table[5][4] = 1;
table[5][6] = 8;
table[6][1] = 3;
table[6][5] = 8;
Contacts myTable = new Contacts(table);
} //closes public method
} //closes class
public class Contacts
private int [][] newtable = new int [7][7];

public String toString()
{String str = "";
for (int row = 0; row < newtable.length; row++) {
for (int col = 0; col < newtable[row].length; col++) {
str += "\t"+newtable[row][col];
str += "\n";
return str ;
public Contacts(int[][] aTable) {
this.newtable = aTable;
16 years ago