GfxDemo2public class GfxDemo2 extends Frame Fancier, Canvas-based Graphics Demo for Learning Tree Course 471/478
We use a subclass of Canvas to do the drawing; GfxDemo2 merely
creates a Frame and adds the Canvas to it! |
Constructors Summary |
---|
GfxDemo2(String title, int w, int h)
setTitle(title);
// Start of Layout stuff (ignore until AWT GUI chapter!)
GridBagLayout gbl = new GridBagLayout();
setLayout(gbl);
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = gbc.BOTH;
gbc.anchor = gbc.CENTER;
gbc.weightx = gbc.weighty = 1.0;
// Now create a GfxDemoCanvas and add it to the Frame.
GfxDemoCanvas xyz = new GfxDemoCanvas(w, h);
gbl.setConstraints(xyz, gbc);
add(xyz);
// Normal end ... pack it up!
pack();
| GfxDemo2(String title)
this(title, 300, 300);
|
Methods Summary |
---|
public static void | main(java.lang.String[] a)
new GfxDemo2("Default Size").setVisible(true);
new GfxDemo2("Smaller", 100, 100).setVisible(true);
|
|