June 2005
Beginner to intermediate
336 pages
6h 29m
English
You can also draw text with the Graphics2D object's drawText method. When the user selects the Draw menu's Draw Text item, Painter displays a dialog box of the OkCancelDialog class (which you saw earlier in the Slapshot! game):
class OkCancelDialog extends Dialog implements ActionListener { Button ok, cancel; TextField text; public String data; OkCancelDialog(Frame hostFrame, String title, boolean dModal) { super(hostFrame, title, dModal); setSize(280, 100); setLayout(new FlowLayout()); text = new TextField(30); add(text); ok = new Button("OK"); add(ok); ok.addActionListener((ActionListener)this); cancel = new Button("Cancel"); add(cancel); cancel.addActionListener(this); data = new String(""); } public void actionPerformed(ActionEvent ...Read now
Unlock full access