addWindowListener(new WindowAdapter() { safeSetIconImages( (List<BufferedImage>) Arrays.asList((BufferedImage[]) source.getIcons()) ); setTitle(MessageFormat.format(resourceBundle.getString("frame.title"), source.getTitle())); displayResCombo = setUpResolutionChooser(); displayResCombo.addKeyListener(aListener); colorDepthCombo = new JComboBox(); this.getContentPane().add(mainPanel); pack();
@Override public void windowClosing(WindowEvent e) { setUserSelection(CANCEL_SELECTION); dispose(); } });
String[] depths = getDepths(resolution, modes); colorDepthCombo.setModel(new DefaultComboBoxModel(depths)); colorDepthCombo.setSelectedItem(colorDepth); String[] freqs = getFrequencies(resolution, modes); displayFreqCombo.setModel(new DefaultComboBoxModel(freqs)); displayFreqCombo.setSelectedItem(getBestFrequency(resolution, modes));
/** * <code>setImage</code> sets the background image of this dialog. * * @param image * <code>URL</code> pointing to the image file. */ public void setImage(URL image) { icon.setIcon(new ImageIcon(image)); pack(); // Resize to accomodate the new image setLocationRelativeTo(null); // put in center }
/** * <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(); } }
addWindowListener(new WindowAdapter() { safeSetIconImages( (List<BufferedImage>) Arrays.asList((BufferedImage[]) source.getIcons()) ); setTitle("Select Display Settings"); displayResCombo = setUpResolutionChooser(); displayResCombo.addKeyListener(aListener); colorDepthCombo = new JComboBox(); updateResolutionChoices(); updateAntialiasChoices(); displayResCombo.setSelectedItem(source.getWidth() + " x " + source.getHeight()); colorDepthCombo.setSelectedItem(source.getBitsPerPixel() + " bpp"); mainPanel.add(buttonPanel, BorderLayout.SOUTH); this.getContentPane().add(mainPanel); pack();
setAlwaysOnTop(true); setResizable(false); createUI();
/** * <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>updateDisplayChoices</code> updates the available color depth and * display frequency options to match the currently selected resolution. */ private void updateDisplayChoices() { if (!fullscreenBox.isSelected()) { // don't run this function when changing windowed settings return; } String resolution = (String) displayResCombo.getSelectedItem(); String colorDepth = (String) colorDepthCombo.getSelectedItem(); if (colorDepth == null) { colorDepth = source.getBitsPerPixel() + " bpp"; } String displayFreq = (String) displayFreqCombo.getSelectedItem(); if (displayFreq == null) { displayFreq = source.getFrequency() + " Hz"; } // grab available depths String[] depths = getDepths(resolution, modes); colorDepthCombo.setModel(new DefaultComboBoxModel(depths)); colorDepthCombo.setSelectedItem(colorDepth); // grab available frequencies String[] freqs = getFrequencies(resolution, modes); displayFreqCombo.setModel(new DefaultComboBoxModel(freqs)); // Try to reset freq displayFreqCombo.setSelectedItem(displayFreq); }
/** * Constructor for the <code>PropertiesDialog</code>. Creates a * properties dialog initialized for the primary display. * * @param source * the <code>AppSettings</code> object to use for working with * the properties file. * @param imageFile * the image file to use as the title of the dialog; * <code>null</code> will result in to image being displayed * @throws NullPointerException * if the source is <code>null</code> */ public SettingsDialog(AppSettings source, String imageFile, boolean loadSettings) { this(source, getURL(imageFile), loadSettings); }
/** * 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); }
private void safeSetIconImages(List<? extends Image> icons) { try { // Due to Java bug 6445278, we try to set icon on our shared owner frame first. // Otherwise, our alt-tab icon will be the Java default under Windows. Window owner = getOwner(); if (owner != null) { Method setIconImages = owner.getClass().getMethod("setIconImages", List.class); setIconImages.invoke(owner, icons); return; } Method setIconImages = getClass().getMethod("setIconImages", List.class); setIconImages.invoke(this, icons); } catch (Exception e) { logger.log(Level.WARNING, "Error setting icon images", e); } }
/** * <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(); } }
/** * <code>setImage</code> sets the background image of this dialog. * * @param image * <code>URL</code> pointing to the image file. */ public void setImage(URL image) { icon.setIcon(new ImageIcon(image)); pack(); // Resize to accomodate the new image setLocationRelativeTo(null); // put in center }
setAlwaysOnTop(true); setResizable(false); createUI();
/** * Constructor for the <code>PropertiesDialog</code>. Creates a * properties dialog initialized for the primary display. * * @param source * the <code>AppSettings</code> object to use for working with * the properties file. * @param imageFile * the image file to use as the title of the dialog; * <code>null</code> will result in to image being displayed * @throws NullPointerException * if the source is <code>null</code> */ public SettingsDialog(AppSettings source, String imageFile, boolean loadSettings) { this(source, getURL(imageFile), loadSettings); }
/** * <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; }
private void safeSetIconImages(List<? extends Image> icons) { try { // Due to Java bug 6445278, we try to set icon on our shared owner frame first. // Otherwise, our alt-tab icon will be the Java default under Windows. Window owner = getOwner(); if (owner != null) { Method setIconImages = owner.getClass().getMethod("setIconImages", List.class); setIconImages.invoke(owner, icons); return; } Method setIconImages = getClass().getMethod("setIconImages", List.class); setIconImages.invoke(this, icons); } catch (Exception e) { logger.log(Level.WARNING, "Error setting icon images", e); } }
addWindowListener(new WindowAdapter() { safeSetIconImages( (List<BufferedImage>) Arrays.asList((BufferedImage[]) source.getIcons()) ); setTitle(MessageFormat.format(resourceBundle.getString("frame.title"), source.getTitle())); displayResCombo = setUpResolutionChooser(); displayResCombo.addKeyListener(aListener); colorDepthCombo = new JComboBox(); this.getContentPane().add(mainPanel); pack();