Java Code Examples for javax.swing.JFormattedTextField#addFocusListener()

The following examples show how to use javax.swing.JFormattedTextField#addFocusListener() . 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: ValueFormatter.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 7 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 2
Source File: FlatDatePickerUI.java    From FlatLaf with Apache License 2.0 5 votes vote down vote up
@Override
protected JFormattedTextField createEditor() {
	JFormattedTextField editor = new DefaultEditor( new DatePickerFormatterUIResource( datePicker.getLocale() ) );
	editor.setName( "dateField" );
	editor.setBorder( BorderFactory.createEmptyBorder() );
	editor.setOpaque( false );
	editor.addFocusListener( new FlatUIUtils.RepaintFocusListener( datePicker ) );
	return editor;
}
 
Example 3
Source File: ValueFormatter.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 4
Source File: ValueFormatter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 5
Source File: ValueFormatter.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 6
Source File: ValueFormatter.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 7
Source File: ValueFormatter.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 8
Source File: ValueFormatter.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 9
Source File: ValueFormatter.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 10
Source File: ValueFormatter.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 11
Source File: ValueFormatter.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 12
Source File: ValueFormatter.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 13
Source File: ValueFormatter.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 14
Source File: ValueFormatter.java    From JDKSourceCode1.8 with MIT License 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 15
Source File: ValueFormatter.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 16
Source File: ValueFormatter.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 17
Source File: ValueFormatter.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 18
Source File: ValueFormatter.java    From jdk1.8-source-analysis with Apache License 2.0 5 votes vote down vote up
static void init(int length, boolean hex, JFormattedTextField text) {
    ValueFormatter formatter = new ValueFormatter(length, hex);
    text.setColumns(length);
    text.setFormatterFactory(new DefaultFormatterFactory(formatter));
    text.setHorizontalAlignment(SwingConstants.RIGHT);
    text.setMinimumSize(text.getPreferredSize());
    text.addFocusListener(formatter);
}
 
Example 19
Source File: SlowPanel.java    From VanetSim with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Constructor, creating GUI items.
 */
public SlowPanel(){
	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;
	timeToPseudonymChangeLabel_ = new JLabel(Messages.getString("SlowPanel.timeToPseudonymChange")); //$NON-NLS-1$
	++c.gridy;
	add(timeToPseudonymChangeLabel_,c);		
	timeToPseudonymChange_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
	timeToPseudonymChange_.setValue(3000);

	timeToPseudonymChange_.setPreferredSize(new Dimension(60,20));
	c.gridx = 1;
	timeToPseudonymChange_.addFocusListener(this);
	add(timeToPseudonymChange_,c);
	
	c.gridx = 0;
	slowSpeedLimitLabel_ = new JLabel(Messages.getString("SlowPanel.speedLimit")); //$NON-NLS-1$
	++c.gridy;
	add(slowSpeedLimitLabel_,c);		
	slowSpeedLimit_ = new JFormattedTextField(NumberFormat.getIntegerInstance());
	slowSpeedLimit_.setValue(30);

	slowSpeedLimit_.setPreferredSize(new Dimension(60,20));
	c.gridx = 1;
	slowSpeedLimit_.addFocusListener(this);
	add(slowSpeedLimit_,c);
	
	c.gridx = 0;
	enableSlowLabel_ = new JLabel(Messages.getString("SlowPanel.enable")); //$NON-NLS-1$
	++c.gridy;
	add(enableSlowLabel_,c);		
	enableSlow_ = new JCheckBox();
	enableSlow_.setSelected(false);
	enableSlow_.setActionCommand("enableSlow"); //$NON-NLS-1$
	c.gridx = 1;
	enableSlow_.addFocusListener(this);
	add(enableSlow_,c);
	enableSlow_.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 20
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);
}