Java Reference
In-Depth Information
while
(iterator.hasNext())
((Resource) iterator.next()).store();
bestStep
#
step;
}
}
// restores the solution corresponding to the best
// performance step
iterator
#
problem.getResources();
while
(iterator.hasNext())
((Resource) iterator.next()).restore();
}
}
The third functionality requires the use definition of two inner classes
that are nested in class
ScheduleSheet
, i.e. class
MouseHandler
and class
MouseMotionHandler
.
MouseHandler
extends class
MouseAdapter
of package
java.awt.event
by
redefining method
mousePressed(MouseEvent e)
and method
mouseReleased
(MouseEvent e)
. These methods are executed when the corresponding input
events are notified and are used to select an activity using the mouse
pointer.
MouseMotionHandler
extends class
MouseMotionAdapter
of package
java.awt.event
by redefining method
mouseMoved(MouseEvent e)
and
mouse
Dragged(MouseEvent e)
. These methods are used to change the temporal
parameters of the selected activity.
public class
ScheduleSheet
extends
JPanel {
ScheduleManager manager
#
null
;
Color colors[]
#
new
Color[7];
Activity selectedActivity
#
null
;
boolean
dueDateSelected
#
false
;
public
ScheduleSheet(ScheduleManager manager) {
colors[0]
#
Color.red;
colors[1]
#
Color.blue;
colors[2]
#
Color.magenta;
colors[3]
#
Color.cyan;
colors[4]
#
Color.green;
colors[5]
#
Color.black;
colors[6]
#
Color.gray;
this
.manager
#
manager;
this
.setBackground(Color.white);
this
.addMouseListener(
new
MouseHandler());
this
.addMouseMotionListener(
new
MouseMotionHandler());
this
.setPreferredSize(
new
Dimension(50, 250));
}
public void
paintComponent(Graphics graphics) {
super
.paintComponent(graphics);