Ignore:
Timestamp:
2016-11-17T23:12:22+01:00 (3 years ago)
Author:
Don-vip
Message:

improve test coverage

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/FullscreenToggleAction.java

    r9576 r11278  
    4444        putValue("toolbar", "fullscreen");
    4545        Main.toolbar.register(this);
    46         gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
     46        gd = GraphicsEnvironment.isHeadless() ? null : GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice();
    4747        setSelected(Main.pref.getBoolean("draw.fullscreen", false));
    4848        notifySelectedState();
     
    7979        boolean selected = isSelected();
    8080
    81         frame.dispose();
    82         frame.setUndecorated(selected);
     81        if (frame != null) {
     82            frame.dispose();
     83            frame.setUndecorated(selected);
    8384
    84         if (selected) {
    85             prevBounds = frame.getBounds();
    86             frame.setBounds(new Rectangle(GuiHelper.getScreenSize()));
     85            if (selected) {
     86                prevBounds = frame.getBounds();
     87                frame.setBounds(new Rectangle(GuiHelper.getScreenSize()));
     88            }
    8789        }
    8890
     
    9496        // screen by default (it's a simulated mode, but should be ok)
    9597        String exclusive = Main.pref.get("draw.fullscreen.exclusive-mode", "auto");
    96         if ("true".equals(exclusive) || ("auto".equals(exclusive) && !Main.isPlatformWindows())) {
     98        if (("true".equals(exclusive) || ("auto".equals(exclusive) && !Main.isPlatformWindows())) && gd != null) {
    9799            gd.setFullScreenWindow(selected ? frame : null);
    98100        }
    99101
    100         if (!selected && prevBounds != null) {
     102        if (!selected && prevBounds != null && frame != null) {
    101103            frame.setBounds(prevBounds);
    102104        }
    103105
    104106        for (Window wind : visibleWindows) {
    105             wind.setVisible(true);
     107            if (wind != null) {
     108                wind.setVisible(true);
     109            }
    106110        }
    107111
    108112        // Free F10 key to allow it to be used by plugins, even after full screen (see #7502)
    109         frame.getJMenuBar().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0), "none");
     113        if (frame != null) {
     114            frame.getJMenuBar().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_F10, 0), "none");
     115        }
    110116    }
    111117}
Note: See TracChangeset for help on using the changeset viewer.