/[schmitzm]/trunk/src/skrueger/i8n/SwitchLanguageDialog.java
ViewVC logotype

Diff of /trunk/src/skrueger/i8n/SwitchLanguageDialog.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1100 by alfonx, Mon Oct 11 00:07:14 2010 UTC revision 1150 by alfonx, Mon Oct 18 12:28:24 2010 UTC
# Line 35  import java.awt.GridBagLayout; Line 35  import java.awt.GridBagLayout;
35  import java.awt.Insets;  import java.awt.Insets;
36  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
37  import java.awt.event.ActionListener;  import java.awt.event.ActionListener;
38  import java.awt.event.MouseWheelListener;  import java.util.ArrayList;
39  import java.util.List;  import java.util.List;
 import java.util.Locale;  
40    
 import javax.swing.DefaultComboBoxModel;  
41  import javax.swing.ImageIcon;  import javax.swing.ImageIcon;
42  import javax.swing.JButton;  import javax.swing.JButton;
43  import javax.swing.JComboBox;  import javax.swing.JComboBox;
# Line 74  public class SwitchLanguageDialog extend Line 72  public class SwitchLanguageDialog extend
72    
73          private JLabel jLabel = null;          private JLabel jLabel = null;
74    
75          private JComboBox jComboBox = null;          private LanguagesComboBox jComboBox = null;
76    
77          private final List<String> languages;          private final List<String> languages;
78    
# Line 142  public class SwitchLanguageDialog extend Line 140  public class SwitchLanguageDialog extend
140    
141          public boolean close() {          public boolean close() {
142                  // Only close by ESC and window-close if a valid selection is made                  // Only close by ESC and window-close if a valid selection is made
143                  if (jComboBox.getSelectedIndex() == languages.size())                  if (jComboBox.getSelectedIndex() == languages.size()
144                                    || jComboBox.getSelectedIndex() == -1)
145                          return false;                          return false;
146                  else                  else
147                          return super.close();                          return super.close();
# Line 258  public class SwitchLanguageDialog extend Line 257  public class SwitchLanguageDialog extend
257           */           */
258          private JComboBox getJComboBox() {          private JComboBox getJComboBox() {
259                  if (jComboBox == null) {                  if (jComboBox == null) {
260                          jComboBox = new JComboBox();                          ArrayList<String> languagesPlusOne = new ArrayList<String>(
261                                            languages);
262                            languagesPlusOne.add("?");
263    
264                          jComboBox.addMouseWheelListener(new MouseWheelListener() {                          jComboBox = new LanguagesComboBox(languages);
                                 public void mouseWheelMoved(java.awt.event.MouseWheelEvent e) {  
   
                                         if ((e.getWheelRotation() < 0)) {  
                                                 if (jComboBox.getSelectedIndex() < jComboBox  
                                                                 .getItemCount() - 1)  
                                                         jComboBox.setSelectedIndex(jComboBox  
                                                                         .getSelectedIndex() + 1);  
                                         } else {  
                                                 if (jComboBox.getSelectedIndex() > 0)  
                                                         jComboBox.setSelectedIndex(jComboBox  
                                                                         .getSelectedIndex() - 1);  
                                         }  
                                 }  
                         });  
   
                         String[] langNames = new String[languages.size() + 1];  
                         for (int i = 0; i < languages.size(); i++) {  
   
                                 Locale locale = I8NUtil.getFirstLocaleForLang(languages.get(i));  
   
                                 langNames[i] = locale.getDisplayLanguage(locale) + " / "  
                                                 + locale.getDisplayLanguage() + " / "  
                                                 + languages.get(i);  
                         }  
                         langNames[languages.size()] = "?";  
   
                         jComboBox.setModel(new DefaultComboBoxModel(langNames));  
                         jComboBox.setSelectedItem(langNames[languages.size()]);  
265    
266                            SwingUtil.addMouseWheelForCombobox(jComboBox);
267                          jComboBox.addActionListener(new ActionListener() {                          jComboBox.addActionListener(new ActionListener() {
268    
269                                  public void actionPerformed(final ActionEvent e) {                                  public void actionPerformed(final ActionEvent e) {

Legend:
Removed from v.1100  
changed lines
  Added in v.1150

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26