Package com.mucommander.ui.dialog.pref.component

Examples of com.mucommander.ui.dialog.pref.component.PrefComboBox


        JPanel languagePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        languagePanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.language")));
        this.languages = Translator.getAvailableLanguages();
        String currentLang = MuConfigurations.getPreferences().getVariable(MuPreference.LANGUAGE);
        String lang;
        languageComboBox = new PrefComboBox() {
      public boolean hasChanged() {
        return !languages[getSelectedIndex()].equals(MuConfigurations.getPreferences().getVariable(MuPreference.LANGUAGE));
      }
        };

        // Use a custom combo box renderer to display language icons
        class LanguageComboBoxRenderer extends BasicComboBoxRenderer {

            @Override
            public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
                JLabel label = (JLabel)super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

                String language = (String)value;
                label.setText(Translator.get("language."+language));
                label.setIcon(IconManager.getIcon(IconManager.LANGUAGE_ICON_SET, language+".png"));

                return label;
            }
        }
        languageComboBox.setRenderer(new LanguageComboBoxRenderer());
   
        // Add combo items and select current language (defaults to EN if current language can't be found)
        int languageIndex = -1;
        for(int i=0; i<languages.length; i++) {
            lang = languages[i];
            languageComboBox.addItem(lang);

            if(lang.equalsIgnoreCase(currentLang))
                languageIndex = i;
            else if(languageIndex==-1 && lang.equalsIgnoreCase("en"))
                languageIndex = i;
        }
        languageComboBox.setSelectedIndex(languageIndex);

        languagePanel.add(languageComboBox);
        mainPanel.add(languagePanel);
        mainPanel.addSpace(10);
   
        // Date & time format panel
        YBoxPanel dateTimeFormatPanel = new YBoxPanel();
        dateTimeFormatPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.date_time")));

        JPanel gridPanel = new JPanel(new GridLayout(1, 2));

        YBoxPanel dateFormatPanel = new YBoxPanel();
        dateFormatPanel.setBorder(BorderFactory.createTitledBorder(Translator.get("prefs_dialog.date")));

        // Date format combo
        dateFormatComboBox = new PrefComboBox() {
      public boolean hasChanged() {
        return !getDateFormatString().equals(MuConfigurations.getPreferences().getVariable(MuPreference.DATE_FORMAT));
      }
        };
        String dateFormat = MuConfigurations.getPreferences().getVariable(MuPreference.DATE_FORMAT);
View Full Code Here


        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;               
View Full Code Here

        // 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);
View Full Code Here

     * Creates the system icons panel.
     * @return the system icons panel.
     */
    private JPanel createSystemIconsPanel() {
        /* 'Use system file icons' combo box */
        this.useSystemFileIconsComboBox = new PrefComboBox() {
      public boolean hasChanged() {
        String systemIconsPolicy;
        switch(useSystemFileIconsComboBox.getSelectedIndex()) {
        case 0:
          systemIconsPolicy = FileIcons.USE_SYSTEM_ICONS_NEVER;
View Full Code Here

     * @param confVar the name of the configuration variable that contains the icon scale factor
     * @param defaultValue the default value for the icon scale factor if the configuration variable has no value
     * @return a combo box that allows to choose a size for a certain type of icon
     */
    private PrefComboBox createIconSizeCombo(final MuPreference preference, float defaultValue) {
      PrefComboBox iconSizeCombo = new PrefComboBox() {
      public boolean hasChanged() {
        return !String.valueOf(ICON_SCALE_FACTORS[getSelectedIndex()]).equals(
            MuConfigurations.getPreferences().getVariable(preference));
      }
      };

        for (String iconSize : ICON_SIZES)
            iconSizeCombo.addItem(iconSize);

        float scaleFactor = MuConfigurations.getPreferences().getVariable(preference, defaultValue);
        int index = 0;
        for(int i=0; i<ICON_SCALE_FACTORS.length; i++) {
            if(scaleFactor==ICON_SCALE_FACTORS[i]) {
                index = i;
                break;
            }
        }
        iconSizeCombo.setSelectedIndex(index);

        return iconSizeCombo;
    }
View Full Code Here

TOP

Related Classes of com.mucommander.ui.dialog.pref.component.PrefComboBox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.