![]() |
CSE 142 Spring 2002TEST uwcse.jar for HW7 |
uwcse.jar
file available here adds some features not in the standard
GWindow
class. In particular, you can set the background color
of the GWindow and you can move it on the screen (so that it doesn't have to be in
the upper left corner, unless moved by the user).
THIS CODE IS NOT THOROUGHLY TESTED. The changes are small(ish), but unfortunately they required changing some code that the normal GWindow depends upon. So, there is a chance that something will go wrong. (I know for sure that when a window is created, it comes up in the upper left hand corner and then moves - that was a "design decision" dictated by the goal of having a flexible interface, the time of day, and today's weather.)
GWindow
, create a HW7GWindow
.
A HW7GWindow
IS a GWindow
, so you can use any of the
methods you normally use. But, it has two additional calls, one to set the
background color and one to move it on the screen.
Here is the code for HW7GWindow
, which also constitutes the full
set of available documentation on it:
package uwcse.graphics;
import java.awt.*;
public class HW7GWindow extends GWindow {
// constructors, so you can create a HW7GWindow exactly as you would a GWindow
public HW7GWindow() {
super();
}
public HW7GWindow(String name) {
super(name);
}
public HW7GWindow(int width, int height) {
super( width, height );
}
public HW7GWindow(String name, int width, int height) {
super( name, width, height );
}
public HW7GWindow(AppletGWindow appletGWindow) {
super ( appletGWindow );
}
// here are the new routines
public void setBGColor( java.awt.Color newColor ) {
((FrameGWindow)theWindow).setBackground( newColor );
}
public void setScreenPosition( int x, int y ) {
((FrameGWindow)theWindow).setLocation( x, y );
}
}
Okay, one little bit more documentation: all you care about is what parameters
the setBGColor()
and setScreenPosition()
methods take.
You don't care how they do what they do, for instance, nor about anything else
in that code.
uwcse.jar
file you're using for HW7 to
uwcse.jar-original
. If you have things set up according to
"the default installation" the file will be in C:\cse\lib
.
Wherever it is for you, rename it.
uwcse.jar
(below) and place it in the
same directory as the renamed old version.
uwcse.jar
and rename the renamed one back to its original name.
HW7GWindow
:
Fetch those files, compile them, and java DummyClass
.
Here's what it looks like: