< prev index next >
src/demo/share/jfc/FileChooserDemo/FileChooserDemo.java
Print this page
*** 134,144 ****
private JRadioButton singleSelectionRadioButton;
private JRadioButton multiSelectionRadioButton;
private JRadioButton openRadioButton;
private JRadioButton saveRadioButton;
private JRadioButton customButton;
! private JComboBox lafComboBox;
private JRadioButton justFilesRadioButton;
private JRadioButton justDirectoriesRadioButton;
private JRadioButton bothFilesAndDirectoriesRadioButton;
private JTextField customField;
private final ExampleFileView fileView;
--- 134,144 ----
private JRadioButton singleSelectionRadioButton;
private JRadioButton multiSelectionRadioButton;
private JRadioButton openRadioButton;
private JRadioButton saveRadioButton;
private JRadioButton customButton;
! private JComboBox<SupportedLaF> lafComboBox;
private JRadioButton justFilesRadioButton;
private JRadioButton justDirectoriesRadioButton;
private JRadioButton bothFilesAndDirectoriesRadioButton;
private JTextField customField;
private final ExampleFileView fileView;
*** 156,166 ****
UIManager.LookAndFeelInfo[] installedLafs = UIManager.
getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo lafInfo : installedLafs) {
try {
Class<?> lnfClass = Class.forName(lafInfo.getClassName());
! LookAndFeel laf = (LookAndFeel) (lnfClass.newInstance());
if (laf.isSupportedLookAndFeel()) {
String name = lafInfo.getName();
SupportedLaF supportedLaF = new SupportedLaF(name, laf);
supportedLaFs.add(supportedLaF);
if (NIMBUS_LAF_NAME.equals(name)) {
--- 156,166 ----
UIManager.LookAndFeelInfo[] installedLafs = UIManager.
getInstalledLookAndFeels();
for (UIManager.LookAndFeelInfo lafInfo : installedLafs) {
try {
Class<?> lnfClass = Class.forName(lafInfo.getClassName());
! LookAndFeel laf = (LookAndFeel) (lnfClass.getDeclaredConstructor().newInstance());
if (laf.isSupportedLookAndFeel()) {
String name = lafInfo.getName();
SupportedLaF supportedLaF = new SupportedLaF(name, laf);
supportedLaFs.add(supportedLaF);
if (NIMBUS_LAF_NAME.equals(name)) {
*** 290,300 ****
showButton = new JButton("Show FileChooser");
showButton.addActionListener(this);
showButton.setMnemonic('s');
// Create laf combo box
! lafComboBox = new JComboBox(supportedLaFs.toArray());
lafComboBox.setSelectedItem(nimbusLaF);
lafComboBox.setEditable(false);
lafComboBox.addActionListener(optionListener);
// ********************************************************
--- 290,300 ----
showButton = new JButton("Show FileChooser");
showButton.addActionListener(this);
showButton.setMnemonic('s');
// Create laf combo box
! lafComboBox = new JComboBox<>(supportedLaFs.toArray(new SupportedLaF[0]));
lafComboBox.setSelectedItem(nimbusLaF);
lafComboBox.setEditable(false);
lafComboBox.addActionListener(optionListener);
// ********************************************************
*** 727,737 ****
SwingUtilities.updateComponentTreeUI(chooser);
}
frame.pack();
} catch (UnsupportedLookAndFeelException exc) {
// This should not happen because we already checked
! ((DefaultComboBoxModel) lafComboBox.getModel()).
removeElement(supportedLaF);
}
}
}
--- 727,737 ----
SwingUtilities.updateComponentTreeUI(chooser);
}
frame.pack();
} catch (UnsupportedLookAndFeelException exc) {
// This should not happen because we already checked
! ((DefaultComboBoxModel<?>) lafComboBox.getModel()).
removeElement(supportedLaF);
}
}
}
< prev index next >