Methods Summary |
---|
public void | actionPerformed(java.awt.event.ActionEvent e)handles menu actions
Object source = e.getSource();
try {
if (source == quitItem) doQuit();
else if (source == openItem) doOpen();
else if (source == closeItem) doClose();
else if (source == newItem) doNew();
else if (source == copyItem) doCopy();
else if (source == cutItem) doCut();
else if (source == pasteItem) doPaste();
} catch (QTException qte) {
qte.printStackTrace();
}
|
public void | doClose()
setVisible(false);
// dispose();
// quit if no windows now showing
if (--windowCount == 0)
doQuit();
|
public void | doCopy()
Movie copied = controller.copy();
copied.putOnScrap(0);
|
public void | doCut()
Movie cut = controller.cut();
cut.putOnScrap(0);
|
private void | doMyLayout()gets component from controller, makes menus
// add movie component
QTComponent qtc =
QTFactory.makeQTComponent (controller);
comp = qtc.asComponent();
add (comp, BorderLayout.CENTER);
// file menu
fileMenu = new Menu ("File");
newItem = new MenuItem ("New Movie");
newItem.addActionListener (this);
fileMenu.add (newItem);
openItem = new MenuItem ("Open Movie...");
openItem.addActionListener (this);
fileMenu.add (openItem);
closeItem = new MenuItem ("Close");
closeItem.addActionListener (this);
fileMenu.add (closeItem);
fileMenu.addSeparator();
quitItem = new MenuItem ("Quit");
quitItem.addActionListener (this);
fileMenu.add(quitItem);
// edit menu
editMenu = new Menu ("Edit");
copyItem = new MenuItem ("Copy");
copyItem.addActionListener(this);
editMenu.add(copyItem);
cutItem = new MenuItem ("Cut");
cutItem.addActionListener(this);
editMenu.add(cutItem);
pasteItem = new MenuItem ("Paste");
pasteItem.addActionListener(this);
editMenu.add(pasteItem);
// make menu bar
MenuBar bar = new MenuBar();
bar.add (fileMenu);
bar.add (editMenu);
setMenuBar (bar);
// add close-button handling
addWindowListener (new WindowAdapter() {
public void windowClosing (WindowEvent e) {
doClose();
}
public void windowClosed (WindowEvent e) {
dispose();
}
});
|
public void | doNew()
makeNewAndShow();
|
public void | doOpen()
QTFile file =
QTFile.standardGetFilePreview (QTFile.kStandardQTFileTypes);
Frame f = new BasicQTEditor (file);
f.pack();
if (newFrameX >= 0)
f.setLocation (newFrameX+=16, newFrameY+=16);
f.setVisible(true);
windowCount++;
|
public void | doPaste()
controller.paste();
pack();
|
public void | doQuit()
System.exit(0);
|
public java.awt.Dimension | getPreferredSize()Force frame's size to respect movie size
if (controller == null)
return new Dimension (0,0);
try {
QDRect contRect = controller.getBounds();
Dimension compDim = comp.getPreferredSize();
if (contRect.getHeight() > compDim.height) {
return new Dimension (contRect.getWidth() +
getInsets().left +
getInsets().right,
contRect.getHeight() +
getInsets().top +
getInsets().bottom);
} else {
return new Dimension (compDim.width +
getInsets().left +
getInsets().right,
compDim.height +
getInsets().top +
getInsets().bottom);
}
} catch (QTException qte) {
return new Dimension (0,0);
}
|
public static void | main(java.lang.String[] args)opens a single new movie window
try {
Frame f = makeNewAndShow();
// note its x, y for future calls
newFrameX = f.getLocation().x;
newFrameY = f.getLocation().y;
} catch (Exception e) {
e.printStackTrace();
}
|
private static java.awt.Frame | makeNewAndShow()creates "new" movie frame, packs and shows.
used by main() and "new"
Frame f = new BasicQTEditor();
f.pack();
if (newFrameX >= 0)
f.setLocation (newFrameX+=16, newFrameY+=16);
f.setVisible(true);
windowCount++;
return f;
|