use of games.strategy.triplea.ui.PoliticalStateOverview in project triplea by triplea-game.
the class GameMenu method addPoliticsMenu.
/**
* Add a Politics Panel button to the game menu, this panel will show the
* current political landscape as a reference, no actions on this panel.
*/
private void addPoliticsMenu() {
final JMenuItem politicsMenuItem = add(SwingAction.of("Show Politics Panel", e -> {
final PoliticalStateOverview ui = new PoliticalStateOverview(gameData, uiContext, false);
final JScrollPane scroll = new JScrollPane(ui);
scroll.setBorder(BorderFactory.createEmptyBorder());
final Dimension screenResolution = Toolkit.getDefaultToolkit().getScreenSize();
// not only do we have a start bar, but we also have the message dialog to account for
final int availHeight = screenResolution.height - 120;
// just the scroll bars plus the window sides
final int availWidth = screenResolution.width - 40;
scroll.setPreferredSize(new Dimension((scroll.getPreferredSize().width > availWidth ? availWidth : scroll.getPreferredSize().width), (scroll.getPreferredSize().height > availHeight ? availHeight : scroll.getPreferredSize().height)));
JOptionPane.showMessageDialog(frame, scroll, "Politics Panel", JOptionPane.PLAIN_MESSAGE);
}));
politicsMenuItem.setMnemonic(KeyEvent.VK_P);
politicsMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_W, Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
}
Aggregations