/**
* Creates a new menubar to be shown in this window.
* @return the newly created menubar
*/
private JMenuBar setupMenu() {
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu(translator.getString("Menu.File"));
menu.setMnemonic(KeyEvent.VK_F);
//Adds mostly the same actions, but without icons
menu.add(new Command(translator.getString("Menu.Print"), KeyEvent.VK_P) {
public void doit() {
startPrinterJob(true);
}
});
// inputHandler must be set to allow reloading
if (renderable != null) {
menu.add(new Command(translator.getString("Menu.Reload"), KeyEvent.VK_R) {
public void doit() {
reload();
}
});
}
menu.addSeparator();
menu.add(new Command(translator.getString("Menu.Exit"), KeyEvent.VK_X) {
public void doit() {
dispose();
}
});
menuBar.add(menu);
menu = new JMenu(translator.getString("Menu.View"));
menu.setMnemonic(KeyEvent.VK_V);
menu.add(new Command(translator.getString("Menu.First.page"), KeyEvent.VK_F) {
public void doit() {
goToFirstPage();
}
});
menu.add(new Command(translator.getString("Menu.Prev.page"), KeyEvent.VK_P) {
public void doit() {
goToPreviousPage();
}
});
menu.add(new Command(translator.getString("Menu.Next.page"), KeyEvent.VK_N) {
public void doit() {
goToNextPage();
}
});
menu.add(new Command(translator.getString("Menu.Last.page"), KeyEvent.VK_L) {
public void doit() {
goToLastPage();
}
});
menu.add(new Command(translator.getString("Menu.Go.to.Page"), KeyEvent.VK_G) {
public void doit() {
showGoToPageDialog();
}
});
menu.addSeparator();
JMenu subMenu = new JMenu(translator.getString("Menu.Zoom"));
subMenu.setMnemonic(KeyEvent.VK_Z);
subMenu.add(new Command("25%", 0) {
public void doit() {
setScale(25.0);
}
});
subMenu.add(new Command("50%", 0) {
public void doit() {
setScale(50.0);
}
});
subMenu.add(new Command("75%", 0) {
public void doit() {
setScale(75.0);
}
});
subMenu.add(new Command("100%", 0) {
public void doit() {
setScale(100.0);
}
});
subMenu.add(new Command("150%", 0) {
public void doit() {
setScale(150.0);
}
});
subMenu.add(new Command("200%", 0) {
public void doit() {
setScale(200.0);
}
});
menu.add(subMenu);
menu.addSeparator();
menu.add(new Command(translator.getString("Menu.Default.zoom"), KeyEvent.VK_D) {
public void doit() {
setScale(100.0);
}
});
menu.add(new Command(translator.getString("Menu.Fit.Window"), KeyEvent.VK_F) {
public void doit() {
setScaleToFitWindow();
}
});
menu.add(new Command(translator.getString("Menu.Fit.Width"), KeyEvent.VK_W) {
public void doit() {
setScaleToFitWidth();
}
});
menu.addSeparator();
ButtonGroup group = new ButtonGroup();
JRadioButtonMenuItem single = new JRadioButtonMenuItem(
new Command(translator.getString("Menu.Single"), KeyEvent.VK_S) {
public void doit() {
previewPanel.setDisplayMode(PreviewPanel.SINGLE);
}
});
JRadioButtonMenuItem cont = new JRadioButtonMenuItem(
new Command(translator.getString("Menu.Continuous"), KeyEvent.VK_C) {
public void doit() {
previewPanel.setDisplayMode(PreviewPanel.CONTINUOUS);
}
});
JRadioButtonMenuItem facing = new JRadioButtonMenuItem(
new Command(translator.getString("Menu.Facing"), 0) {
public void doit() {
previewPanel.setDisplayMode(PreviewPanel.CONT_FACING);
}
});
single.setSelected(true);
group.add(single);
group.add(cont);
group.add(facing);
menu.add(single);
menu.add(cont);
menu.add(facing);
menuBar.add(menu);
menu = new JMenu(translator.getString("Menu.Help"));
menu.setMnemonic(KeyEvent.VK_H);
menu.add(new Command(translator.getString("Menu.About"), KeyEvent.VK_A) {
public void doit() {
startHelpAbout();
}
});
menuBar.add(menu);
return menuBar;
}