本文整理匯總了Java中javax.swing.text.NumberFormatter.setCommitsOnValidEdit方法的典型用法代碼示例。如果您正苦於以下問題:Java NumberFormatter.setCommitsOnValidEdit方法的具體用法?Java NumberFormatter.setCommitsOnValidEdit怎麽用?Java NumberFormatter.setCommitsOnValidEdit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.text.NumberFormatter
的用法示例。
在下文中一共展示了NumberFormatter.setCommitsOnValidEdit方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: WettDialog
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
/**
* Creates a new WettDialog and displays the given array of snails.
* @param parent The Form opening this dialog
* @param schneggen The array of snails to display
* @param wettbueroFactor The factor the Wettbuero uses.
*/
public WettDialog(Frame parent, ArrayList<Rennschnecke> schneggen, double wettbueroFactor) {
super(parent, true);
initComponents();
NumberFormat format = NumberFormat.getCurrencyInstance();
format.setMinimumFractionDigits(2);
format.setMaximumFractionDigits(2);
NumberFormatter nf = new NumberFormatter(format);
nf.setMinimum(0.02);
// The maximum bet value is, well, pretty high.
nf.setMaximum(Double.MAX_VALUE / wettbueroFactor);
nf.setAllowsInvalid(false);
nf.setCommitsOnValidEdit(true);
nf.setOverwriteMode(false);
einsatzInput.setFormatterFactory(
new DefaultFormatterFactory(nf)
);
result = null;
snailList.setModel(new DefaultListModel<>());
snailList.setListData(schneggen.toArray(new Rennschnecke[schneggen.size()]));
}
示例2: getImageSizePanel
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
private JPanel getImageSizePanel() {
JPanel imageSizePanel = new JPanel();
imageSizePanel.setLayout(new GridLayout(1, 4));
NumberFormat format = NumberFormat.getInstance();
format.setGroupingUsed(false);
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(0);
formatter.setMaximum(Integer.MAX_VALUE);
formatter.setCommitsOnValidEdit(true);
widthTF = new JFormattedTextField(formatter);
widthTF.setValue(1200);
addFocusListener(widthTF);
heightTF = new JFormattedTextField(formatter);
heightTF.setValue(1000);
addFocusListener(heightTF);
imageSizePanel.add(new JLabel(" Width:"));
imageSizePanel.add(widthTF);
imageSizePanel.add(new JLabel(" Height:"));
imageSizePanel.add(heightTF);
return imageSizePanel;
}
示例3: getImageSizePanel
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
private JPanel getImageSizePanel() {
JPanel imageSizePanel = new JPanel();
imageSizePanel.setLayout(new GridLayout(1, 4));
NumberFormat format = NumberFormat.getInstance();
format.setGroupingUsed(false);
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(0);
formatter.setMaximum(Integer.MAX_VALUE);
formatter.setCommitsOnValidEdit(true);
widthTF = new JFormattedTextField(formatter);
widthTF.setValue(1200);
widthTF.addFocusListener(FOCUS_LISTENER);
heightTF = new JFormattedTextField(formatter);
heightTF.setValue(1000);
heightTF.addFocusListener(FOCUS_LISTENER);
imageSizePanel.add(new JLabel(" Width:"));
imageSizePanel.add(widthTF);
imageSizePanel.add(new JLabel(" Height:"));
imageSizePanel.add(heightTF);
return imageSizePanel;
}
示例4: getIntegerTextField
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
public JFormattedTextField getIntegerTextField(Integer min, Integer max, Integer value) {
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(min);
formatter.setMaximum(max);
formatter.setAllowsInvalid(true);
formatter.setCommitsOnValidEdit(false);
JFormattedTextField field = new JFormattedTextField(formatter);
field.setValue(value);
field.setFont(REGULAR_FONT.deriveFont(scale * 18));
field.setFocusLostBehavior(JFormattedTextField.PERSIST);
field.setForeground(AppThemeColor.TEXT_DEFAULT);
field.setCaretColor(AppThemeColor.TEXT_DEFAULT);
field.setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createLineBorder(AppThemeColor.BORDER, 1),
BorderFactory.createLineBorder(AppThemeColor.TRANSPARENT, 3)
));
field.setBackground(AppThemeColor.HEADER);
return field;
}
示例5: editStackSize
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
public static Dimension editStackSize(Dimension currentSize, Component parent) {
StackSizeEditor dialog = new StackSizeEditor();
dialog.stackDimension = currentSize;
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(0);
formatter.setMaximum(Integer.MAX_VALUE);
formatter.setAllowsInvalid(false);
formatter.setCommitsOnValidEdit(true);
dialog.newHeight.setFormatterFactory(new DefaultFormatterFactory(formatter));
dialog.newWidth.setFormatterFactory(new DefaultFormatterFactory(formatter));
dialog.currentStackSize.setText("Stack is " + currentSize.width + "px by " + currentSize.height + "px");
dialog.newWidth.setText(String.valueOf(currentSize.width));
dialog.newHeight.setText(String.valueOf(currentSize.height));
dialog.pack();
dialog.setLocationRelativeTo(parent);
dialog.setVisible(true);
return dialog.stackDimension;
}
示例6: createUIComponents
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
private void createUIComponents() {
NumberFormat format = NumberFormat.getInstance();
format.setGroupingUsed(false);
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMaximum(65535);
formatter.setAllowsInvalid(false);
formatter.setCommitsOnValidEdit(true);
portTextField = new JFormattedTextField(formatter);
jvmPortTextField = new JFormattedTextField(formatter);
appsMap = new JBTable(new ModulesTableModel());
}
示例7: createUIComponents
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
/**
* Custom initialization code from form
*/
private void createUIComponents() {
NumberFormat numberFormat = NumberFormat.getInstance();
NumberFormatter formatter = new NumberFormatter(numberFormat);
formatter.setValueClass(Integer.class);
formatter.setMaximum(1000);
formatter.setMinimum(1);
formatter.setCommitsOnValidEdit(true);
formatter.setOverwriteMode(true);
pasteToFetch = new JFormattedTextField(formatter);
pasteToFetch.setValue(50);
}
開發者ID:kennedyoliveira,項目名稱:ultimate-pastebin-intellij-plugin,代碼行數:17,代碼來源:PasteBinConfigurationForm.java
示例8: integerNumberFormatter
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
/**
* Provides a convenient integer formatter.
*
* @return a formatter instance.
*/
private static NumberFormatter integerNumberFormatter() {
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(0);
formatter.setMaximum(Integer.MAX_VALUE);
// If you want the value to be committed on each keystroke instead of focus lost
formatter.setCommitsOnValidEdit(true);
return formatter;
}
示例9: configureFormatter
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
private AbstractFormatter configureFormatter() {
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(0);
formatter.setMaximum(Integer.MAX_VALUE);
formatter.setAllowsInvalid(false);
formatter.setCommitsOnValidEdit(true);
return formatter;
}
示例10: getNumberFormatter
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
public static NumberFormatter getNumberFormatter(
NumberFormat nf,
Class<? extends Number> valueClass,
Comparable<? extends Number> min,
Comparable<? extends Number> max) {
NumberFormatter nfm = new NumberFormatter(nf);
nfm.setValueClass(valueClass);
nfm.setCommitsOnValidEdit(true);
nfm.setMinimum(min);
nfm.setMaximum(max);
return nfm;
}
示例11: getInputComponents
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
@Override
protected JPanel getInputComponents() {
UIManager.put("TaskPane.animate", Boolean.FALSE);
if (inputComponents != null)
throw new RuntimeException(
"Can't create input components twice (app bug)");
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(0);
formatter.setMaximum(Integer.MAX_VALUE);
formatter.setCommitsOnValidEdit(true);
JPanel optionsPane = new JPanel();
final GroupLayout groupLayout = new GroupLayout(optionsPane);
groupLayout.setAutoCreateContainerGaps(true);
groupLayout.setAutoCreateGaps(true);
optionsPane.setLayout(groupLayout);
final JLabel lblFileName = new JLabel("File");
JLabel lblFileNameHelp = new JLabel(ICON_HELP);
if (isAcceptDirectoriesOnly()) {
lblFileNameHelp
.setToolTipText("The selected directory to export the images");
} else {
lblFileNameHelp
.setToolTipText("The selected file to export the image");
}
fileName = new JTextField("", 20);
fileName.setEditable(false);
fileName.addMouseListener(getBrowseListener());
JButton browseButton = new JButton(ICON_BROWSE);
browseButton.setToolTipText("Opens a file chooser to select a file");
browseButton.addMouseListener(getBrowseListener());
final JPanel fileChooserPanel = new JPanel(new BorderLayout());
fileChooserPanel.add(fileName, BorderLayout.CENTER);
fileChooserPanel.add(browseButton, BorderLayout.EAST);
final JLabel lblImageSize = new JLabel("Size");
JLabel lblImageSizeHelp = new JLabel(ICON_HELP);
lblImageSizeHelp.setToolTipText("Sets the size in px of the image");
JPanel imageSizePanel = getImageSizePanel();
groupLayout.setHorizontalGroup(
groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup()
.addComponent(lblFileName, Alignment.TRAILING)
.addComponent(lblImageSize, Alignment.TRAILING))
.addGroup(groupLayout.createParallelGroup()
.addComponent(fileChooserPanel)
.addComponent(imageSizePanel))
.addGroup(groupLayout.createParallelGroup()
.addComponent(lblFileNameHelp)
.addComponent(lblImageSizeHelp))
);
groupLayout.setVerticalGroup(
groupLayout.createSequentialGroup()
.addGroup(groupLayout.createParallelGroup()
.addComponent(lblFileName, Alignment.CENTER)
.addComponent(fileChooserPanel, Alignment.CENTER)
.addComponent(lblFileNameHelp, Alignment.CENTER))
.addGroup(groupLayout.createParallelGroup()
.addComponent(lblImageSize, Alignment.CENTER)
.addComponent(imageSizePanel, Alignment.CENTER)
.addComponent(lblImageSizeHelp, Alignment.CENTER))
);
final JPanel toret = new JPanel(new BorderLayout());
toret.add(optionsPane, BorderLayout.NORTH);
return toret;
}
示例12: ClassificationPanel
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
public ClassificationPanel() {
setLayout(null);
btnBrowse = new JButton("Browse...");
panelOptions = new JPanel();
lblClassifier = new JLabel("Classifier:");
checkBoxNaiveBayes = new JCheckBox("Naïve Bayes");
checkBoxJ48 = new JCheckBox("J48");
checkBoxKnn = new JCheckBox("K-nn");
checkBoxEuclideanDist = new JCheckBox("Euclidean Distance");
checkBoxCosSimilarity = new JCheckBox("Cosine Similarity");
lblEvaluationMethod = new JLabel("Evaluation Method:");
radioBtnCrossValidation = new JRadioButton("Cross-validation");
radioBtnPercentageSplit = new JRadioButton("Percentage Split");
radioBtnLOOCV = new JRadioButton("LOOCV");
btnGroupEM = new ButtonGroup();
NumberFormat format = NumberFormat.getNumberInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(0);
formatter.setMaximum(99);
formatter.setCommitsOnValidEdit(true);
txtFolds = new JFormattedTextField(formatter);
lblFolds = new JLabel("folds");
txtSplit = new JFormattedTextField(formatter);
lblSplit = new JLabel("% training set");
btnProcess = new JButton("Process!");
lblReport = new JLabel("Report:");
txtAreaReport = new JTextArea();
paneReport = new JScrollPane(txtAreaReport);
progressBar = new JProgressBar();
btnSave = new JButton("Save to file");
btnChart = new JButton("Generate chart");
createPanel();
}
示例13: createCenterPane
import javax.swing.text.NumberFormatter; //導入方法依賴的package包/類
/**
* Creates the center pane that shows the different options values.
*/
private void createCenterPane() {
JLabel nameLabel = new JLabel("Pictures default name start with");
m_nameText = new JTextField(m_defaultName, 12);
JLabel originalLabel = new JLabel("Use picture registered thumbnail");
m_yesButton = new JRadioButton("Yes", m_originalThumbnail);
m_noButton = new JRadioButton("No", !m_originalThumbnail);
ButtonGroup bg = new ButtonGroup();
bg.add(m_yesButton);
bg.add(m_noButton);
JPanel originalPane = new JPanel(new FlowLayout(FlowLayout.CENTER));
originalPane.add(m_yesButton);
originalPane.add(m_noButton);
JLabel methodLabel = new JLabel("Scaling method to generate thumbnails");
m_methodList = new JList<Method>(Scalr.Method.values());
m_methodList.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
m_methodList.setSelectedValue(m_generateMethod, true);
m_methodList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JLabel sizeLabel = new JLabel("Thumbnails size (in pixels)");
NumberFormat format = NumberFormat.getInstance();
NumberFormatter formatter = new NumberFormatter(format);
formatter.setValueClass(Integer.class);
formatter.setMinimum(m_minThumbnailSize);
formatter.setMaximum(m_maxThumbnailSize);
formatter.setCommitsOnValidEdit(true);
m_sizeText = new JFormattedTextField(formatter);
m_sizeText.setValue(new Integer(m_thumbnailSize));
JPanel centerPane = new JPanel();
centerPane.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.gridwidth = 1;
gbc.insets = new Insets(1,5,1,5);
gbc.weightx = 0.0;
centerPane.add(nameLabel,gbc);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 1.0;
centerPane.add(m_nameText,gbc);
gbc.gridwidth = 1;
gbc.weightx = 0.0;
centerPane.add(originalLabel,gbc);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 1.0;
centerPane.add(originalPane,gbc);
gbc.gridwidth = 1;
gbc.weightx = 0.0;
centerPane.add(methodLabel,gbc);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 1.0;
centerPane.add(m_methodList,gbc);
gbc.gridwidth = 1;
gbc.weightx = 0.0;
centerPane.add(sizeLabel,gbc);
gbc.gridwidth = GridBagConstraints.REMAINDER;
gbc.weightx = 1.0;
centerPane.add(m_sizeText,gbc);
m_contentPane.add(centerPane,BorderLayout.CENTER);
}