Java Code Examples for javax.swing.text.NumberFormatter#setMaximum()

The following examples show how to use javax.swing.text.NumberFormatter#setMaximum() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: IntegerField.java    From uima-uimaj with Apache License 2.0 5 votes vote down vote up
/**
 * Instantiates a new integer field.
 *
 * @param min the min
 * @param max the max
 * @param initialValue the initial value
 */
public IntegerField(int min, int max, int initialValue) {
  super();

  NumberFormatter formatter = new NumberFormatter(numberFormat);
  formatter.setMinimum(min);
  formatter.setMaximum(max);
  formatter.setCommitsOnValidEdit(true);
  setFormatter(formatter);

  setValue(initialValue);
}
 
Example 2
Source File: GrammarvizGuesserPane.java    From grammarviz2_src with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: TileQuantityPanel.java    From Carcassonne with Eclipse Public License 2.0 5 votes vote down vote up
private void createTextField(int initialQuantity) {
    NumberFormatter formatter = new NumberFormatter(NumberFormat.getIntegerInstance());
    formatter.setMinimum(0);
    formatter.setMaximum(99);
    formatter.setAllowsInvalid(false);
    formatter.setCommitsOnValidEdit(true);
    textField = new JFormattedTextField(formatter);
    setQuantity(initialQuantity);
    add(textField, BorderLayout.SOUTH);
}
 
Example 4
Source File: GridSizeDialog.java    From Carcassonne with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates a number formatter that enforces the valid minimum and maximum values for the text fields.
 */
private NumberFormatter createNumberFormatter() {
    NumberFormatter formatter = new NumberFormatter(NumberFormat.getInstance());
    formatter.setValueClass(Integer.class);
    formatter.setMinimum(MIN_VALUE);
    formatter.setMaximum(MAX_VALUE);
    return formatter;
}
 
Example 5
Source File: MuleRemoteDebuggerConfPanel.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
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());

}
 
Example 6
Source File: ClassDialogue.java    From JByteMod-Beta with GNU General Public License v2.0 5 votes vote down vote up
@SuppressWarnings("rawtypes")
public static JFormattedTextField createNumberField(Class<?> type, Object minValue, Object maxValue) {
  NumberFormat format = NumberFormat.getInstance();
  format.setGroupingUsed(false);
  format.setMaximumFractionDigits(10);
  NumberFormatter formatter = new NumberFormatter(format);
  formatter.setValueClass(type);
  formatter.setMinimum((Comparable) minValue);
  formatter.setMaximum((Comparable) maxValue);
  formatter.setAllowsInvalid(false);
  formatter.setCommitsOnValidEdit(true);
  formatter.setOverwriteMode(true);
  JFormattedTextField jftf = new JFormattedTextField(formatter);
  return jftf;
}
 
Example 7
Source File: PreferencesDialog.java    From yawl with GNU Lesser General Public License v3.0 5 votes vote down vote up
private NumberFormatter getPortValueFormatter() {
    NumberFormat plainIntegerFormat = NumberFormat.getInstance();
    plainIntegerFormat.setGroupingUsed(false);                      // no commas

    NumberFormatter portFormatter = new NumberFormatter(plainIntegerFormat);
    portFormatter.setValueClass(Integer.class);
    portFormatter.setAllowsInvalid(false);
    portFormatter.setMinimum(0);
    portFormatter.setMaximum(65535);
    return portFormatter;
}
 
Example 8
Source File: ConversionPanel.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
/** Updates the text field when the main data model is updated. */
public void stateChanged(ChangeEvent e) {
    int min = sliderModel.getMinimum();
    int max = sliderModel.getMaximum();
    double value = sliderModel.getDoubleValue();
    NumberFormatter formatter = (NumberFormatter) textField.getFormatter();

    formatter.setMinimum(new Double(min));
    formatter.setMaximum(new Double(max));
    textField.setValue(new Double(value));
}
 
Example 9
Source File: AdvancedSecurityPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public AdvancedSecurityPanel(Binding binding, ConfigVersion cfgVersion) {
    this.binding = binding;
    this.cfgVersion = cfgVersion;
    
    freshnessff = new DefaultFormatterFactory();
    NumberFormat freshnessFormat = NumberFormat.getIntegerInstance();
    freshnessFormat.setGroupingUsed(false);
    NumberFormatter freshnessFormatter = new NumberFormatter(freshnessFormat);
    freshnessFormat.setMaximumIntegerDigits(8);
    freshnessFormatter.setCommitsOnValidEdit(true);
    freshnessFormatter.setMinimum(0);
    freshnessFormatter.setMaximum(99999999);
    freshnessff.setDefaultFormatter(freshnessFormatter);
            
    skewff = new DefaultFormatterFactory();
    NumberFormat skewFormat = NumberFormat.getIntegerInstance();
    skewFormat.setGroupingUsed(false);
    NumberFormatter skewFormatter = new NumberFormatter(skewFormat);
    skewFormat.setMaximumIntegerDigits(8);
    skewFormatter.setCommitsOnValidEdit(true);
    skewFormatter.setMinimum(0);
    skewFormatter.setMaximum(99999999);
    skewff.setDefaultFormatter(skewFormatter);

    initComponents();
    
    sync();
}
 
Example 10
Source File: AdvancedRMPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public AdvancedRMPanel(Binding binding, ConfigVersion cfgVersion) {
    super();
    this.binding = binding;
    this.cfgVersion = cfgVersion;

    milisecondsff = new DefaultFormatterFactory();
    NumberFormat millisecondsFormat = NumberFormat.getIntegerInstance();        
    millisecondsFormat.setGroupingUsed(false);
    NumberFormatter millisecondsFormatter = new NumberFormatter(millisecondsFormat);
    millisecondsFormat.setMaximumIntegerDigits(8);
    millisecondsFormatter.setCommitsOnValidEdit(true);
    millisecondsFormatter.setMinimum(0);
    millisecondsFormatter.setMaximum(99999999);
    milisecondsff.setDefaultFormatter(millisecondsFormatter);

    maxBufff = new DefaultFormatterFactory();
    NumberFormat maxBufFormat = NumberFormat.getIntegerInstance();
    maxBufFormat.setGroupingUsed(false);
    NumberFormatter maxBufFormatter = new NumberFormatter(maxBufFormat);
    maxBufFormat.setMaximumIntegerDigits(8);
    maxBufFormatter.setCommitsOnValidEdit(true);
    maxBufFormatter.setMinimum(0);
    maxBufFormatter.setMaximum(99999999);
    maxBufff.setDefaultFormatter(maxBufFormatter);

    initComponents();

    inSync = true;
    for (RMDeliveryAssurance assurance : RMDeliveryAssurance.values()) {
        deliveryAssuranceCombo.addItem(assurance);
    }
    inSync = false;
    
    sync();
    refresh();
}
 
Example 11
Source File: DomBotEditor.java    From DominionSim with MIT License 4 votes vote down vote up
private JPanel getBoardPanel() {
        final JPanel thePanel = new JPanel();
        thePanel.setLayout( new GridBagLayout() );
//        thePanel.setBorder( new TitledBorder( "" ));
        final GridBagConstraints theCons = DomGui.getGridBagConstraints( 2 );
        //board cards
        thePanel.add(new JLabel("Board"),theCons);
        myBoardField = new JTextField(myChosenStrategy.getBoardString(), TEXT_FIELD_WIDTH);
        theCons.gridx++;
        thePanel.add(myBoardField,theCons);
        //bane card
        theCons.gridx=0;
        theCons.gridy++;
        theCons.fill=GridBagConstraints.NONE;
        thePanel.add(new JLabel("Bane Card"),theCons);
        myBaneField = new JTextField(myChosenStrategy.getBaneCardAsString(), 20);
        theCons.gridx++;
        thePanel.add(myBaneField,theCons);
        //Mountain Pass bid
        theCons.gridx=0;
        theCons.gridy++;
        theCons.fill=GridBagConstraints.NONE;
        thePanel.add(new JLabel("Mountain Pass bid"),theCons);
        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(false);
        myMountainPassBidField = new JFormattedTextField(formatter);
        myMountainPassBidField.setColumns(10);
        myMountainPassBidField.setValue(myChosenStrategy.getMountainPassBid(0));
        theCons.gridx++;
        thePanel.add(myMountainPassBidField,theCons);
        //Obelisk card
        theCons.gridx=0;
        theCons.gridy++;
        theCons.fill=GridBagConstraints.NONE;
        thePanel.add(new JLabel("Obelisk choice"),theCons);
        myObeliskChoice = new JTextField(myChosenStrategy.getObeliskChoice(), 20);
        theCons.gridx++;
        thePanel.add(myObeliskChoice,theCons);
        //Shelters
        theCons.gridx=0;
        theCons.gridy++;
        theCons.fill=GridBagConstraints.NONE;
        myShelters = new JCheckBox("Shelters", myChosenStrategy.getShelters());
        thePanel.add(myShelters,theCons);
        //info button
        JButton theInfoBTN = new JButton("Info");
        theInfoBTN.setMnemonic('I');
        theInfoBTN.addActionListener(this);
        theInfoBTN.setActionCommand("BoardInfo");
        theCons.gridy++;
        theCons.fill=GridBagConstraints.NONE;
        theCons.anchor=GridBagConstraints.EAST;
        thePanel.add(theInfoBTN,theCons);
        return thePanel;
	}
 
Example 12
Source File: IntegerEditor.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
public IntegerEditor(int min, int max)
{
	super(new JFormattedTextField());
	ftf = (JFormattedTextField) getComponent();
	minimum = min;
	maximum = max;

	//Set up the editor for the integer cells.
	integerFormat = NumberFormat.getIntegerInstance();
	NumberFormatter intFormatter = new NumberFormatter(integerFormat);
	intFormatter.setFormat(integerFormat);
	intFormatter.setMinimum(minimum);
	intFormatter.setMaximum(maximum);

	ftf.setFormatterFactory(new DefaultFormatterFactory(intFormatter));
	ftf.setValue(minimum);
	ftf.setHorizontalAlignment(SwingConstants.TRAILING);
	ftf.setFocusLostBehavior(JFormattedTextField.PERSIST);

	//React when the user presses Enter while the editor is
	//active.  (Tab is handled as specified by
	//JFormattedTextField's focusLostBehavior property.)
	ftf.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "check");
	ftf.getActionMap().put("check", new AbstractAction()
	{

		@Override
		public void actionPerformed(ActionEvent e)
		{
			if (!ftf.isEditValid())
			{ //The text is invalid.
				if (userSaysRevert())
				{ //reverted
					ftf.postActionEvent(); //inform the editor
				}
			}
			else
			{
				try
				{ //The text is valid,
					ftf.commitEdit(); //so use it.
					ftf.postActionEvent(); //stop editing
				}
				catch (java.text.ParseException exc)
				{
				}
			}
		}

	});
}
 
Example 13
Source File: TomcatSettingsEditor.java    From SmartTomcat with Apache License 2.0 4 votes vote down vote up
@NotNull
@Override
protected JComponent createEditor() {

    ComboboxWithBrowseButton tomcatField = runnerSetting.getTomcatField();
    TextFieldWithBrowseButton docBaseField = runnerSetting.getDocBaseField();

    JTextField contextPathField = runnerSetting.getContextPathField();
    JFormattedTextField portField = runnerSetting.getPortField();
    JFormattedTextField adminPort = runnerSetting.getAdminPort();

    JXButton configrationButton = runnerSetting.getConfigrationButton();
    configrationButton.addActionListener(e -> ShowSettingsUtil.getInstance().showSettingsDialog(project, TomcatSettingConfigurable.class));


    VirtualFile baseDir = VirtualFileManager.getInstance().getFileSystem("file").findFileByPath(project.getBasePath());

    FileChooserDescriptor chooserDescriptor = new IgnoreOutputFileChooserDescriptor(project).withRoots(baseDir);
    docBaseField.addBrowseFolderListener("webapp", "Choose Web Folder", project, chooserDescriptor);
    docBaseField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
        @Override
        protected void textChanged(DocumentEvent documentEvent) {

            if (!documentEvent.getType().equals(DocumentEvent.EventType.REMOVE)) {
                String text = docBaseField.getText();
                if (text != null && !text.trim().equals("")) {
                    VirtualFile fileByIoFile = LocalFileSystem.getInstance().findFileByIoFile(new File(text));

                    Module module = ModuleUtilCore.findModuleForFile(fileByIoFile, project);
                    String contextPath = module == null ? "/" : "/" + module.getName();
                    contextPathField.setText(contextPath);
                }
            }

        }
    });

    portField.setValue(8080);
    adminPort.setValue(8005);
    DefaultFormatterFactory tf = new DefaultFormatterFactory();
    NumberFormat format = NumberFormat.getInstance();
    format.setGroupingUsed(false);
    NumberFormatter formatter = new NumberFormatter(format);
    formatter.setValueClass(Integer.class);
    formatter.setMinimum(0);
    formatter.setMaximum(65535);
    tf.setDefaultFormatter(formatter);
    portField.setFormatterFactory(tf);
    adminPort.setFormatterFactory(tf);

    return runnerSetting.getMainPanel();
}
 
Example 14
Source File: IsotopePeakScannerSetupDialog.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected void addDialogComponents() {
  super.addDialogComponents();

  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();

  pnlChart = new EChartPanel(chart);
  pnlChart.setPreferredSize(
      new Dimension((int) (screenSize.getWidth() / 3), (int) (screenSize.getHeight() / 3)));
  pnlPreview.add(pnlChart, BorderLayout.CENTER);


  // get components
  cmpAutoCarbon = (OptionalModuleComponent) this
      .getComponentForParameter(IsotopePeakScannerParameters.autoCarbonOpt);
  cmpAutoCarbonCbx = (JCheckBox) cmpAutoCarbon.getComponent(0);
  cmpPreview =
      (JCheckBox) this.getComponentForParameter(IsotopePeakScannerParameters.showPreview);
  cmpPreview.setSelected(false); // i want to have the checkbox below the pattern settings
  // but it should be disabled by default. Thats why it's hardcoded here.

  // get parameters
  pElement = parameterSet.getParameter(IsotopePeakScannerParameters.element);
  pMinIntensity = parameterSet.getParameter(IsotopePeakScannerParameters.minPatternIntensity);
  pCharge = parameterSet.getParameter(IsotopePeakScannerParameters.charge);
  pMergeWidth = parameterSet.getParameter(IsotopePeakScannerParameters.mergeWidth);
  pAutoCarbon = parameterSet.getParameter(IsotopePeakScannerParameters.autoCarbonOpt);
  autoCarbonParameters = pAutoCarbon.getEmbeddedParameters();
  pMinC = autoCarbonParameters.getParameter(AutoCarbonParameters.minCarbon);
  pMaxC = autoCarbonParameters.getParameter(AutoCarbonParameters.maxCarbon);
  pMinSize = autoCarbonParameters.getParameter(AutoCarbonParameters.minPatternSize);

  // set up gui
  form = new NumberFormatter(NumberFormat.getInstance());
  form.setValueClass(Integer.class);
  form.setFormat(new DecimalFormat("0"));
  form.setAllowsInvalid(true);
  form.setMinimum(minC);
  form.setMaximum(maxC);

  btnPrevPattern = new JButton("Previous");
  btnPrevPattern.addActionListener(this);
  btnPrevPattern.setMinimumSize(btnPrevPattern.getPreferredSize());
  btnPrevPattern.setEnabled(cmpAutoCarbonCbx.isSelected());

  txtCurrentPatternIndex = new JFormattedTextField(form);
  txtCurrentPatternIndex.addActionListener(this);
  txtCurrentPatternIndex.setText(String.valueOf((minC + maxC) / 2));
  txtCurrentPatternIndex.setPreferredSize(new Dimension(50, 25));
  txtCurrentPatternIndex.setEditable(true);
  txtCurrentPatternIndex.setEnabled(cmpAutoCarbonCbx.isSelected());

  btnNextPattern = new JButton("Next");
  btnNextPattern.addActionListener(this);
  btnNextPattern.setPreferredSize(btnNextPattern.getMinimumSize());
  btnNextPattern.setEnabled(cmpAutoCarbonCbx.isSelected());

  chart = ChartFactory.createXYBarChart("Isotope pattern preview", "m/z", false, "Abundance",
      new XYSeriesCollection(new XYSeries("")));
  chart.getPlot().setBackgroundPaint(Color.WHITE);
  chart.getXYPlot().setDomainGridlinePaint(Color.GRAY);
  chart.getXYPlot().setRangeGridlinePaint(Color.GRAY);

  pnlPreviewButtons.add(btnPrevPattern);
  pnlPreviewButtons.add(txtCurrentPatternIndex);
  pnlPreviewButtons.add(btnNextPattern);

  pack();
}
 
Example 15
Source File: EventSamplerGui.java    From BotServiceStressToolkit with MIT License 4 votes vote down vote up
private void init() {
	// Standard setup
	setLayout(new BorderLayout(0, 5));
	setBorder(makeBorder());
	add(makeTitlePanel(), BorderLayout.NORTH); // Add the standard title

	JPanel mainPanel = new JPanel();
	add(mainPanel, BorderLayout.CENTER);

	numOfResponsesExpectedLabel = new javax.swing.JLabel(NUMBER_OF_RESPONSES_EXPECTED_LABEL);
	
	channeldataTextArea.setColumns(20);
	channeldataTextArea.setRows(5);
	channeldataAreaScrollPane.setViewportView(channeldataTextArea);
	
	NumberFormat format = new DecimalFormat("#0");
	NumberFormatter formatter = new NumberFormatter(format);
	formatter.setValueClass(Integer.class);
	formatter.setMinimum(0);
	formatter.setMaximum(MAX_RESPONSES_ALLOWED);
	formatter.setAllowsInvalid(false);
	formatter.setCommitsOnValidEdit(true);

	numOfResponsesExpectedTextField = new javax.swing.JFormattedTextField(formatter);
	numOfResponsesExpectedLabel.setText(NUMBER_OF_RESPONSES_EXPECTED_LABEL);
	channeldataLabel.setText(CHANNELDATA_LABEL);
	eventNameLabel.setText(EVENT_NAME_LABEL);
	
	javax.swing.GroupLayout layout = new javax.swing.GroupLayout(mainPanel);
	mainPanel.setLayout(layout);

	layout.setHorizontalGroup(
			layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
					.createSequentialGroup().addGroup(layout
							.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
									.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
									.addComponent(channeldataLabel, javax.swing.GroupLayout.Alignment.LEADING,
											javax.swing.GroupLayout.DEFAULT_SIZE,
											javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
									.addComponent(eventNameLabel, javax.swing.GroupLayout.Alignment.LEADING,
											javax.swing.GroupLayout.DEFAULT_SIZE,
											javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
							.addComponent(numOfResponsesExpectedLabel))
					.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
							.addComponent(eventNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 244,
									javax.swing.GroupLayout.PREFERRED_SIZE)
							.addComponent(numOfResponsesExpectedTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
									244, javax.swing.GroupLayout.PREFERRED_SIZE)
							.addComponent(channeldataAreaScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 585,
									javax.swing.GroupLayout.PREFERRED_SIZE))
					.addGap(0, 469, Short.MAX_VALUE)));
	layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
			.createSequentialGroup().addContainerGap()
			.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
					.addComponent(channeldataAreaScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE,
							javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
					.addGroup(layout.createSequentialGroup().addGap(30, 30, 30).addComponent(channeldataLabel)))
			.addGap(10, 10, 10)
			.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
					.addComponent(eventNameLabel).addComponent(eventNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
							javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
			.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
			.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
					.addComponent(numOfResponsesExpectedLabel).addComponent(numOfResponsesExpectedTextField,
							javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
							javax.swing.GroupLayout.PREFERRED_SIZE))
			.addContainerGap(540, Short.MAX_VALUE)));
}
 
Example 16
Source File: ConversationUpdateSamplerGui.java    From BotServiceStressToolkit with MIT License 4 votes vote down vote up
private void init() { // WARNING: called from ctor so must not be overridden
						// (i.e. must be private or final)
	// Standard setup
	setLayout(new BorderLayout(0, 5));
	setBorder(makeBorder());
	add(makeTitlePanel(), BorderLayout.NORTH); // Add the standard title

	JPanel mainPanel = new JPanel();
	add(mainPanel, BorderLayout.CENTER);

	numOfResponsesExpectedLabel = new javax.swing.JLabel();
	membersAddedLabel = new javax.swing.JLabel();

	NumberFormat format = new DecimalFormat("#0");
	NumberFormatter formatter = new NumberFormatter(format);
	formatter.setValueClass(Integer.class);
	formatter.setMinimum(0);
	formatter.setMaximum(MAX_RESPONSES_ALLOWED);
	formatter.setAllowsInvalid(false);
	formatter.setCommitsOnValidEdit(true);

	numOfResponsesExpectedTextField = new javax.swing.JFormattedTextField(formatter);
	membersAddedTextField = new javax.swing.JTextField();

	numOfResponsesExpectedLabel.setText(NUMBER_OF_RESPONSES_EXPECTED_LABEL);
	membersAddedLabel.setText(MEMBERS_ADDED_LABEL);

	javax.swing.GroupLayout layout = new javax.swing.GroupLayout(mainPanel);
	mainPanel.setLayout(layout);
	layout.setHorizontalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
			.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addGroup(layout
					.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
					.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
							.addGroup(layout.createSequentialGroup().addComponent(numOfResponsesExpectedLabel)
									.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED,
											javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
									.addComponent(numOfResponsesExpectedTextField,
											javax.swing.GroupLayout.PREFERRED_SIZE, 327,
											javax.swing.GroupLayout.PREFERRED_SIZE))
							.addGroup(javax.swing.GroupLayout.Alignment.LEADING,
									layout.createSequentialGroup().addComponent(membersAddedLabel)
											.addGap(42, 42, 42).addComponent(membersAddedTextField,
													javax.swing.GroupLayout.PREFERRED_SIZE, 327,
													javax.swing.GroupLayout.PREFERRED_SIZE))))
					.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
	layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
			.addGroup(layout.createSequentialGroup().addGap(32, 32, 32)
					.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
							.addComponent(numOfResponsesExpectedLabel).addComponent(numOfResponsesExpectedTextField,
									javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
									javax.swing.GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
							.addComponent(membersAddedLabel).addComponent(membersAddedTextField,
									javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
									javax.swing.GroupLayout.PREFERRED_SIZE))
					.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)));
}
 
Example 17
Source File: MessageSamplerGui.java    From BotServiceStressToolkit with MIT License 4 votes vote down vote up
private void init() { // WARNING: called from ctor so must not be overridden
						// (i.e. must be private or final)
	// Standard setup
	setLayout(new BorderLayout(0, 5));
	setBorder(makeBorder());
	add(makeTitlePanel(), BorderLayout.NORTH); // Add the standard title

	JPanel mainPanel = new JPanel();
	add(mainPanel, BorderLayout.CENTER);

	numOfResponsesExpectedLabel = new javax.swing.JLabel(NUMBER_OF_RESPONSES_EXPECTED_LABEL);

	messageTextTextArea.setColumns(20);
	messageTextTextArea.setRows(5);
	messageTextAreaScrollPane.setViewportView(messageTextTextArea);

	NumberFormat format = new DecimalFormat("#0");
	NumberFormatter formatter = new NumberFormatter(format);
	formatter.setValueClass(Integer.class);
	formatter.setMinimum(0);
	formatter.setMaximum(MAX_RESPONSES_ALLOWED);
	formatter.setAllowsInvalid(false);
	formatter.setCommitsOnValidEdit(true);

	numOfResponsesExpectedTextField = new javax.swing.JFormattedTextField(formatter);
	numOfResponsesExpectedLabel.setText(NUMBER_OF_RESPONSES_EXPECTED_LABEL);
	messageTextLabel.setText(MESSAGE_TEXT_LABEL);
	messageTextFormatLabel.setText(MESSAGE_TEXT_FORMAT_LABEL);
	localeLabel.setText(LOCALE_LABEL);

	javax.swing.GroupLayout layout = new javax.swing.GroupLayout(mainPanel);
	mainPanel.setLayout(layout);

	layout.setHorizontalGroup(
			layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
					.createSequentialGroup().addGroup(layout
							.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
									.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
									.addComponent(messageTextLabel, javax.swing.GroupLayout.Alignment.LEADING,
											javax.swing.GroupLayout.DEFAULT_SIZE,
											javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
									.addComponent(messageTextFormatLabel, javax.swing.GroupLayout.Alignment.LEADING,
											javax.swing.GroupLayout.DEFAULT_SIZE,
											javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
									.addComponent(localeLabel, javax.swing.GroupLayout.DEFAULT_SIZE,
											javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
							.addComponent(numOfResponsesExpectedLabel))
					.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
					.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
							.addComponent(localeTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 244,
									javax.swing.GroupLayout.PREFERRED_SIZE)
							.addComponent(numOfResponsesExpectedTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
									244, javax.swing.GroupLayout.PREFERRED_SIZE)
							.addComponent(messageTextFormatTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 244,
									javax.swing.GroupLayout.PREFERRED_SIZE)
							.addComponent(messageTextAreaScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 585,
									javax.swing.GroupLayout.PREFERRED_SIZE))
					.addGap(0, 469, Short.MAX_VALUE)));
	layout.setVerticalGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout
			.createSequentialGroup().addContainerGap()
			.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
					.addComponent(messageTextAreaScrollPane, javax.swing.GroupLayout.PREFERRED_SIZE,
							javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
					.addGroup(layout.createSequentialGroup().addGap(30, 30, 30).addComponent(messageTextLabel)))
			.addGap(10, 10, 10)
			.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
					.addComponent(messageTextFormatLabel).addComponent(messageTextFormatTextField,
							javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
							javax.swing.GroupLayout.PREFERRED_SIZE))
			.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
			.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
					.addComponent(localeLabel).addComponent(localeTextField, javax.swing.GroupLayout.PREFERRED_SIZE,
							javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
			.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
			.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
					.addComponent(numOfResponsesExpectedLabel).addComponent(numOfResponsesExpectedTextField,
							javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,
							javax.swing.GroupLayout.PREFERRED_SIZE))
			.addContainerGap(540, Short.MAX_VALUE)));
}
 
Example 18
Source File: Fields.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public static FieldBuilder<JFormattedTextField, Double> doubleFieldBuilder() {
   NumberFormatter formatter = new NumberFormatter();
   formatter.setMaximum(Double.MAX_VALUE);
   formatter.setMinimum(-Double.MAX_VALUE);
   return new FormattedTextFieldBuilder<Double>(formatter);
}
 
Example 19
Source File: Fields.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public static FieldBuilder<JFormattedTextField, Long> longFieldBuilder() {
   NumberFormatter formatter = new NumberFormatter();
   formatter.setMaximum(Long.MAX_VALUE);
   formatter.setMinimum(Long.MIN_VALUE);
   return new FormattedTextFieldBuilder<Long>(formatter);
}
 
Example 20
Source File: Fields.java    From arcusplatform with Apache License 2.0 4 votes vote down vote up
public static FieldBuilder<JFormattedTextField, Integer> intFieldBuilder() {
   NumberFormatter intFormatter = new NumberFormatter();
   intFormatter.setMaximum(Integer.MAX_VALUE);
   intFormatter.setMinimum(Integer.MIN_VALUE);
   return new FormattedTextFieldBuilder<Integer>(intFormatter);
}