jdk/src/share/demo/jfc/Font2DTest/RangeMenu.java
changeset 2 90ce3da70b43
child 3108 06e84124688c
equal deleted inserted replaced
0:fd16c54261b3 2:90ce3da70b43
       
     1 /*
       
     2  * Copyright 2000-2005 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  *
       
     4  * Redistribution and use in source and binary forms, with or without
       
     5  * modification, are permitted provided that the following conditions
       
     6  * are met:
       
     7  *
       
     8  *   - Redistributions of source code must retain the above copyright
       
     9  *     notice, this list of conditions and the following disclaimer.
       
    10  *
       
    11  *   - Redistributions in binary form must reproduce the above copyright
       
    12  *     notice, this list of conditions and the following disclaimer in the
       
    13  *     documentation and/or other materials provided with the distribution.
       
    14  *
       
    15  *   - Neither the name of Sun Microsystems nor the names of its
       
    16  *     contributors may be used to endorse or promote products derived
       
    17  *     from this software without specific prior written permission.
       
    18  *
       
    19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
       
    20  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
       
    21  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
       
    22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
       
    23  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
       
    24  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
       
    25  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
       
    26  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
       
    27  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
       
    28  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
       
    29  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
       
    30  */
       
    31 
       
    32 /*
       
    33  */
       
    34 
       
    35 import java.awt.BorderLayout;
       
    36 import java.awt.Font;
       
    37 import java.awt.event.ActionEvent;
       
    38 import java.awt.event.ActionListener;
       
    39 import java.awt.event.ItemEvent;
       
    40 import java.awt.event.ItemListener;
       
    41 
       
    42 import javax.swing.*;
       
    43 
       
    44 /**
       
    45  * RangeMenu.java
       
    46  *
       
    47  * @author Shinsuke Fukuda
       
    48  * @author Ankit Patel [Conversion to Swing - 01/07/30]
       
    49  */
       
    50 
       
    51 /// Custom made choice menu that holds data for unicode range
       
    52 
       
    53 public final class RangeMenu extends JComboBox implements ActionListener {
       
    54 
       
    55     /// Painfully extracted from java.lang.Character.UnicodeBlock.  Arrrgh!
       
    56     /// Unicode 3.0 data.
       
    57 
       
    58     private final int[][] UNICODE_RANGES = {
       
    59         { 0x000000, 0x00007f }, /// BASIC_LATIN
       
    60         { 0x000080, 0x0000ff }, /// LATIN_1_SUPPLEMENT
       
    61         { 0x000100, 0x00017f }, /// LATIN_EXTENDED_A
       
    62         { 0x000180, 0x00024f }, /// LATIN_EXTENDED_B
       
    63         { 0x000250, 0x0002af }, /// IPA_EXTENSIONS
       
    64         { 0x0002b0, 0x0002ff }, /// SPACING_MODIFIER_LETTERS
       
    65         { 0x000300, 0x00036f }, /// COMBINING_DIACRITICAL_MARKS
       
    66         { 0x000370, 0x0003ff }, /// GREEK
       
    67         { 0x000400, 0x0004ff }, /// CYRILLIC
       
    68         { 0x000500, 0x00052f }, /// CYRILLIC_SUPPLEMENTARY
       
    69         { 0x000530, 0x00058f }, /// ARMENIAN
       
    70         { 0x000590, 0x0005ff }, /// HEBREW
       
    71         { 0x000600, 0x0006ff }, /// ARABIC
       
    72         { 0x000700, 0x00074f }, /// SYRIAC
       
    73         { 0x000780, 0x0007bf }, /// THAANA
       
    74         { 0x000900, 0x00097f }, /// DEVANAGARI
       
    75         { 0x000980, 0x0009ff }, /// BENGALI
       
    76         { 0x000a00, 0x000a7f }, /// GURMUKHI
       
    77         { 0x000a80, 0x000aff }, /// GUJARATI
       
    78         { 0x000b00, 0x000b7f }, /// ORIYA
       
    79         { 0x000b80, 0x000bff }, /// TAMIL
       
    80         { 0x000c00, 0x000c7f }, /// TELUGU
       
    81         { 0x000c80, 0x000cff }, /// KANNADA
       
    82         { 0x000d00, 0x000d7f }, /// MALAYALAM
       
    83         { 0x000d80, 0x000dff }, /// SINHALA
       
    84         { 0x000e00, 0x000e7f }, /// THAI
       
    85         { 0x000e80, 0x000eff }, /// LAO
       
    86         { 0x000f00, 0x000fff }, /// TIBETAN
       
    87         { 0x001000, 0x00109f }, /// MYANMAR
       
    88         { 0x0010a0, 0x0010ff }, /// GEORGIAN
       
    89         { 0x001100, 0x0011ff }, /// HANGUL_JAMO
       
    90         { 0x001200, 0x00137f }, /// ETHIOPIC
       
    91         { 0x0013a0, 0x0013ff }, /// CHEROKEE
       
    92         { 0x001400, 0x00167f }, /// UNIFIED_CANADIAN_ABORIGINAL_SYLLABICS
       
    93         { 0x001680, 0x00169f }, /// OGHAM
       
    94         { 0x0016a0, 0x0016ff }, /// RUNIC
       
    95         { 0x001700, 0x00171f }, /// TAGALOG
       
    96         { 0x001720, 0x00173f }, /// HANUNOO
       
    97         { 0x001740, 0x00175f }, /// BUHID
       
    98         { 0x001760, 0x00177f }, /// TAGBANWA
       
    99         { 0x001780, 0x0017ff }, /// KHMER
       
   100         { 0x001800, 0x0018af }, /// MONGOLIAN
       
   101         { 0x001900, 0x00194f }, /// LIMBU
       
   102         { 0x001950, 0x00197f }, /// TAI_LE
       
   103         { 0x0019e0, 0x0019ff }, /// KHMER_SYMBOLS
       
   104         { 0x001d00, 0x001d7f }, /// PHONETIC_EXTENSIONS
       
   105         { 0x001e00, 0x001eff }, /// LATIN_EXTENDED_ADDITIONAL
       
   106         { 0x001f00, 0x001fff }, /// GREEK_EXTENDED
       
   107         { 0x002000, 0x00206f }, /// GENERAL_PUNCTUATION
       
   108         { 0x002070, 0x00209f }, /// SUPERSCRIPTS_AND_SUBSCRIPTS
       
   109         { 0x0020a0, 0x0020cf }, /// CURRENCY_SYMBOLS
       
   110         { 0x0020d0, 0x0020ff }, /// COMBINING_MARKS_FOR_SYMBOLS
       
   111         { 0x002100, 0x00214f }, /// LETTERLIKE_SYMBOLS
       
   112         { 0x002150, 0x00218f }, /// NUMBER_FORMS
       
   113         { 0x002190, 0x0021ff }, /// ARROWS
       
   114         { 0x002200, 0x0022ff }, /// MATHEMATICAL_OPERATORS
       
   115         { 0x002300, 0x0023ff }, /// MISCELLANEOUS_TECHNICAL
       
   116         { 0x002400, 0x00243f }, /// CONTROL_PICTURES
       
   117         { 0x002440, 0x00245f }, /// OPTICAL_CHARACTER_RECOGNITION
       
   118         { 0x002460, 0x0024ff }, /// ENCLOSED_ALPHANUMERICS
       
   119         { 0x002500, 0x00257f }, /// BOX_DRAWING
       
   120         { 0x002580, 0x00259f }, /// BLOCK_ELEMENTS
       
   121         { 0x0025a0, 0x0025ff }, /// GEOMETRIC_SHAPES
       
   122         { 0x002600, 0x0026ff }, /// MISCELLANEOUS_SYMBOLS
       
   123         { 0x002700, 0x0027bf }, /// DINGBATS
       
   124         { 0x0027c0, 0x0027ef }, /// MISCELLANEOUS_MATHEMATICAL_SYMBOLS_A
       
   125         { 0x0027f0, 0x0027ff }, /// SUPPLEMENTAL_ARROWS_A
       
   126         { 0x002800, 0x0028ff }, /// BRAILLE_PATTERNS
       
   127         { 0x002900, 0x00297f }, /// SUPPLEMENTAL_ARROWS_B
       
   128         { 0x002980, 0x0029ff }, /// MISCELLANEOUS_MATHEMATICAL_SYMBOLS_B
       
   129         { 0x002a00, 0x002aff }, /// SUPPLEMENTAL_MATHEMATICAL_OPERATORS
       
   130         { 0x002b00, 0x002bff }, /// MISCELLANEOUS_SYMBOLS_AND_ARROWS
       
   131         { 0x002e80, 0x002eff }, /// CJK_RADICALS_SUPPLEMENT
       
   132         { 0x002f00, 0x002fdf }, /// KANGXI_RADICALS
       
   133         { 0x002ff0, 0x002fff }, /// IDEOGRAPHIC_DESCRIPTION_CHARACTERS
       
   134         { 0x003000, 0x00303f }, /// CJK_SYMBOLS_AND_PUNCTUATION
       
   135         { 0x003040, 0x00309f }, /// HIRAGANA
       
   136         { 0x0030a0, 0x0030ff }, /// KATAKANA
       
   137         { 0x003100, 0x00312f }, /// BOPOMOFO
       
   138         { 0x003130, 0x00318f }, /// HANGUL_COMPATIBILITY_JAMO
       
   139         { 0x003190, 0x00319f }, /// KANBUN
       
   140         { 0x0031a0, 0x0031bf }, /// BOPOMOFO_EXTENDED
       
   141         { 0x0031f0, 0x0031ff }, /// KATAKANA_PHONETIC_EXTENSIONS
       
   142         { 0x003200, 0x0032ff }, /// ENCLOSED_CJK_LETTERS_AND_MONTHS
       
   143         { 0x003300, 0x0033ff }, /// CJK_COMPATIBILITY
       
   144         { 0x003400, 0x004dbf }, /// CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A
       
   145         { 0x004dc0, 0x004dff }, /// YIJING_HEXAGRAM_SYMBOLS
       
   146         { 0x004e00, 0x009fff }, /// CJK_UNIFIED_IDEOGRAPHS
       
   147         { 0x00a000, 0x00a48f }, /// YI_SYLLABLES
       
   148         { 0x00a490, 0x00a4cf }, /// YI_RADICALS
       
   149         { 0x00ac00, 0x00d7af }, /// HANGUL_SYLLABLES
       
   150         { 0x00d800, 0x00dfff }, /// SURROGATES_AREA
       
   151         { 0x00e000, 0x00f8ff }, /// PRIVATE_USE_AREA
       
   152         { 0x00f900, 0x00faff }, /// CJK_COMPATIBILITY_IDEOGRAPHS
       
   153         { 0x00fb00, 0x00fb4f }, /// ALPHABETIC_PRESENTATION_FORMS
       
   154         { 0x00fb50, 0x00fdff }, /// ARABIC_PRESENTATION_FORMS_A
       
   155         { 0x00fe00, 0x00fe0f }, /// VARIATION_SELECTORS
       
   156         { 0x00fe20, 0x00fe2f }, /// COMBINING_HALF_MARKS
       
   157         { 0x00fe30, 0x00fe4f }, /// CJK_COMPATIBILITY_FORMS
       
   158         { 0x00fe50, 0x00fe6f }, /// SMALL_FORM_VARIANTS
       
   159         { 0x00fe70, 0x00feff }, /// ARABIC_PRESENTATION_FORMS_B
       
   160         { 0x00ff00, 0x00ffef }, /// HALFWIDTH_AND_FULLWIDTH_FORMS
       
   161         { 0x00fff0, 0x00ffff }, /// SPECIALS
       
   162         { 0x010000, 0x01007f }, /// LINEAR_B_SYLLABARY
       
   163         { 0x010080, 0x0100ff }, /// LINEAR_B_IDEOGRAMS
       
   164         { 0x010100, 0x01013f }, /// AEGEAN_NUMBERS
       
   165         { 0x010300, 0x01032f }, /// OLD_ITALIC
       
   166         { 0x010330, 0x01034f }, /// GOTHIC
       
   167         { 0x010380, 0x01039f }, /// UGARITIC
       
   168         { 0x010400, 0x01044f }, /// DESERET
       
   169         { 0x010450, 0x01047f }, /// SHAVIAN
       
   170         { 0x010480, 0x0104af }, /// OSMANYA
       
   171         { 0x010800, 0x01083f }, /// CYPRIOT_SYLLABARY
       
   172         { 0x01d000, 0x01d0ff }, /// BYZANTINE_MUSICAL_SYMBOLS
       
   173         { 0x01d100, 0x01d1ff }, /// MUSICAL_SYMBOLS
       
   174         { 0x01d300, 0x01d35f }, /// TAI_XUAN_JING_SYMBOLS
       
   175         { 0x01d400, 0x01d7ff }, /// MATHEMATICAL_ALPHANUMERIC_SYMBOLS
       
   176         { 0x020000, 0x02a6df }, /// CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
       
   177         { 0x02f800, 0x02fa1f }, /// CJK_COMPATIBILITY_IDEOGRAPHS_SUPPLEMENT
       
   178         { 0x0e0000, 0x0e007f }, /// TAGS
       
   179         { 0x0e0100, 0x0e01ef }, /// VARIATION_SELECTORS_SUPPLEMENT
       
   180         { 0x0f0000, 0x0fffff }, /// SUPPLEMENTARY_PRIVATE_USE_AREA_A
       
   181         { 0x100000, 0x10ffff }, /// SUPPLEMENTARY_PRIVATE_USE_AREA_B
       
   182         { 0x000000, 0x00007f }, /// OTHER [USER DEFINED RANGE]
       
   183      };
       
   184 
       
   185     private final String[] UNICODE_RANGE_NAMES = {
       
   186         "Basic Latin",
       
   187         "Latin-1 Supplement",
       
   188         "Latin Extended-A",
       
   189         "Latin Extended-B",
       
   190         "IPA Extensions",
       
   191         "Spacing Modifier Letters",
       
   192         "Combining Diacritical Marks",
       
   193         "Greek",
       
   194         "Cyrillic",
       
   195         "Cyrillic Supplement",
       
   196         "Armenian",
       
   197         "Hebrew",
       
   198         "Arabic",
       
   199         "Syriac",
       
   200         "Thaana",
       
   201         "Devanagari",
       
   202         "Bengali",
       
   203         "Gurmukhi",
       
   204         "Gujarati",
       
   205         "Oriya",
       
   206         "Tamil",
       
   207         "Telugu",
       
   208         "Kannada",
       
   209         "Malayalam",
       
   210         "Sinhala",
       
   211         "Thai",
       
   212         "Lao",
       
   213         "Tibetan",
       
   214         "Myanmar",
       
   215         "Georgian",
       
   216         "Hangul Jamo",
       
   217         "Ethiopic",
       
   218         "Cherokee",
       
   219         "Unified Canadian Aboriginal Syllabics",
       
   220         "Ogham",
       
   221         "Runic",
       
   222         "Tagalog",
       
   223         "Hanunoo",
       
   224         "Buhid",
       
   225         "Tagbanwa",
       
   226         "Khmer",
       
   227         "Mongolian",
       
   228         "Limbu",
       
   229         "Tai Le",
       
   230         "Khmer Symbols",
       
   231         "Phonetic Extensions",
       
   232         "Latin Extended Additional",
       
   233         "Greek Extended",
       
   234         "General Punctuation",
       
   235         "Superscripts and Subscripts",
       
   236         "Currency Symbols",
       
   237         "Combining Marks for Symbols",
       
   238         "Letterlike Symbols",
       
   239         "Number Forms",
       
   240         "Arrows",
       
   241         "Mathematical Operators",
       
   242         "Miscellaneous Technical",
       
   243         "Control Pictures",
       
   244         "Optical Character Recognition",
       
   245         "Enclosed Alphanumerics",
       
   246         "Box Drawing",
       
   247         "Block Elements",
       
   248         "Geometric Shapes",
       
   249         "Miscellaneous Symbols",
       
   250         "Dingbats",
       
   251         "Miscellaneous Mathematical Symbols-A",
       
   252         "Supplemental Arrows-A",
       
   253         "Braille Patterns",
       
   254         "Supplemental Arrows-B",
       
   255         "Miscellaneous Mathematical Symbols-B",
       
   256         "Supplemental Mathematical Operators",
       
   257         "Miscellaneous Symbols and Arrows",
       
   258         "CJK Radicals Supplement",
       
   259         "Kangxi Radicals",
       
   260         "Ideographic Description Characters",
       
   261         "CJK Symbols and Punctuation",
       
   262         "Hiragana",
       
   263         "Katakana",
       
   264         "Bopomofo",
       
   265         "Hangul Compatibility Jamo",
       
   266         "Kanbun",
       
   267         "Bopomofo Extended",
       
   268         "Katakana Phonetic Extensions",
       
   269         "Enclosed CJK Letters and Months",
       
   270         "CJK Compatibility",
       
   271         "CJK Unified Ideographs Extension A",
       
   272         "Yijing Hexagram Symbols",
       
   273         "CJK Unified Ideographs",
       
   274         "Yi Syllables",
       
   275         "Yi Radicals",
       
   276         "Hangul Syllables",
       
   277         "Surrogates Area", // High Surrogates, High Private Use Surrogates, Low Surrogates
       
   278         "Private Use Area",
       
   279         "CJK Compatibility Ideographs",
       
   280         "Alphabetic Presentation Forms",
       
   281         "Arabic Presentation Forms-A",
       
   282         "Variation Selectors",
       
   283         "Combining Half Marks",
       
   284         "CJK Compatibility Forms",
       
   285         "Small Form Variants",
       
   286         "Arabic Presentation Forms-B",
       
   287         "Halfwidth and Fullwidth Forms",
       
   288         "Specials",
       
   289         "Linear B Syllabary",
       
   290         "Linear B Ideograms",
       
   291         "Aegean Numbers",
       
   292         "Old Italic",
       
   293         "Gothic",
       
   294         "Ugaritic",
       
   295         "Deseret",
       
   296         "Shavian",
       
   297         "Osmanya",
       
   298         "Cypriot Syllabary",
       
   299         "Byzantine Musical Symbols",
       
   300         "Musical Symbols",
       
   301         "Tai Xuan Jing Symbols",
       
   302         "Mathematical Alphanumeric Symbols",
       
   303         "CJK Unified Ideographs Extension B",
       
   304         "CJK Compatibility Ideographs Supplement",
       
   305         "Tags",
       
   306         "Variation Selectors Supplement",
       
   307         "Supplementary Private Use Area-A",
       
   308         "Supplementary Private Use Area-B",
       
   309         "Custom...",
       
   310     };
       
   311 
       
   312     private boolean useCustomRange = false;
       
   313     private int[] customRange = { 0x0000, 0x007f };
       
   314 
       
   315     /// Custom range dialog variables
       
   316     private final JDialog customRangeDialog;
       
   317     private final JTextField customRangeStart = new JTextField( "0000", 4 );
       
   318     private final JTextField customRangeEnd   = new JTextField( "007F", 4 );
       
   319     private final int CUSTOM_RANGE_INDEX = UNICODE_RANGE_NAMES.length - 1;
       
   320 
       
   321     /// Parent Font2DTest Object holder
       
   322     private final Font2DTest parent;
       
   323 
       
   324     public static final int SURROGATES_AREA_INDEX = 91;
       
   325 
       
   326     public RangeMenu( Font2DTest demo, JFrame f ) {
       
   327         super();
       
   328         parent = demo;
       
   329 
       
   330         for ( int i = 0; i < UNICODE_RANGE_NAMES.length; i++ )
       
   331           addItem( UNICODE_RANGE_NAMES[i] );
       
   332 
       
   333         setSelectedIndex( 0 );
       
   334         addActionListener( this );
       
   335 
       
   336         /// Set up custom range dialog...
       
   337         customRangeDialog = new JDialog( f, "Custom Unicode Range", true );
       
   338         customRangeDialog.setResizable( false );
       
   339 
       
   340         JPanel dialogTop = new JPanel();
       
   341         JPanel dialogBottom = new JPanel();
       
   342         JButton okButton = new JButton("OK");
       
   343         JLabel from = new JLabel( "From:" );
       
   344         JLabel to = new JLabel("To:");
       
   345         Font labelFont = new Font( "dialog", Font.BOLD, 12 );
       
   346         from.setFont( labelFont );
       
   347         to.setFont( labelFont );
       
   348         okButton.setFont( labelFont );
       
   349 
       
   350         dialogTop.add( from );
       
   351         dialogTop.add( customRangeStart );
       
   352         dialogTop.add( to );
       
   353         dialogTop.add( customRangeEnd );
       
   354         dialogBottom.add( okButton );
       
   355         okButton.addActionListener( this );
       
   356 
       
   357         customRangeDialog.getContentPane().setLayout( new BorderLayout() );
       
   358         customRangeDialog.getContentPane().add( "North", dialogTop );
       
   359         customRangeDialog.getContentPane().add( "South", dialogBottom );
       
   360         customRangeDialog.pack();
       
   361     }
       
   362 
       
   363     /// Return the range that is currently selected
       
   364 
       
   365     public int[] getSelectedRange() {
       
   366         if ( useCustomRange ) {
       
   367             int startIndex, endIndex;
       
   368             String startText, endText;
       
   369             String empty = "";
       
   370             try {
       
   371                 startText = customRangeStart.getText().trim();
       
   372                 endText = customRangeEnd.getText().trim();
       
   373                 if ( startText.equals(empty) && !endText.equals(empty) ) {
       
   374                     endIndex = Integer.parseInt( endText, 16 );
       
   375                     startIndex = endIndex - 7*25;
       
   376                 }
       
   377                 else if ( !startText.equals(empty) && endText.equals(empty) ) {
       
   378                     startIndex = Integer.parseInt( startText, 16 );
       
   379                     endIndex = startIndex + 7*25;
       
   380                 }
       
   381                 else {
       
   382                     startIndex = Integer.parseInt( customRangeStart.getText(), 16 );
       
   383                     endIndex = Integer.parseInt( customRangeEnd.getText(), 16 );
       
   384                 }
       
   385             }
       
   386             catch ( Exception e ) {
       
   387                 /// Error in parsing the hex number ---
       
   388                 /// Reset the range to what it was before and return that
       
   389                 customRangeStart.setText( Integer.toString( customRange[0], 16 ));
       
   390                 customRangeEnd.setText( Integer.toString( customRange[1], 16 ));
       
   391                 return customRange;
       
   392             }
       
   393 
       
   394             if ( startIndex < 0 )
       
   395               startIndex = 0;
       
   396             if ( endIndex > 0xffff )
       
   397               endIndex = 0xffff;
       
   398             if ( startIndex > endIndex )
       
   399               startIndex = endIndex;
       
   400 
       
   401             customRange[0] = startIndex;
       
   402             customRange[1] = endIndex;
       
   403             return customRange;
       
   404         }
       
   405         else
       
   406           return UNICODE_RANGES[ getSelectedIndex() ];
       
   407     }
       
   408 
       
   409     /// Function used by loadOptions in Font2DTest main panel
       
   410     /// to reset setting and range selection
       
   411     public void setSelectedRange( String name, int start, int end ) {
       
   412         setSelectedItem( name );
       
   413         customRange[0] = start;
       
   414         customRange[1] = end;
       
   415         parent.fireRangeChanged();
       
   416     }
       
   417 
       
   418     /// ActionListener interface function
       
   419     /// ABP
       
   420     /// moved JComboBox event code into this fcn from
       
   421     /// itemStateChanged() method. Part of change to Swing.
       
   422     public void actionPerformed( ActionEvent e ) {
       
   423         Object source = e.getSource();
       
   424 
       
   425         if ( source instanceof JComboBox ) {
       
   426                 String rangeName = (String)((JComboBox)source).getSelectedItem();
       
   427 
       
   428                 if ( rangeName.equals("Custom...") ) {
       
   429                     useCustomRange = true;
       
   430                     customRangeDialog.setLocationRelativeTo(parent);
       
   431                     customRangeDialog.show();
       
   432                 }
       
   433                 else {
       
   434                   useCustomRange = false;
       
   435                 }
       
   436                 parent.fireRangeChanged();
       
   437         }
       
   438         else if ( source instanceof JButton ) {
       
   439                 /// Since it is only "OK" button that sends any action here...
       
   440                 customRangeDialog.hide();
       
   441         }
       
   442     }
       
   443 }