Java Code Examples for javax.swing.text.NumberFormatter#setValueClass()
The following examples show how to use
javax.swing.text.NumberFormatter#setValueClass() .
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: SkillInfoTab.java From pcgen with GNU Lesser General Public License v2.1 | 7 votes |
private SkillRankSpinnerEditor(SkillRankSpinnerModel model) { super(model); this.model = model; DefaultEditor editor = new DefaultEditor(spinner); NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.#")); //$NON-NLS-1$ formatter.setValueClass(Float.class); DefaultFormatterFactory factory = new DefaultFormatterFactory(formatter); JFormattedTextField ftf = editor.getTextField(); ftf.setEditable(true); ftf.setFormatterFactory(factory); ftf.setHorizontalAlignment(SwingConstants.RIGHT); spinner.setEditor(editor); }
Example 2
Source File: ComponentsFactory.java From MercuryTrade with MIT License | 6 votes |
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; }
Example 3
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private static DefaultFormatterFactory makeFFactory(SpinnerNumberModel m) { // DecimalFormatSymbols dfs) { NumberFormat format = new DecimalFormat("####0"); // , dfs); NumberFormatter editFormatter = new NumberFormatter(format) { // @Override protected DocumentFilter getDocumentFilter() { // return new IntegerDocumentFilter(); // } @Override public Object stringToValue(String text) throws ParseException { try { Long.parseLong(text); } catch (NumberFormatException ex) { throw (ParseException) new ParseException(ex.getMessage(), 0).initCause(ex); } Object o = format.parse(text); if (o instanceof Long) { Long val = (Long) format.parse(text); Long max = (Long) m.getMaximum(); Long min = (Long) m.getMinimum(); if (max.compareTo(val) < 0 || min.compareTo(val) > 0) { throw new ParseException("out of bounds", 0); } return val; } throw new ParseException("not Long", 0); } }; // editFormatter.setAllowsInvalid(false); // editFormatter.setCommitsOnValidEdit(true); editFormatter.setValueClass(Long.class); NumberFormatter displayFormatter = new NumberFormatter(format); return new DefaultFormatterFactory(displayFormatter, displayFormatter, editFormatter); }
Example 4
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
private static DefaultFormatterFactory makeFFactory(DecimalFormatSymbols dfs) { DecimalFormat format = new DecimalFormat("0.00", dfs); NumberFormatter displayFormatter = new NumberFormatter(format); displayFormatter.setValueClass(Double.class); NumberFormatter editFormatter = new NumberFormatter(format); editFormatter.setValueClass(Double.class); return new DefaultFormatterFactory(displayFormatter, displayFormatter, editFormatter); }
Example 5
Source File: GrammarvizGuesserPane.java From grammarviz2_src with GNU General Public License v2.0 | 5 votes |
/** * 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 6
Source File: ClassDialogue.java From JByteMod-Beta with GNU General Public License v2.0 | 5 votes |
@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: ImageInfoEditor.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private void editSliderSample(MouseEvent evt, final int sliderIndex) { final PropertyContainer vc = new PropertyContainer(); vc.addProperty(Property.create("sample", getSliderSample(sliderIndex))); vc.getDescriptor("sample").setDisplayName("sample"); vc.getDescriptor("sample").setUnit(getModel().getParameterUnit()); final ValueRange valueRange; if (sliderIndex == 0) { valueRange = new ValueRange(Double.NEGATIVE_INFINITY, round(getMaxSliderSample(sliderIndex))); } else if (sliderIndex == getSliderCount() - 1) { valueRange = new ValueRange(round(getMinSliderSample(sliderIndex)), Double.POSITIVE_INFINITY); } else { valueRange = new ValueRange(round(getMinSliderSample(sliderIndex)), round(getMaxSliderSample(sliderIndex))); } vc.getDescriptor("sample").setValueRange(valueRange); final BindingContext ctx = new BindingContext(vc); final NumberFormatter formatter = new NumberFormatter(new DecimalFormat("#0.0#")); formatter.setValueClass(Double.class); // to ensure that double values are returned final JFormattedTextField field = new JFormattedTextField(formatter); field.setColumns(11); field.setHorizontalAlignment(JFormattedTextField.RIGHT); ctx.bind("sample", field); showPopup(evt, field); ctx.addPropertyChangeListener("sample", pce -> { hidePopup(); setSliderSample(sliderIndex, (Double) ctx.getBinding("sample").getPropertyValue()); computeZoomInToSliderLimits(); applyChanges(); }); }
Example 8
Source File: GridSizeDialog.java From Carcassonne with Eclipse Public License 2.0 | 5 votes |
/** * 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 9
Source File: AddBookView.java From protobuf-converter with MIT License | 5 votes |
public AddBookView(final JFrame windowFrame) { form = new JPanel(); form.setLayout(null); form.setBounds(0, 210, 250, 250); titleLable = new JLabel("Title"); titleLable.setBounds(10, 10, 80, 25); form.add(titleLable); titleText = new JTextField(20); titleText.setBounds(80, 10, 160, 25); form.add(titleText); authorLabel = new JLabel("Author"); authorLabel.setBounds(10, 40, 80, 25); form.add(authorLabel); authorText = new JTextField(20); authorText.setBounds(80, 40, 160, 25); form.add(authorText); pageLabel = new JLabel("Pages"); pageLabel.setBounds(10, 70, 80, 25); form.add(pageLabel); NumberFormatter numberFormatter = new NumberFormatter(NumberFormat.getIntegerInstance()); numberFormatter.setValueClass(Integer.class); numberFormatter.setAllowsInvalid(false); numberFormatter.setMinimum(1); pageText = new JFormattedTextField(numberFormatter); pageText.setBounds(80, 70, 160, 25); form.add(pageText); addButton = new JButton("Add"); addButton.setBounds(160, 100, 80, 25); form.add(addButton); addButton.addActionListener(this); windowFrame.add(form); }
Example 10
Source File: PreferencesDialog.java From yawl with GNU Lesser General Public License v3.0 | 5 votes |
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 11
Source File: Continuous1BandBasicForm.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private JFormattedTextField getNumberTextField(double value) { final NumberFormatter formatter = new NumberFormatter(new DecimalFormat("0.0############")); formatter.setValueClass(Double.class); // to ensure that double values are returned final JFormattedTextField numberField = new JFormattedTextField(formatter); numberField.setValue(value); final Dimension preferredSize = numberField.getPreferredSize(); preferredSize.width = 70; numberField.setPreferredSize(preferredSize); return numberField; }
Example 12
Source File: FormattedDecimalField.java From bither-desktop-java with Apache License 2.0 | 5 votes |
/** * @param min The minimum value * @param max The maximum value * @param decimalPlaces The number of decimal places to show (padding as required) * @param maxLength The maximum length */ public FormattedDecimalField(double min, double max, int decimalPlaces, int maxLength) { super(); Preconditions.checkNotNull(min, "'min' must be present"); Preconditions.checkNotNull(max, "'max' must be present"); Preconditions.checkState(min < max, "'min' must be less than 'max'"); Preconditions.checkState(decimalPlaces >= 0 && decimalPlaces < 15, "'decimalPlaces' must be in range [0,15)"); // setInputVerifier(new ThemeAwareDecimalInputVerifier(min, max)); setBackground(Themes.currentTheme.dataEntryBackground()); // Build number formatters NumberFormatter defaultFormatter = new NumberFormatter(); defaultFormatter.setValueClass(BigDecimal.class); NumberFormatter displayFormatter = Numbers.newDisplayFormatter(decimalPlaces, maxLength); NumberFormatter editFormatter = Numbers.newEditFormatter(decimalPlaces, maxLength); setFormatterFactory(new DefaultFormatterFactory( defaultFormatter, displayFormatter, editFormatter )); }
Example 13
Source File: Numbers.java From bither-desktop-java with Apache License 2.0 | 5 votes |
/** * @param decimalFormat The decimal format appropriate for this locale * @return A number formatter that is locale-aware and configured for doubles */ private static NumberFormatter newNumberFormatter(final DecimalFormat decimalFormat, final int maxEditLength) { // Create the number formatter with local-sensitive adjustments NumberFormatter displayFormatter = new NumberFormatter(decimalFormat) { // The max input length for the given symbol DocumentFilter documentFilter = new DocumentMaxLengthFilter(maxEditLength); @Override public Object stringToValue(String text) throws ParseException { // RU locale (and others) requires a non-breaking space for a grouping separator text = text.replace(' ', '\u00a0'); return super.stringToValue(text); } @Override protected DocumentFilter getDocumentFilter() { return documentFilter; } }; // Use a BigDecimal for widest value handling displayFormatter.setValueClass(BigDecimal.class); return displayFormatter; }
Example 14
Source File: DomBotEditor.java From DominionSim with MIT License | 4 votes |
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 15
Source File: IsotopePeakScannerSetupDialog.java From mzmine2 with GNU General Public License v2.0 | 4 votes |
@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 16
Source File: Config.java From BeanStack with Apache License 2.0 | 4 votes |
public Config() { settings = new LinkedHashMap<>(); // These put()s determine the order shown on the settings screen // Note that the default values are documented on the website, so update accordingly put("enable", true); put("apikey", "none"); put("classblacklist", ""); put("hashtrace", true); put("issuepercve", false); put("debug", false); put("logdups", false); put("issuetitle", "Stack Trace Fingerprint Found"); put("apiurl", "https://beanstack.io/api/"); // NOTE: when editing these names, also update the documentation! readableNames = new LinkedHashMap<>(); readableNames.put("enable", "Enable Lookups"); readableNames.put("apiurl", "API URL"); readableNames.put("issuetitle", "Issue Title"); readableNames.put("debug", "Print Debug Messages to Stdout"); readableNames.put("logdups", "Log Duplicates"); readableNames.put("apikey", "API Key"); readableNames.put("classblacklist", "Blacklisted Class Prefixes"); readableNames.put("issuepercve", "Create an issue for each CVE*"); readableNames.put("hashtrace", "Hash traces before submission*"); for (String key: settings.keySet()) { //callbacks.saveExtensionSetting(key, null); // purge saved settings String value = GlobalVars.callbacks.loadExtensionSetting(key); if (GlobalVars.callbacks.loadExtensionSetting(key) != null) { putRaw(key, value); } } NumberFormat format = NumberFormat.getInstance(); onlyInt = new NumberFormatter(format); onlyInt.setValueClass(Integer.class); onlyInt.setMinimum(-1); onlyInt.setMaximum(Integer.MAX_VALUE); onlyInt.setAllowsInvalid(false); }
Example 17
Source File: TomcatSettingsEditor.java From SmartTomcat with Apache License 2.0 | 4 votes |
@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 18
Source File: EventSamplerGui.java From BotServiceStressToolkit with MIT License | 4 votes |
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 19
Source File: ConversationUpdateSamplerGui.java From BotServiceStressToolkit with MIT License | 4 votes |
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 20
Source File: MessageSamplerGui.java From BotServiceStressToolkit with MIT License | 4 votes |
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))); }