Java Code Examples for javax.swing.JTextField#addMouseListener()

The following examples show how to use javax.swing.JTextField#addMouseListener() . These examples are extracted from open source projects. 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 Project: android-classyshark   File: Toolbar.java    License: Apache License 2.0 6 votes vote down vote up
private JTextField buildTypingArea() {
    final JTextField result = new JTextField(50);

    result.setEnabled(true);
    theme.applyTo(result);

    result.addMouseListener(new MouseAdapter() {

        @Override
        public void mouseReleased(MouseEvent e) {
            if (result.getSelectedText() != null) {
                String textToDelete = typingArea.getSelectedText();
                String selectedLine = result.getText().substring(0,
                        result.getText().lastIndexOf(textToDelete));

                result.setText(selectedLine);
                toolbarController.onChangedTextFromTypingArea(result.getText());
            }
        }
    });

    return result;
}
 
Example 2
/**
 * popup panel to create a playlist
 */
public String importPlayListPrompt() {
	final JTextField urlField = new JTextField();
	final GhostText gText = new GhostText("Enter service url", urlField);

	urlField.addMouseListener(new ContextMenuMouseListener());
	urlField.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(final MouseEvent e) {

		}
	});
	urlField.setHorizontalAlignment(SwingConstants.CENTER);
	gText.setHorizontalAlignment(SwingConstants.CENTER);

	final JPanel panel = new JPanel(new GridLayout(0, 1));

	panel.add(new JLabel("Enter a PlayList URL"));
	panel.add(urlField);
	final int result = JOptionPane.showConfirmDialog(null, panel,
			"Add to Service", JOptionPane.OK_CANCEL_OPTION,
			JOptionPane.PLAIN_MESSAGE);

	if (result == JOptionPane.OK_OPTION) {
		if (!urlField.getText().isEmpty()) {
			return urlField.getText();
		}
	} else {

	}
	return "";

}
 
Example 3
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 4
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 5
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 6
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 7
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 8
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 9
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 10
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 11
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 12
public WhoIsControl() {
	super();
	setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0));
	// top panel, start/cancel button and JTextField
	_whoIsButton = new JButton(GO_IMG);
	_whoIsButton.setToolTipText(Resources.getLabel("whois.button"));
	_hostIpTextField = new JTextField(17);
	_hostIpTextField.setText(Resources.getLabel("enter.whois"));

	final FirstInputListener listener = new FirstInputListener(_hostIpTextField);
	_hostIpTextField.addMouseListener(listener);
	_hostIpTextField.addKeyListener(listener);
	_hostIpTextField.setToolTipText(Resources.getLabel("enter.whois"));

	add(_hostIpTextField);
	add(_whoIsButton);
	// search button enable if text is not blank
	_hostIpTextField.addKeyListener(new KeyAdapter() {
		@Override
		public void keyReleased(final KeyEvent e) {
			_whoIsButton.setEnabled(!_hostIpTextField.getText().equals(""));
			if (e.getKeyCode() == KeyEvent.VK_ENTER) {
				_whoIsButton.getActionListeners()[0].actionPerformed(new ActionEvent(this, 0, "whois"));
			}
		}
	});
	// action of search/cancel trace route
	_whoIsButton.addActionListener(arg0 -> whois());

	_whoIsButton.setEnabled(false);
	_autocomplete = new AutoCompleteComponent(_hostIpTextField, _services.getAutocomplete());
}
 
Example 13
Source Project: hottub   File: TreePosTest.java    License: GNU General Public License v2.0 5 votes vote down vote up
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 14
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 15
/**
 * popup panel to add url to playlist
 */
public void additionToPlayListPrompt() {

	if ((Settings.getLastPlayList() == null)
			|| Settings.getLastPlayList().isEmpty()) {
		JOptionPane.showMessageDialog(new JFrame(),
				"You do not have any playlist loaded!", "Uh oh",
				JOptionPane.ERROR_MESSAGE);
		return;
	}

	final JTextField urlField = new JTextField();
	urlField.addMouseListener(new ContextMenuMouseListener());
	urlField.addMouseListener(new MouseAdapter() {
		@Override
		public void mouseClicked(final MouseEvent e) {

		}
	});
	new GhostText("https://www.youtube.com/watch?v=TU3b1qyEGsE", urlField);
	urlField.setHorizontalAlignment(SwingConstants.CENTER);
	final JPanel panel = new JPanel(new GridLayout(0, 1));

	panel.add(new JLabel("Paste media url"));
	panel.add(urlField);

	final int result = JOptionPane.showConfirmDialog(null, panel,
			"Add to Playlist", JOptionPane.OK_CANCEL_OPTION,
			JOptionPane.PLAIN_MESSAGE);

	if (result == JOptionPane.OK_OPTION) {
		addUrlToPlayList(urlField.getText());
	} else {

	}

}
 
Example 16
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 17
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 18
JTextField addListener(final JTextField f) {
    f.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            body.setCaretPosition(Integer.valueOf(f.getText()));
            body.getCaret().setVisible(true);
        }
    });
    return f;
}
 
Example 19
Source Project: opensim-gui   File: MeasurementSetPanel.java    License: Apache License 2.0 5 votes vote down vote up
public JComponent getMarkerComponent(final String name, final int measurementIndex, final int markerPairIndex, final int index) {
   Dimension dim = new Dimension(MARKER_NAME_WIDTH,HEIGHT);
   JTextField markerButton = new JTextField(name);
   markerButton.setEditable(false);
   markerButton.setHorizontalAlignment(SwingConstants.CENTER);
   // Indicate marker does not exist in model's marker set with red color (though the measurement may still be invalid
   // if this marker is not found in the marker data passed to the model scaler)
   boolean markerInModel = measurementSetModel.getMarkerExistsInModel(name);
   boolean markerInMeasurementTrial = measurementSetModel.getMarkerExistsInMeasurementTrial(name);
   if(!markerInModel || !markerInMeasurementTrial) {
      markerButton.setBackground(invalidColor);
      if(!markerInModel && !markerInMeasurementTrial) markerButton.setToolTipText("Marker not in model or measurement marker data!");
      else if(!markerInModel) markerButton.setToolTipText("Marker not in model!");
      else markerButton.setToolTipText("Marker not in measurement marker data!");
   } else {
      markerButton.setBackground(Color.white);
      markerButton.setToolTipText(null);
   }
   markerButton.setMinimumSize(dim);
   markerButton.setMaximumSize(dim);
   markerButton.setPreferredSize(dim);
   markerButton.setBorder(markerInnerBorder);
   markerButton.addMouseListener(new MouseAdapter() {
      public void mousePressed(MouseEvent evt) {
         JPopupMenu popup = new JPopupMenu();
         for(int i=0; i<markerNames.size(); i++) {
            JRadioButtonMenuItem item = new JRadioButtonMenuItem(new ChangeMarkerPairMarkerAction(markerNames.get(i), measurementIndex, markerPairIndex, index));
            if(markerNames.get(i).equals(name)) item.setSelected(true);
            popup.add(item);
         }
         popup.setLayout(new GridLayout(25,markerNames.size()/25+1));
         popup.show(evt.getComponent(),evt.getX(),evt.getY());
      }
   });

   return markerButton;
}
 
Example 20
public SnifferControl() {
	super();
	setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0));
	_hostIpTextField = new JTextField(17);
	_hostIpTextField.setText(Resources.getLabel("sniffer.host.tooltip"));
	final FirstInputListener listener = new FirstInputListener(_hostIpTextField);
	_hostIpTextField.addMouseListener(listener);
	_hostIpTextField.addKeyListener(listener);
	_hostIpTextField.setToolTipText(Resources.getLabel("sniffer.host.tooltip"));
	add(_hostIpTextField);

	final JLabel protocolLabel = new JLabel(Resources.getLabel("protocol.label"));
	protocolLabel.setToolTipText(Resources.getLabel("protocol.desc"));
	add(protocolLabel);
	for (final Protocol type : Protocol.values()) {
		if (type == Protocol.OTHER) {
			continue;
		}
		final JCheckBox check = new JCheckBox(type.name(), type == Protocol.TCP);
		_packets.put(type, check);
		add(check);
	}
	final JLabel portLabel = new JLabel(Resources.getLabel("port.label"));
	portLabel.setToolTipText(Resources.getLabel("port.desc"));
	_allPortCheck = new JCheckBox(Resources.getLabel("all.port.label"));
	_allPortCheck.setToolTipText(Resources.getLabel("all.port.desc"));
	_allPortCheck.setSelected(false);
	add(_allPortCheck);

	_portTF = new JFormattedTextField();
	_portTF.setText("80,443");
	_portTF.setColumns(15);
	//			_portTF.setMaximumSize(new Dimension(30, _portTF.getPreferredSize().height));
	add(portLabel);
	add(_portTF);
	_portTF.setEnabled(true);

	_allPortCheck.addChangeListener(e -> _portTF.setEnabled(!_allPortCheck.isSelected()));

	_filterPacketLengthCheck = new JCheckBox(Resources.getLabel("filter.length"));
	_filterPacketLengthCheck.setToolTipText(Resources.getLabel("filter.length.desc"));
	_filterPacketLengthCheck.setSelected(false);
	add(_filterPacketLengthCheck);

	_filterLengthTF = new JFormattedTextField(new NumberFormatterFactory());
	_filterLengthTF.setText("128");
	_filterLengthTF.setColumns(5);
	add(_filterLengthTF);

	_filterPacketLengthCheck.addChangeListener(e -> _filterLengthTF.setEnabled(_filterPacketLengthCheck.isEnabled() && _filterPacketLengthCheck.isSelected()));
	_capturePeriod = new JFormattedTextField(new NumberFormatterFactory());
	_capturePeriod.setText("0");
	_capturePeriod.setColumns(5);
	add(new JLabel(Resources.getLabel("capture.period")));
	add(_capturePeriod);

	_captureButton = new JButton(GO_IMG);
	_captureButton.setToolTipText(Resources.getLabel("capture.packet.start"));
	add(_captureButton);
	_captureButton.addActionListener(arg0 -> start());
}