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

The following examples show how to use javax.swing.JFormattedTextField#setToolTipText() . 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: DatePickerPanel.java    From java-photoslibrary with Apache License 2.0 6 votes vote down vote up
public DatePickerPanel() {
  super();
  setLayout(new GridLayout(1 /* rows */, 3 /* cols */));

  yearTextField = new JFormattedTextField();
  yearTextField.setToolTipText("Year (YYYY)");
  yearTextField.addActionListener(this);
  add(yearTextField);

  monthTextField = new JFormattedTextField();
  monthTextField.setToolTipText("Month (MM)");
  monthTextField.addActionListener(this);
  add(monthTextField);

  dayTextField = new JFormattedTextField();
  dayTextField.setToolTipText("Day (DD)");
  dayTextField.addActionListener(this);
  add(dayTextField);

  dateConsumers = new ArrayList<>();
}
 
Example 2
Source File: EditLogControlPanel.java    From VanetSim with GNU General Public License v3.0 6 votes vote down vote up
public void setFilePath(JFormattedTextField textField){
	//begin with creation of new file
	JFileChooser fc = new JFileChooser();
	//set directory and ".log" filter
	fc.setCurrentDirectory(new File(System.getProperty("user.dir")));
	fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
	fc.setFileFilter(logFileFilter_);
	
	int status = fc.showDialog(this, Messages.getString("EditLogControlPanel.approveButton"));
	
	if(status == JFileChooser.APPROVE_OPTION){
			textField.setValue(fc.getSelectedFile().getAbsolutePath());
			textField.setToolTipText(fc.getSelectedFile().getAbsolutePath());
			textField.setCaretPosition(textField.getText().length());
	}
}
 
Example 3
Source File: SharedFunctions.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
public static JFormattedTextField createDateField(JPanel pnl, String str, String tip) {
    SimpleDateFormat format = new SimpleDateFormat(DATE_FORMAT);
    JFormattedTextField txt = new JFormattedTextField(format);
    txt.setText(str);
    txt.setToolTipText(tip);
    pnl.add(txt);
    return txt;
}
 
Example 4
Source File: SwingTextFieldWidget.java    From atdl4j with MIT License 5 votes vote down vote up
@Override
public List< ? extends Component> createBrickComponents() {
  
  List<Component> components = new ArrayList<Component>();
  
// tooltip
     String tooltip = control.getTooltip();
     
     // label        
     if ( control.getLabel() != null ) {
         label = new JLabel();
         label.setName(getName()+"/label");
         label.setText(control.getLabel());
         if ( tooltip != null ) label.setToolTipText( tooltip );
     }
             
     // textField
     textField = new JFormattedTextField();
     textField.setName(getName()+"/text");
     
     // init value
     if ( ControlHelper.getInitValue( control, getAtdl4jOptions() ) != null )
         textField.setText( (String) ControlHelper.getInitValue( control, getAtdl4jOptions() ) );

     // tooltip
     if (tooltip != null) textField.setToolTipText(tooltip);

     if (label != null){
       components.add( label);
     }
     components.add( textField);

     textField.setPreferredSize(new Dimension(100, textField.getPreferredSize().height));
     
  return components;
}
 
Example 5
Source File: SliderWithTextBox.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
// <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
private void initComponents() {
    jCoordinateNameLabel = new javax.swing.JLabel();
    jXSlider = new javax.swing.JSlider();
    jFormattedTextField = new JFormattedTextField(formatter);
    jMinimumLabel = new javax.swing.JLabel();
    jMaximumLabel = new javax.swing.JLabel();

    jCoordinateNameLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    jCoordinateNameLabel.setText("coordinate");
    jCoordinateNameLabel.setToolTipText("Name");
    jCoordinateNameLabel.setAlignmentX(1.0F);
    jCoordinateNameLabel.setMaximumSize(new java.awt.Dimension(100, 14));
    jCoordinateNameLabel.setMinimumSize(new java.awt.Dimension(100, 14));
    jCoordinateNameLabel.setPreferredSize(new java.awt.Dimension(100, 14));

    setBorder(javax.swing.BorderFactory.createTitledBorder("Slider label"));
    setAlignmentY(0.0F);
    jXSlider.setMajorTickSpacing(20);
    jXSlider.setMinorTickSpacing(10);
    jXSlider.setToolTipText("Seek");
    jXSlider.setAlignmentX(0.0F);
    jXSlider.setMinimumSize(new java.awt.Dimension(50, 25));
    jXSlider.setPreferredSize(new java.awt.Dimension(50, 25));

    jFormattedTextField.setHorizontalAlignment(javax.swing.JTextField.TRAILING);
    jFormattedTextField.setText("-123.456");
    jFormattedTextField.setToolTipText("Current value");
    jFormattedTextField.setFont(new java.awt.Font("Tahoma", 0, 11));
    jFormattedTextField.setMinimumSize(new java.awt.Dimension(55, 19));
    jFormattedTextField.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            jFormattedTextFieldActionPerformed(evt);
        }
    });

    jMinimumLabel.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
    jMinimumLabel.setText("-123");
    jMinimumLabel.setToolTipText("Lower bound");
    jMinimumLabel.setFocusable(false);
    jMinimumLabel.setIconTextGap(0);
    jMinimumLabel.setMaximumSize(new java.awt.Dimension(30, 25));
    jMinimumLabel.setMinimumSize(new java.awt.Dimension(30, 25));
    jMinimumLabel.setPreferredSize(new java.awt.Dimension(30, 25));

    jMaximumLabel.setText("123");
    jMaximumLabel.setToolTipText("Upper bound");
    jMaximumLabel.setFocusable(false);
    jMaximumLabel.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
    jMaximumLabel.setIconTextGap(0);
    jMaximumLabel.setMaximumSize(new java.awt.Dimension(25, 25));
    jMaximumLabel.setMinimumSize(new java.awt.Dimension(25, 25));
    jMaximumLabel.setPreferredSize(new java.awt.Dimension(25, 25));

    org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
        .add(layout.createSequentialGroup()
            .add(jFormattedTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 55, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
            .add(jMinimumLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
            .add(jXSlider, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 122, Short.MAX_VALUE)
            .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
            .add(jMaximumLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
        .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
            .add(jMaximumLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .add(jFormattedTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            .add(jMinimumLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        .add(jXSlider, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 25, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
    );
}
 
Example 6
Source File: BasicDatePickerUI.java    From microba with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected void installComponents() {
	field = new JFormattedTextField(createFormatterFactory());
	field.setValue(peer.getDate());
	field.setFocusLostBehavior(peer.getFocusLostBehavior());
	field.setEditable(peer.isFieldEditable());
	field.setToolTipText(peer.getToolTipText());
	// button
	button = new JButton();
	button.setFocusable(false);
	button.setMargin(new Insets(0, 0, 0, 0));
	button.setToolTipText(peer.getToolTipText());

	setSimpeLook(false);
	// calendar
	calendarPane = new CalendarPane(peer.getStyle());
	calendarPane.setShowTodayButton(peer.isShowTodayButton());
	calendarPane.setFocusLostBehavior(JFormattedTextField.REVERT);
	calendarPane.setFocusCycleRoot(true);
	calendarPane.setBorder(BorderFactory.createEmptyBorder(1, 3, 0, 3));
	calendarPane.setStripTime(false);
	calendarPane.setLocale(peer.getLocale());
	calendarPane.setZone(peer.getZone());
	calendarPane.setFocusable(peer.isDropdownFocusable());
	calendarPane.setColorOverrideMap(peer.getColorOverrideMap());
	// popup
	popup = new JPopupMenu();
	popup.setLayout(new BorderLayout());
	popup.add(calendarPane, BorderLayout.CENTER);
	popup.setLightWeightPopupEnabled(true);
	// add
	peer.setLayout(new BorderLayout());

	switch (peer.getPickerStyle()) {
	case DatePicker.PICKER_STYLE_FIELD_AND_BUTTON:
		peer.add(field, BorderLayout.CENTER);
		peer.add(button, BorderLayout.EAST);
		break;
	case DatePicker.PICKER_STYLE_BUTTON:
		peer.add(button, BorderLayout.EAST);
		break;
	}

	peer.revalidate();
	peer.repaint();

	componentListener = new ComponentListener();

	button.addActionListener(componentListener);
	field.addPropertyChangeListener(componentListener);

	calendarPane.addPropertyChangeListener(componentListener);
	calendarPane.addCommitListener(componentListener);
	calendarPane.addActionListener(componentListener);

	peerDateChanged(peer.getDate());
}
 
Example 7
Source File: SwingTextFieldWidget.java    From atdl4j with MIT License 4 votes vote down vote up
public void createWidget(JPanel parent)
{
	// tooltip
	String tooltip = control.getTooltip();
	
	// label		
	if ( control.getLabel() != null ) {
		label = new JLabel();
		label.setName(getName()+"/label");
		label.setText(control.getLabel());
		if ( tooltip != null ) label.setToolTipText( tooltip );
	}
			
	// textField
	textField = new JFormattedTextField();
	textField.setName(getName()+"/text");
	
	// init value
	if ( ControlHelper.getInitValue( control, getAtdl4jOptions() ) != null )
		textField.setText( (String) ControlHelper.getInitValue( control, getAtdl4jOptions() ) );

	// tooltip
	if (tooltip != null) textField.setToolTipText(tooltip);

	if (label != null){
		wrapper = new JPanel(new GridBagLayout());
		GridBagConstraints c = new GridBagConstraints();
		c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;   
    c.gridwidth = 1;
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.insets = new Insets(0, 0, 0, 0);
    wrapper.add( label, c);
		c.gridx = 1;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 0, 0);
    wrapper.add( textField, c);
		parent.add(wrapper);
	}
	else {
		parent.add(textField);
	}

	textField.setPreferredSize(new Dimension(100, textField.getPreferredSize().height));
	textField.revalidate();
}