Java Code Examples for java.text.NumberFormat#getIntegerInstance()

The following examples show how to use java.text.NumberFormat#getIntegerInstance() . 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: Tools.java    From rapidminer-studio with GNU Affero General Public License v3.0 6 votes vote down vote up
public static void setFormatLocale(Locale locale) {
	FORMAT_LOCALE = locale;

	int numberDigits = 3;
	try {
		String numberDigitsString = ParameterService
				.getParameterValue(RapidMiner.PROPERTY_RAPIDMINER_GENERAL_FRACTIONDIGITS_NUMBERS);
		numberDigits = Integer.parseInt(numberDigitsString);
	} catch (NumberFormatException e) {
	}
	NUMBER_FORMAT = new DecimalFormat(getDecimalFormatPattern(numberDigits),
			DecimalFormatSymbols.getInstance(FORMAT_LOCALE));
	INTEGER_FORMAT = NumberFormat.getIntegerInstance(locale);
	PERCENT_FORMAT = NumberFormat.getPercentInstance(locale);
	FORMAT_SYMBOLS = new DecimalFormatSymbols(locale);
}
 
Example 2
Source File: FastDecimalFormat.java    From pentaho-reporting with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * Creates a new number-format for the given type using the standard JDK methods.
 *
 * @param type   the type.
 * @param locale the locale for which the format shoudl be created.
 * @return the number format or null, if there was an error while creating the format.
 */
private NumberFormat createFormat( final int type, final Locale locale ) {
  switch ( type ) {
    case TYPE_INTEGER: {
      return NumberFormat.getIntegerInstance( locale );
    }
    case TYPE_PERCENT: {
      return NumberFormat.getPercentInstance( locale );
    }
    case TYPE_CURRENCY: {
      return NumberFormat.getCurrencyInstance( locale );
    }
    default: {
      return NumberFormat.getInstance( locale );
    }
  }
}
 
Example 3
Source File: AutomaticWorkQueueImpl.java    From cxf with Apache License 2.0 5 votes vote down vote up
public Dictionary<String, String> getProperties() {
    Dictionary<String, String> properties = new Hashtable<>();
    NumberFormat nf = NumberFormat.getIntegerInstance();
    properties.put("name", nf.format(getName()));
    properties.put("highWaterMark", nf.format(getHighWaterMark()));
    properties.put("lowWaterMark", nf.format(getLowWaterMark()));
    properties.put("initialSize", nf.format(getLowWaterMark()));
    properties.put("dequeueTimeout", nf.format(getLowWaterMark()));
    properties.put("queueSize", nf.format(getLowWaterMark()));
    return properties;
}
 
Example 4
Source File: ControlPanel.java    From openvisualtraceroute with GNU Lesser General Public License v3.0 5 votes vote down vote up
public NumberFormatterFactory() {
	super();
	final NumberFormat format = NumberFormat.getIntegerInstance();
	format.setGroupingUsed(false);
	final NumberFormatter nf = new NumberFormatter(format);
	setDefaultFormatter(nf);
	setDisplayFormatter(nf);
	setEditFormatter(nf);
}
 
Example 5
Source File: SinglestreamXmlDumpParser.java    From wikiforia with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String toString() {
    NumberFormat nf = NumberFormat.getIntegerInstance();
    nf.setGroupingUsed(true);

    return String.format("Singlestreamed XML Dump parser { \n * Batch size: %s, \n * Input: %s \n}",
                         nf.format(batchsize),
                         pageInput == null ? "[Inputstream]" : pageInput.getAbsolutePath());
}
 
Example 6
Source File: UIUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
/**
 * It is your responsibility to set correct horizontal align (left in case of UI Designer)
 */
public static void configureNumericFormattedTextField(@Nonnull JFormattedTextField textField) {
  NumberFormat format = NumberFormat.getIntegerInstance();
  format.setParseIntegerOnly(true);
  format.setGroupingUsed(false);
  NumberFormatter numberFormatter = new NumberFormatter(format);
  numberFormatter.setMinimum(0);
  textField.setFormatterFactory(new DefaultFormatterFactory(numberFormatter));
  textField.setHorizontalAlignment(SwingConstants.TRAILING);

  textField.setColumns(4);
}
 
Example 7
Source File: NumberRollView.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the number roll position.
 */
private void setNumberRoll(float number) {
    mNumber = number;
    int downNumber = (int) number;
    int upNumber = downNumber + 1;

    NumberFormat numberFormatter = NumberFormat.getIntegerInstance();
    String newString = numberFormatter.format(upNumber);
    if (!newString.equals(mUpNumber.getText().toString())) {
        mUpNumber.setText(newString);
        if (mContentDescriptionStringId != 0) {
            mUpNumber.setContentDescription(getResources().getQuantityString(
                    mContentDescriptionStringId, upNumber, upNumber));
        }
    }

    newString = numberFormatter.format(downNumber);
    if (!newString.equals(mDownNumber.getText().toString())) {
        mDownNumber.setText(newString);
        if (mContentDescriptionStringId != 0) {
            mDownNumber.setContentDescription(getResources().getQuantityString(
                    mContentDescriptionStringId, downNumber, downNumber));
        }
    }

    float offset = number % 1.0f;

    mUpNumber.setTranslationY(mUpNumber.getHeight() * (offset - 1.0f));
    mDownNumber.setTranslationY(mDownNumber.getHeight() * offset);

    mUpNumber.setAlpha(offset);
    mDownNumber.setAlpha(1.0f - offset);
}
 
Example 8
Source File: EditSettingsControlPanel.java    From VanetSim with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates the panel which is shown when mix zones are enabled.
 * 
 * @return the mix zones panel
 */
private final JPanel createMixPanel(){
	JPanel panel = new JPanel();
	panel.setOpaque(false);
	panel.setLayout(new GridBagLayout());
	
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.anchor = GridBagConstraints.PAGE_START;
	c.weightx = 1;
	c.gridx = 0;
	c.gridy = 0;
	c.gridheight = 1;
	c.insets = new Insets(5,0,5,0);
	
	JLabel jLabel1 = new JLabel(Messages.getString("EditSettingsControlPanel.mixZoneSize")); //$NON-NLS-1$
	panel.add(jLabel1,c);		
	mixZoneRadius_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
	mixZoneRadius_.setPreferredSize(new Dimension(60,20));
	mixZoneRadius_.setValue(100);
	mixZoneRadius_.addPropertyChangeListener("value", this); //$NON-NLS-1$
	c.gridx = 1;
	c.weightx = 0;
	panel.add(mixZoneRadius_,c);
	
	c.gridx = 0;
	c.gridwidth = 2;
	++c.gridy;
	fallbackInMixZonesCheckBox_ = new JCheckBox(Messages.getString("EditSettingsControlPanel.fallbackCommunicationInMixZones"), true); //$NON-NLS-1$
	fallbackInMixZonesCheckBox_.addItemListener(this);
	panel.add(fallbackInMixZonesCheckBox_,c);
	
	++c.gridy;
	fallbackInMixZonesPanel_ = createMixFallBackPanel();
	panel.add(fallbackInMixZonesPanel_,c);
	
	return panel;
}
 
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: AbstractDbAccess.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
/**
 * Convert duration in seconds to days, hours, minutes and seconds
 * @param time time in seconds
 * @return
 */
public static String formatTimeDiffereceFromSecondsToString( int time ) {

    int days = time / DAY_IN_SECONDS;
    time -= days * DAY_IN_SECONDS;

    int hours = time / HOUR_IN_SECONDS;
    time -= hours * HOUR_IN_SECONDS;

    int minutes = time / MIN_IN_SECONDS;
    time -= minutes * MIN_IN_SECONDS;

    int seconds = time;

    NumberFormat nf = NumberFormat.getIntegerInstance();
    nf.setMinimumIntegerDigits(2);

    StringBuilder duration = new StringBuilder();
    if (days > 0) {
        duration.append(days);
        duration.append(" days, ");
    }
    duration.append(nf.format(hours));
    duration.append(":");
    duration.append(nf.format(minutes));
    duration.append(":");
    duration.append(nf.format(seconds));
    return duration.toString();
}
 
Example 11
Source File: RandomPerformanceTests.java    From jenetics with Apache License 2.0 5 votes vote down vote up
private static String testNextLong(final Random random, final int loops) {
	long start = System.nanoTime();
	for (int i = loops; --i >= 0;) {
		random.nextLong();
	}
	long end = System.nanoTime();

	final NumberFormat format = NumberFormat.getIntegerInstance();
	return String.format("%11s l/sec", format.format(perSec(loops, start, end)));
}
 
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: Test6462562.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
void testIntegerFormat() {
    NumberFormat format = NumberFormat.getIntegerInstance(Locale.US);
    TestFormattedTextField ftf = create(format);
    ftf.setValue(56L);

    System.err.println("Testing NumberFormat.getIntegerInstance(Locale.US)");

    // test inserting individual characters
    ftf.test(0, 0, "1", 16L);
    ftf.test(2, 0, "2", 162L);
    ftf.test(1, 0, "0", 102L);

    // test inserting several characters at once - e.g. from clipboard
    ftf.test(0, 0, "1024", 1024L);
    ftf.test(3, 0, "333", 10333L);
    ftf.test(6, 0, "77", 1033377L);
    ftf.test(4, 0, "99", 1039977L);
    ftf.test(6, 0, "00", 1039007L);

    // test inserting strings that contain some formatting
    ftf.test(0, 0, "2,2", 229007L);
    ftf.test(2, 0, "2,2", 22227L);
    ftf.test(3, 0, "2,2", 2222L);
    ftf.test(5, 0, "33,33", 22223333L);

    // test delete
    ftf.test(0, 0, DELETE, 2223333L);
    ftf.test(9, 0, DELETE, 2223333L);
    ftf.test(4, 0, DELETE, 222333L);
    ftf.test(4, 0, DELETE, 22233L);

    // test backspace
    ftf.test(0, 0, BACKSPACE, 22233L);
    ftf.test(6, 0, BACKSPACE, 2223L);
    ftf.test(2, 0, BACKSPACE, 223L);
    ftf.test(2, 0, BACKSPACE, 23L);

    // test replacing selection
    ftf.test(0, 1, "555", 5553L);
    ftf.test(3, 2, "555", 55555L);
    ftf.test(1, 3, "1", 5155L);
    ftf.test(2, 2, "6", 565L);
    ftf.test(0, 3, "111222333444555", 111222333444555L);

    // test deleting selection
    ftf.test(0, 2, DELETE, 1222333444555L);
    ftf.test(0, 3, BACKSPACE, 22333444555L);
    ftf.test(12, 2, DELETE, 223334445L);
    ftf.test(9, 2, BACKSPACE, 2233344L);
    ftf.test(3, 4, DELETE, 2244L);
    ftf.test(0, 4, BACKSPACE, 4L);
}
 
Example 14
Source File: Test6462562.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
void testIntegerFormat() {
    NumberFormat format = NumberFormat.getIntegerInstance(Locale.US);
    TestFormattedTextField ftf = create(format);
    ftf.setValue(56L);

    System.err.println("Testing NumberFormat.getIntegerInstance(Locale.US)");

    // test inserting individual characters
    ftf.test(0, 0, "1", 16L);
    ftf.test(2, 0, "2", 162L);
    ftf.test(1, 0, "0", 102L);

    // test inserting several characters at once - e.g. from clipboard
    ftf.test(0, 0, "1024", 1024L);
    ftf.test(3, 0, "333", 10333L);
    ftf.test(6, 0, "77", 1033377L);
    ftf.test(4, 0, "99", 1039977L);
    ftf.test(6, 0, "00", 1039007L);

    // test inserting strings that contain some formatting
    ftf.test(0, 0, "2,2", 229007L);
    ftf.test(2, 0, "2,2", 22227L);
    ftf.test(3, 0, "2,2", 2222L);
    ftf.test(5, 0, "33,33", 22223333L);

    // test delete
    ftf.test(0, 0, DELETE, 2223333L);
    ftf.test(9, 0, DELETE, 2223333L);
    ftf.test(4, 0, DELETE, 222333L);
    ftf.test(4, 0, DELETE, 22233L);

    // test backspace
    ftf.test(0, 0, BACKSPACE, 22233L);
    ftf.test(6, 0, BACKSPACE, 2223L);
    ftf.test(2, 0, BACKSPACE, 223L);
    ftf.test(2, 0, BACKSPACE, 23L);

    // test replacing selection
    ftf.test(0, 1, "555", 5553L);
    ftf.test(3, 2, "555", 55555L);
    ftf.test(1, 3, "1", 5155L);
    ftf.test(2, 2, "6", 565L);
    ftf.test(0, 3, "111222333444555", 111222333444555L);

    // test deleting selection
    ftf.test(0, 2, DELETE, 1222333444555L);
    ftf.test(0, 3, BACKSPACE, 22333444555L);
    ftf.test(12, 2, DELETE, 223334445L);
    ftf.test(9, 2, BACKSPACE, 2233344L);
    ftf.test(3, 4, DELETE, 2244L);
    ftf.test(0, 4, BACKSPACE, 4L);
}
 
Example 15
Source File: CallbackPanel.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public CallbackPanel(SectionView view, Node node, Binding binding, JaxWsModel jaxWsModel, WSDLModel serviceModel) {
    super(view);
    this.view = view;
    this.node = node;
    this.binding = binding;
    this.jaxwsmodel = jaxWsModel;
    this.serviceModel = serviceModel;

    cfgVersion = PolicyModelHelper.getConfigVersion(binding);

    FileObject fo = node.getLookup().lookup(FileObject.class);
    if (fo == null) {
        JAXWSLightSupport support = node.getLookup().lookup(JAXWSLightSupport.class);
        if (support != null) {
            fo = support.getWsdlFolder(false);
        }
    }
    if (fo != null) {
        project = FileOwnerQuery.getOwner(fo);
    } else {
        throw new IllegalArgumentException("Cannot find corresponding project: " + node);
    }

    this.wsitProvider = project.getLookup().lookup(WsitProvider.class);
    if (wsitProvider != null) {
        jsr109 = wsitProvider.isJsr109Project();
    }

    tstampff = new DefaultFormatterFactory();
    NumberFormat timestampFormat = NumberFormat.getIntegerInstance();
    timestampFormat.setGroupingUsed(false);
    timestampFormat.setParseIntegerOnly(true);
    timestampFormat.setMaximumIntegerDigits(8);
    timestampFormat.setMaximumFractionDigits(0);
    NumberFormatter timestampFormatter = new NumberFormatter(timestampFormat);
    timestampFormatter.setCommitsOnValidEdit(true);
    timestampFormatter.setMinimum(0);
    timestampFormatter.setMaximum(99999999);
    tstampff.setDefaultFormatter(timestampFormatter);

    initComponents();
    /* issue 232988: the background color issues with dark metal L&F
    samlHandlerField.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
    samlHandlerLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
    iterationLabel.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
    iterationField.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
    devDefaultsChBox.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
    cbTimestampLbl.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
    cbTimestampField.setBackground(SectionVisualTheme.getDocumentBackgroundColor());
    */
    cbTimestampField.setFocusLostBehavior(JFormattedTextField.COMMIT_OR_REVERT);

    inSync = true;
    credTypeCombo.removeAllItems();
    credTypeCombo.addItem(ComboConstants.STATIC);
    credTypeCombo.addItem(ComboConstants.DYNAMIC);
    inSync = false;

    addImmediateModifier(samlHandlerField);
    addImmediateModifier(credTypeCombo);
    addImmediateModifier(devDefaultsChBox);
    addImmediateModifier(cbTimestampField);
    addImmediateModifier(iterationField);
    
    sync();
}
 
Example 16
Source File: RSUPanel.java    From VanetSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor. Creating GUI items.
 */
public RSUPanel(){
	setLayout(new GridBagLayout());
	
	// global layout settings
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.anchor = GridBagConstraints.PAGE_START;
	c.weightx = 0.5;
	c.gridx = 0;
	c.gridy = 0;
	c.gridheight = 1;
	c.gridwidth = 2;
	
	// Radio buttons to select mode
	ButtonGroup group = new ButtonGroup();
	addRSU_ = new JRadioButton(Messages.getString("RSUPanel.addRSU")); //$NON-NLS-1$
	addRSU_.setActionCommand("addRSU"); //$NON-NLS-1$;
	addRSU_.setSelected(true);
	group.add(addRSU_);
	++c.gridy;
	add(addRSU_,c);
	addRSU_.addActionListener(this);
	
	deleteRSU_ = new JRadioButton(Messages.getString("RSUPanel.deleteRSU")); //$NON-NLS-1$
	deleteRSU_.setActionCommand("deleteRSU"); //$NON-NLS-1$
	group.add(deleteRSU_);
	++c.gridy;
	add(deleteRSU_,c);
	deleteRSU_.addActionListener(this);
	
	c.gridwidth = 1;
	c.insets = new Insets(5,5,5,5);
	
	//textfields
	c.gridx = 0;
	rsuLabel_ = new JLabel(Messages.getString("RSUPanel.radius")); //$NON-NLS-1$
	++c.gridy;
	add(rsuLabel_,c);		
	rsuRadius_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
	rsuRadius_.setValue(500);

	rsuRadius_.setPreferredSize(new Dimension(60,20));
	c.gridx = 1;
	add(rsuRadius_,c);
	
	c.gridx = 0;
	c.gridwidth = 2;
	++c.gridy;
	add(ButtonCreator.getJButton("deleteAll.png", "clearRSUs", Messages.getString("RSUPanel.btnClearRSUs"), this),c);
	
	deleteNote_ = new TextAreaLabel(Messages.getString("RSUPanel.noteDelete")); //$NON-NLS-1$
	++c.gridy;
	c.gridx = 0;
	add(deleteNote_, c);
	deleteNote_.setVisible(false);
	
	addNote_ = new TextAreaLabel(Messages.getString("RSUPanel.noteAdd")); //$NON-NLS-1$
	++c.gridy;
	c.gridx = 0;
	add(addNote_, c);
	addNote_.setVisible(true);
	
	
	//to consume the rest of the space
	c.weighty = 1.0;
	++c.gridy;
	JPanel space = new JPanel();
	space.setOpaque(false);
	add(space, c);
}
 
Example 17
Source File: EvolutionStatistics.java    From jenetics with Apache License 2.0 4 votes vote down vote up
private static String i(final long value) {
	final NumberFormat nf = NumberFormat.getIntegerInstance();
	return nf.format(value);
}
 
Example 18
Source File: SilentPeriodPanel.java    From VanetSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor, creating GUI items.
 */
public SilentPeriodPanel(){
	setLayout(new GridBagLayout());
	
	// global layout settings
	GridBagConstraints c = new GridBagConstraints();
	c.fill = GridBagConstraints.BOTH;
	c.anchor = GridBagConstraints.PAGE_START;
	c.weightx = 0.5;
	c.gridx = 0;
	c.gridy = 0;
	c.gridheight = 1;
	c.gridwidth = 2;
	
	
	c.gridwidth = 1;
	c.insets = new Insets(5,5,5,5);
	
	c.gridx = 0;
	silentPeriodDurationLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.duration")); //$NON-NLS-1$
	++c.gridy;
	add(silentPeriodDurationLabel_,c);		
	silentPeriodDuration_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
	silentPeriodDuration_.setValue(3000);

	silentPeriodDuration_.setPreferredSize(new Dimension(60,20));
	c.gridx = 1;
	silentPeriodDuration_.addFocusListener(this);
	add(silentPeriodDuration_,c);
	
	c.gridx = 0;
	silentPeriodFrequencyLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.frequency")); //$NON-NLS-1$
	++c.gridy;
	add(silentPeriodFrequencyLabel_,c);		
	silentPeriodFrequency_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
	silentPeriodFrequency_.setValue(10000);

	silentPeriodFrequency_.setPreferredSize(new Dimension(60,20));
	c.gridx = 1;
	silentPeriodFrequency_.addFocusListener(this);
	add(silentPeriodFrequency_,c);
	
	c.gridx = 0;
	enableSilentPeriodsLabel_ = new JLabel(Messages.getString("SilentPeriodPanel.enable")); //$NON-NLS-1$
	++c.gridy;
	add(enableSilentPeriodsLabel_,c);		
	enableSilentPeriods_ = new JCheckBox();
	enableSilentPeriods_.setSelected(false);
	enableSilentPeriods_.setActionCommand("enableSilentPeriods"); //$NON-NLS-1$
	c.gridx = 1;
	enableSilentPeriods_.addFocusListener(this);
	add(enableSilentPeriods_,c);
	enableSilentPeriods_.addActionListener(this);	
	
	
	//to consume the rest of the space
	c.weighty = 1.0;
	++c.gridy;
	JPanel space = new JPanel();
	space.setOpaque(false);
	add(space, c);
}
 
Example 19
Source File: Test6462562.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
void testIntegerFormat() {
    NumberFormat format = NumberFormat.getIntegerInstance(Locale.US);
    TestFormattedTextField ftf = create(format);
    ftf.setValue(56L);

    System.err.println("Testing NumberFormat.getIntegerInstance(Locale.US)");

    // test inserting individual characters
    ftf.test(0, 0, "1", 16L);
    ftf.test(2, 0, "2", 162L);
    ftf.test(1, 0, "0", 102L);

    // test inserting several characters at once - e.g. from clipboard
    ftf.test(0, 0, "1024", 1024L);
    ftf.test(3, 0, "333", 10333L);
    ftf.test(6, 0, "77", 1033377L);
    ftf.test(4, 0, "99", 1039977L);
    ftf.test(6, 0, "00", 1039007L);

    // test inserting strings that contain some formatting
    ftf.test(0, 0, "2,2", 229007L);
    ftf.test(2, 0, "2,2", 22227L);
    ftf.test(3, 0, "2,2", 2222L);
    ftf.test(5, 0, "33,33", 22223333L);

    // test delete
    ftf.test(0, 0, DELETE, 2223333L);
    ftf.test(9, 0, DELETE, 2223333L);
    ftf.test(4, 0, DELETE, 222333L);
    ftf.test(4, 0, DELETE, 22233L);

    // test backspace
    ftf.test(0, 0, BACKSPACE, 22233L);
    ftf.test(6, 0, BACKSPACE, 2223L);
    ftf.test(2, 0, BACKSPACE, 223L);
    ftf.test(2, 0, BACKSPACE, 23L);

    // test replacing selection
    ftf.test(0, 1, "555", 5553L);
    ftf.test(3, 2, "555", 55555L);
    ftf.test(1, 3, "1", 5155L);
    ftf.test(2, 2, "6", 565L);
    ftf.test(0, 3, "111222333444555", 111222333444555L);

    // test deleting selection
    ftf.test(0, 2, DELETE, 1222333444555L);
    ftf.test(0, 3, BACKSPACE, 22333444555L);
    ftf.test(12, 2, DELETE, 223334445L);
    ftf.test(9, 2, BACKSPACE, 2233344L);
    ftf.test(3, 4, DELETE, 2244L);
    ftf.test(0, 4, BACKSPACE, 4L);
}
 
Example 20
Source File: DayOfMonthFieldPartitioner.java    From kite with Apache License 2.0 4 votes vote down vote up
public DayOfMonthFieldPartitioner(String sourceName, @Nullable String name) {
  super(sourceName, (name == null ? "day" : name), Calendar.DAY_OF_MONTH, 31);
  format = NumberFormat.getIntegerInstance();
  format.setMinimumIntegerDigits(2);
  format.setMaximumIntegerDigits(2);
}