org.fife.ui.rsyntaxtextarea.SpellingOptionPanel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rtext Show documentation
Show all versions of rtext Show documentation
RText is a powerful, cross-platform programmer's text editor written in Java. It is designed
to be easy to use, highly customizable and flexible. Part of RText's design is for the source code
to be simple, easy to understand, and well documented, so that other programmers can look into its
inner-workings and figure out how RText ticks with ease. A good place to start (besides the source
code) is the Javadoc for all classes used in the project.
/*
* 10/10/2009
*
* SpellingOptionPanel.java - An option panel for the spelling checker.
* Copyright (C) 2009 Robert Futrell
* http://fifesoft.com/rtext
* Licensed under a modified BSD license.
* See the included license file for details.
*/
package org.fife.ui.rsyntaxtextarea;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.util.ResourceBundle;
import javax.swing.BorderFactory;
import javax.swing.Box;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SpringLayout;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.AbstractDocument;
import org.fife.rtext.NumberDocumentFilter;
import org.fife.rtext.RText;
import org.fife.rtext.RTextPreferences;
import org.fife.rtext.RTextUtilities;
import org.fife.rtext.SpellingSupport;
import org.fife.ui.FSATextField;
import org.fife.ui.OptionsDialogPanel;
import org.fife.ui.RButton;
import org.fife.ui.RColorButton;
import org.fife.ui.RColorSwatchesButton;
import org.fife.ui.SelectableLabel;
import org.fife.ui.SpecialValueComboBox;
import org.fife.ui.UIUtil;
import org.fife.ui.rtextfilechooser.RTextFileChooser;
/**
* Options panel for the spelling checker.
*
* @author Robert Futrell
* @version 1.0
*/
public class SpellingOptionPanel extends OptionsDialogPanel {
private JCheckBox enabledCB;
private JLabel dictLabel;
private SpecialValueComboBox dictCombo;
private JLabel userDictLabel;
private FSATextField userDictField;
private SelectableLabel userDictDescField;
private RButton userDictBrowse;
private RTextFileChooser chooser;
private JLabel colorLabel;
private RColorSwatchesButton spellingColorButton;
private JLabel errorsPerFileLabel;
private JTextField maxErrorsField;
private JCheckBox viewSpellingWindowCB;
private Listener listener;
private ResourceBundle msg;
private static final String[][] DICTIONARIES = {
{ "English (United Kingdom)", SpellingSupport.DICTIONARIES[0] },
{ "English (United States)", SpellingSupport.DICTIONARIES[1] },
};
private static final String MISC_PROPERTY = "Miscellaneous";
public SpellingOptionPanel() {
ComponentOrientation orientation = ComponentOrientation.
getOrientation(getLocale());
listener = new Listener();
msg = ResourceBundle.getBundle(
"org.fife.ui.rsyntaxtextarea.SpellingOptionPanel");
setName(msg.getString("Title"));
setLayout(new BorderLayout());
setBorder(UIUtil.getEmpty5Border());
JPanel contentPane = new JPanel(new BorderLayout());
contentPane.setBorder(new OptionPanelBorder(msg.getString("Spelling")));
add(contentPane);
Box temp = Box.createVerticalBox();
contentPane.add(temp, BorderLayout.NORTH);
enabledCB = new JCheckBox(msg.getString("Enabled"));
enabledCB.setActionCommand("Enabled");
enabledCB.addActionListener(listener);
addLeftAligned(temp, enabledCB);
temp.add(Box.createVerticalStrut(5));
dictLabel = new JLabel(msg.getString("Dictionary"));
dictCombo = new SpecialValueComboBox();
for (int i=0; i