Java Reference
In-Depth Information
To support the new menu item, you need to modify the actionPerformed() method in the
SketchFrame class to handle its events:
public void actionPerformed(ActionEvent e) {
if(e.getSource() == aboutItem) {
// Create about dialog with the menu item as parent
JOptionPane.showMessageDialog(this, // Parent
"Sketcher Copyright Ivor Horton 2000",// Message
"About Sketcher", // Title
JOptionPane.INFORMATION _ MESSAGE); // Message type
} else if(e.getSource() == fontItem) { // Set the dialog window position
Rectangle bounds = getBounds();
fontDlg.setLocation(bounds.x + bounds.width/3, bounds.y + bounds.height/3);
fontDlg.setVisible(true); // Show the dialog
}
}
All the new else : if block does, is make the dialog visible after setting its location in relation to the
application window. If you recompile Sketcher you will be able to play with fonts to your heart's content.
Search WWH ::




Custom Search