/** * <code>updateResolutionChoices</code> updates the available resolutions * list to match the currently selected window mode (fullscreen or * windowed). It then sets up a list of standard options (if windowed) or * calls <code>updateDisplayChoices</code> (if fullscreen). */ private void updateResolutionChoices() { if (!fullscreenBox.isSelected()) { displayResCombo.setModel(new DefaultComboBoxModel( getWindowedResolutions(windowModes))); if (displayResCombo.getItemCount() > 0) { displayResCombo.setSelectedIndex(displayResCombo.getItemCount()-1); } colorDepthCombo.setModel(new DefaultComboBoxModel(new String[]{ "24 bpp", "16 bpp"})); displayFreqCombo.setModel(new DefaultComboBoxModel( new String[]{resourceBundle.getString("refresh.na")})); displayFreqCombo.setEnabled(false); } else { displayResCombo.setModel(new DefaultComboBoxModel( getResolutions(modes, Integer.MAX_VALUE, Integer.MAX_VALUE))); if (displayResCombo.getItemCount() > 0) { displayResCombo.setSelectedIndex(displayResCombo.getItemCount()-1); } displayFreqCombo.setEnabled(true); updateDisplayChoices(); } }
/** * Returns every unique resolution from an array of <code>DisplayMode</code>s * where the resolution is greater than the configured minimums and the height * is less than the current screen resolution. */ private String[] getWindowedResolutions(DisplayMode[] modes) { int maxHeight = 0; int maxWidth = 0; for (int i = 0; i < modes.length; i++) { if (maxHeight < modes[i].getHeight()) { maxHeight = modes[i].getHeight(); } if (maxWidth < modes[i].getWidth()) { maxWidth = modes[i].getWidth(); } } return getResolutions(modes, maxHeight, maxWidth); }
/** * <code>updateResolutionChoices</code> updates the available resolutions * list to match the currently selected window mode (fullscreen or * windowed). It then sets up a list of standard options (if windowed) or * calls <code>updateDisplayChoices</code> (if fullscreen). */ private void updateResolutionChoices() { if (!fullscreenBox.isSelected()) { displayResCombo.setModel(new DefaultComboBoxModel( windowedResolutions)); colorDepthCombo.setModel(new DefaultComboBoxModel(new String[]{ "24 bpp", "16 bpp"})); displayFreqCombo.setModel(new DefaultComboBoxModel( new String[]{"n/a"})); displayFreqCombo.setEnabled(false); } else { displayResCombo.setModel(new DefaultComboBoxModel( getResolutions(modes))); displayFreqCombo.setEnabled(true); updateDisplayChoices(); } }
/** * <code>setUpChooser</code> retrieves all available display modes and * places them in a <code>JComboBox</code>. The resolution specified by * GameSettings is used as the default value. * * @return the combo box of display modes. */ private JComboBox setUpResolutionChooser() { String[] res = getResolutions(modes); JComboBox resolutionBox = new JComboBox(res); resolutionBox.setSelectedItem(source.getWidth() + " x " + source.getHeight()); resolutionBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateDisplayChoices(); } }); return resolutionBox; }
/** * <code>updateResolutionChoices</code> updates the available resolutions * list to match the currently selected window mode (fullscreen or * windowed). It then sets up a list of standard options (if windowed) or * calls <code>updateDisplayChoices</code> (if fullscreen). */ private void updateResolutionChoices() { if (!fullscreenBox.isSelected()) { displayResCombo.setModel(new DefaultComboBoxModel( getWindowedResolutions(windowModes))); if (displayResCombo.getItemCount() > 0) { displayResCombo.setSelectedIndex(displayResCombo.getItemCount()-1); } colorDepthCombo.setModel(new DefaultComboBoxModel(new String[]{ "24 bpp", "16 bpp"})); displayFreqCombo.setModel(new DefaultComboBoxModel( new String[]{resourceBundle.getString("refresh.na")})); displayFreqCombo.setEnabled(false); } else { displayResCombo.setModel(new DefaultComboBoxModel( getResolutions(modes, Integer.MAX_VALUE, Integer.MAX_VALUE))); if (displayResCombo.getItemCount() > 0) { displayResCombo.setSelectedIndex(displayResCombo.getItemCount()-1); } displayFreqCombo.setEnabled(true); updateDisplayChoices(); } }
/** * Returns every unique resolution from an array of <code>DisplayMode</code>s * where the resolution is greater than the configured minimums and the height * is less than the current screen resolution. */ private String[] getWindowedResolutions(DisplayMode[] modes) { int maxHeight = 0; int maxWidth = 0; for (int i = 0; i < modes.length; i++) { if (maxHeight < modes[i].getHeight()) { maxHeight = modes[i].getHeight(); } if (maxWidth < modes[i].getWidth()) { maxWidth = modes[i].getWidth(); } } return getResolutions(modes, maxHeight, maxWidth); }