use of com.mucommander.ui.dialog.pref.component.PrefComboBox in project mucommander by mucommander.
the class AppearancePanel method createLookAndFeelPanel.
/**
* Creates the look and feel panel.
*
* @return the look and feel panel.
*/
private JPanel createLookAndFeelPanel() {
JPanel lnfPanel;
// Creates the panel.
lnfPanel = new YBoxPanel();
lnfPanel.setAlignmentX(LEFT_ALIGNMENT);
lnfPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.look_and_feel")));
// Creates the look and feel combo box.
lookAndFeelComboBox = new PrefComboBox() {
public boolean hasChanged() {
int selectedIndex = getSelectedIndex();
if (selectedIndex < 0)
return false;
return !lookAndFeels[selectedIndex].getClassName().equals(MuConfigurations.getPreferences().getVariable(MuPreference.LOOK_AND_FEEL));
}
};
lookAndFeelComboBox.setRenderer(new BasicComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label;
label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (index < 0)
return label;
// All look and feels that are not modifiable must be flagged with a lock icon.
if (isLookAndFeelModifiable(lookAndFeels[index]))
label.setIcon(transparentIcon);
else
label.setIcon(lockIcon);
return label;
}
});
// Populates the look and feel combo box.
populateLookAndFeels();
// Initialises buttons and event listening.
importLookAndFeelButton = new JButton(Translator.get("prefs_dialog.import") + "...");
deleteLookAndFeelButton = new JButton(Translator.get("delete"));
importLookAndFeelButton.addActionListener(this);
deleteLookAndFeelButton.addActionListener(this);
resetLookAndFeelButtons();
lookAndFeelComboBox.addActionListener(this);
// Adds the look and feel list and the action buttons to the panel.
JPanel flowPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
flowPanel.add(lookAndFeelComboBox);
flowPanel.add(importLookAndFeelButton);
flowPanel.add(deleteLookAndFeelButton);
flowPanel.add(new JLabel(dial = new SpinningDial()));
lnfPanel.add(flowPanel);
return lnfPanel;
}
use of com.mucommander.ui.dialog.pref.component.PrefComboBox in project mucommander by mucommander.
the class AppearancePanel method createThemesPanel.
/**
* Creates the themes panel.
*
* @return the themes panel.
*/
private JPanel createThemesPanel() {
JPanel gridPanel = new ProportionalGridPanel(4);
// Creates the various panel's buttons.
editThemeButton = new JButton(Translator.get("edit") + "...");
importThemeButton = new JButton(Translator.get("prefs_dialog.import") + "...");
exportThemeButton = new JButton(Translator.get("prefs_dialog.export") + "...");
renameThemeButton = new JButton(Translator.get("rename"));
deleteThemeButton = new JButton(Translator.get("delete"));
duplicateThemeButton = new JButton(Translator.get("duplicate"));
editThemeButton.addActionListener(this);
importThemeButton.addActionListener(this);
exportThemeButton.addActionListener(this);
renameThemeButton.addActionListener(this);
deleteThemeButton.addActionListener(this);
duplicateThemeButton.addActionListener(this);
// Creates the panel's 'type label'.
typeLabel = new JLabel("");
// Creates the theme combo box.
themeComboBox = new PrefComboBox() {
public boolean hasChanged() {
return !ThemeManager.isCurrentTheme((Theme) getSelectedItem());
}
};
themeComboBox.addActionListener(this);
// Sets the combobox's renderer.
lockIcon = IconManager.getIcon(IconManager.PREFERENCES_ICON_SET, "lock.png");
transparentIcon = new ImageIcon(new BufferedImage(lockIcon.getIconWidth(), lockIcon.getIconHeight(), BufferedImage.TYPE_INT_ARGB));
themeComboBox.setRenderer(new BasicComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label;
Theme theme;
label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
theme = (Theme) value;
if (ThemeManager.isCurrentTheme(theme))
label.setText(theme.getName() + " (" + Translator.get("theme.current") + ")");
else
label.setText(theme.getName());
if (theme.getType() != Theme.CUSTOM_THEME)
label.setIcon(lockIcon);
else
label.setIcon(transparentIcon);
return label;
}
});
// Initialises the content of the combo box.
populateThemes(ThemeManager.getCurrentTheme());
gridPanel.add(themeComboBox);
gridPanel.add(editThemeButton);
gridPanel.add(importThemeButton);
gridPanel.add(exportThemeButton);
gridPanel.add(typeLabel);
gridPanel.add(renameThemeButton);
gridPanel.add(deleteThemeButton);
gridPanel.add(duplicateThemeButton);
JPanel flowPanel = new JPanel(new FlowLayout(FlowLayout.LEADING));
flowPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.themes")));
flowPanel.add(gridPanel);
return flowPanel;
}
Aggregations