Search in sources :

Example 1 with PoliticalStateOverview

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()));
}
Also used : IntTextField(games.strategy.ui.IntTextField) ClientGame(games.strategy.engine.framework.ClientGame) Insets(java.awt.Insets) JTextField(javax.swing.JTextField) Action(javax.swing.Action) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) TripleAFrame(games.strategy.triplea.ui.TripleAFrame) JMenuItem(javax.swing.JMenuItem) UiContext(games.strategy.triplea.ui.UiContext) ClientSetting(games.strategy.triplea.settings.ClientSetting) BoxLayout(javax.swing.BoxLayout) KeyStroke(javax.swing.KeyStroke) PoliticalStateOverview(games.strategy.triplea.ui.PoliticalStateOverview) RandomStatsDetails(games.strategy.engine.random.RandomStatsDetails) JMenu(javax.swing.JMenu) BorderFactory(javax.swing.BorderFactory) GridBagConstraints(java.awt.GridBagConstraints) KeyEvent(java.awt.event.KeyEvent) JOptionPane(javax.swing.JOptionPane) OddsCalculatorDialog(games.strategy.triplea.oddsCalculator.ta.OddsCalculatorDialog) MenuListener(javax.swing.event.MenuListener) VerifiedRandomNumbersDialog(games.strategy.triplea.ui.VerifiedRandomNumbersDialog) JScrollPane(javax.swing.JScrollPane) IRandomStats(games.strategy.engine.random.IRandomStats) GameData(games.strategy.engine.data.GameData) Dimension(java.awt.Dimension) JLabel(javax.swing.JLabel) IGame(games.strategy.engine.framework.IGame) SoundOptions(games.strategy.sound.SoundOptions) MenuEvent(javax.swing.event.MenuEvent) GridBagLayout(java.awt.GridBagLayout) PropertiesUi(games.strategy.engine.data.properties.PropertiesUi) JPanel(javax.swing.JPanel) Toolkit(java.awt.Toolkit) SwingAction(games.strategy.ui.SwingAction) JScrollPane(javax.swing.JScrollPane) PoliticalStateOverview(games.strategy.triplea.ui.PoliticalStateOverview) Dimension(java.awt.Dimension) JMenuItem(javax.swing.JMenuItem)

Aggregations

GameData (games.strategy.engine.data.GameData)1 PropertiesUi (games.strategy.engine.data.properties.PropertiesUi)1 ClientGame (games.strategy.engine.framework.ClientGame)1 IGame (games.strategy.engine.framework.IGame)1 IRandomStats (games.strategy.engine.random.IRandomStats)1 RandomStatsDetails (games.strategy.engine.random.RandomStatsDetails)1 SoundOptions (games.strategy.sound.SoundOptions)1 OddsCalculatorDialog (games.strategy.triplea.oddsCalculator.ta.OddsCalculatorDialog)1 ClientSetting (games.strategy.triplea.settings.ClientSetting)1 PoliticalStateOverview (games.strategy.triplea.ui.PoliticalStateOverview)1 TripleAFrame (games.strategy.triplea.ui.TripleAFrame)1 UiContext (games.strategy.triplea.ui.UiContext)1 VerifiedRandomNumbersDialog (games.strategy.triplea.ui.VerifiedRandomNumbersDialog)1 IntTextField (games.strategy.ui.IntTextField)1 SwingAction (games.strategy.ui.SwingAction)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 Toolkit (java.awt.Toolkit)1