use of java.awt.event.KeyListener in project JMRI by JMRI.
the class BlockTableAction method additionalAddOption.
JPanel additionalAddOption() {
GridLayout additionLayout = new GridLayout(0, 2);
JPanel mainPanel = new JPanel();
mainPanel.setLayout(additionLayout);
mainPanel.add(new JLabel(Bundle.getMessage("BlockLengthColName")));
mainPanel.add(lengthField);
mainPanel.add(new JLabel(Bundle.getMessage("BlockCurveColName")));
mainPanel.add(cur);
mainPanel.add(new JLabel(" "));
mainPanel.add(checkPerm);
speeds = new JComboBox<String>();
speeds.setEditable(true);
for (int i = 0; i < speedList.size(); i++) {
speeds.addItem(speedList.get(i));
}
mainPanel.add(new JLabel(Bundle.getMessage("BlockSpeed")));
mainPanel.add(speeds);
//return displayList;
lengthField.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent keyEvent) {
}
@Override
public void keyReleased(KeyEvent keyEvent) {
String text = lengthField.getText();
if (!validateNumericalInput(text)) {
String msg = Bundle.getMessage("ShouldBeNumber", new Object[] { Bundle.getMessage("BlockLengthColName") });
jmri.InstanceManager.getDefault(jmri.UserPreferencesManager.class).showWarningMessage(Bundle.getMessage("ErrorTitle"), msg, getClassName(), "length", false, false);
}
}
@Override
public void keyTyped(KeyEvent keyEvent) {
}
});
return mainPanel;
}
use of java.awt.event.KeyListener in project knime-core by knime.
the class CSVFilesHistoryPanel method addChangeListener.
/**
* Adds a change listener to the panel that gets notified whenever the entered file name changes.
*
* @param cl a change listener
* @since 2.11
*/
public void addChangeListener(final ChangeListener cl) {
((JTextField) m_textBox.getEditor().getEditorComponent()).addKeyListener(new KeyListener() {
@Override
public void keyTyped(final KeyEvent e) {
}
@Override
public void keyReleased(final KeyEvent e) {
cl.stateChanged(new ChangeEvent(e.getSource()));
}
@Override
public void keyPressed(final KeyEvent e) {
}
});
m_textBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
cl.stateChanged(new ChangeEvent(e.getSource()));
}
});
}
use of java.awt.event.KeyListener in project Spark by igniterealtime.
the class HistoryTranscript method finished.
/**
* Set the layout settings
*/
public void finished() {
pageLeft.addActionListener(arg0 -> pageLeft());
pageRight.addActionListener(arg0 -> pageRight());
periodChooser.addActionListener(e -> handlePeriodChange(periods.get(periodChooser.getSelectedIndex())));
// add search text input
searchPanel.setLayout(new GridBagLayout());
navigatorPanel.setLayout(new GridBagLayout());
controlPanel.setLayout(new BorderLayout());
filterPanel.setLayout(new GridBagLayout());
mainPanel.setLayout(new BorderLayout());
// the list of periods
// periods.add(period_oneWeek);
// periods.add(period_threeWeeks);
periods.add(period_oneMonth);
periods.add(period_oneYear);
periods.add(period_noPeriod);
// get the default preferences for the search period
int index = getPeriodIndex(pref.getSearchPeriod(periods.get(0)));
for (String period : periods) {
periodChooser.addItem(Res.getString(period));
}
periodChooser.setToolTipText(Res.getString("message.search.page.timeperiod"));
pageCounter.setToolTipText(Res.getString("message.search.page.counter"));
pageRight.setToolTipText(Res.getString("message.search.page.right"));
pageLeft.setToolTipText(Res.getString("message.search.page.left"));
searchField.setText(Res.getString("message.search.for.history"));
searchField.setToolTipText(Res.getString("message.search.for.history"));
searchField.setForeground((Color) UIManager.get("TextField.lightforeground"));
searchPanel.add(vacardPanel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(1, 5, 1, 1), 0, 0));
filterPanel.add(periodChooser, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 5, 1, 1), 0, 0));
filterPanel.add(searchField, new GridBagConstraints(2, 0, GridBagConstraints.REMAINDER, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(1, 1, 6, 1), 0, 0));
navigatorPanel.add(pageLeft, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(1, 5, 1, 1), 0, 0));
navigatorPanel.add(pageCounter, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(1, 5, 1, 1), 0, 0));
navigatorPanel.add(pageRight, new GridBagConstraints(2, 0, GridBagConstraints.REMAINDER, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(1, 1, 6, 1), 0, 0));
controlPanel.add(filterPanel, BorderLayout.NORTH);
controlPanel.add(navigatorPanel, BorderLayout.SOUTH);
overTheTopPanel.setLayout(new BorderLayout());
overTheTopPanel.add(searchPanel, BorderLayout.NORTH);
overTheTopPanel.add(controlPanel, BorderLayout.SOUTH);
mainPanel.add(overTheTopPanel, BorderLayout.NORTH);
window.setEditorKit(new HTMLEditorKit() {
@Override
public ViewFactory getViewFactory() {
return new HTMLFactory() {
public View create(Element e) {
View v = super.create(e);
if (v instanceof InlineView) {
return new InlineView(e) {
public int getBreakWeight(int axis, float pos, float len) {
if (axis == View.X_AXIS) {
checkPainter();
int p0 = getStartOffset();
int p1 = getGlyphPainter().getBoundedPosition(this, p0, pos, len);
if (p1 == p0) {
// can't even fit a single character
return View.BadBreakWeight;
}
try {
// if the view contains line break char return forced break
if (getDocument().getText(p0, p1 - p0).indexOf(SEPARATOR) >= 0) {
return View.ForcedBreakWeight;
}
} catch (BadLocationException ex) {
// should never happen
}
}
return super.getBreakWeight(axis, pos, len);
}
public View breakView(int axis, int p0, float pos, float len) {
if (axis == View.X_AXIS) {
checkPainter();
int p1 = getGlyphPainter().getBoundedPosition(this, p0, pos, len);
try {
// if the view contains line break char break the view
int index = getDocument().getText(p0, p1 - p0).indexOf(SEPARATOR);
if (index >= 0) {
GlyphView v = (GlyphView) createFragment(p0, p0 + index + 1);
return v;
}
} catch (BadLocationException ex) {
// should never happen
}
}
return super.breakView(axis, p0, pos, len);
}
};
} else if (v instanceof javax.swing.text.html.ParagraphView) {
return new javax.swing.text.html.ParagraphView(e) {
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r) {
if (r == null) {
r = new SizeRequirements();
}
float pref = layoutPool.getPreferredSpan(axis);
float min = layoutPool.getMinimumSpan(axis);
r.minimum = (int) min;
r.preferred = Math.max(r.minimum, (int) pref);
r.maximum = Integer.MAX_VALUE;
r.alignment = 0.5f;
return r;
}
};
}
return v;
}
};
}
});
window.setBackground(Color.white);
pane.getVerticalScrollBar().setBlockIncrement(200);
pane.getVerticalScrollBar().setUnitIncrement(20);
mainPanel.add(pane, BorderLayout.CENTER);
frame.setIconImage(SparkRes.getImageIcon(SparkRes.HISTORY_16x16).getImage());
frame.getContentPane().setLayout(new BorderLayout());
frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
frame.pack();
frame.setSize(600, 400);
window.setCaretPosition(0);
window.requestFocus();
GraphicUtils.centerWindowOnScreen(frame);
frame.setVisible(true);
window.setEditable(false);
searchField.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
}
@Override
public void keyReleased(KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
searchQuery = searchField.getText();
TaskEngine.getInstance().schedule(transcriptTask, 10);
searchField.requestFocus();
focusFlag = true;
}
}
@Override
public void keyPressed(KeyEvent e) {
}
});
searchField.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) {
if (searchField.getText().equals(Res.getString("message.search.for.history"))) {
searchField.setText("");
}
searchField.setForeground((Color) UIManager.get("TextField.foreground"));
}
public void focusLost(FocusEvent e) {
searchField.setForeground((Color) UIManager.get("TextField.lightforeground"));
if (searchField.getText().length() <= 1) {
searchField.setText(Res.getString("message.search.for.history"));
}
}
});
// after initializing the period, we can load the history
isInitialized.set(true);
periodChooser.setSelectedIndex(index);
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
window.setText("");
}
@Override
public void windowClosed(WindowEvent e) {
frame.removeWindowListener(this);
frame.dispose();
transcriptTask.cancel();
searchPanel.remove(vacardPanel);
}
});
}
use of java.awt.event.KeyListener in project Spark by igniterealtime.
the class CoBrowser method tabSelected.
public void tabSelected() {
goButton = new RolloverButton(FastpathRes.getImageIcon(FastpathRes.PUSH_URL_16x16));
pushCurrentPageButton = new RolloverButton(FastpathRes.getImageIcon(FastpathRes.DOWNLOAD_16x16));
followMeButton = new JCheckBox(FpRes.getString("checkbox.allow.user.to.follow"), false);
followMeButton.setToolTipText(GraphicUtils.createToolTip(PUBLIC_TOOLTIP));
followMeButton.addActionListener(this);
final JPanel mainPanel = new JPanel();
browser = BrowserFactory.getBrowser();
browser.addBrowserListener(this);
mainPanel.setLayout(new BorderLayout());
mainPanel.add(browser, BorderLayout.CENTER);
urlField = new JTextField();
setLayout(new GridBagLayout());
backButton = new RolloverButton(FastpathRes.getImageIcon(FastpathRes.SMALL_PIN_BLUE));
backButton.setText(FpRes.getString("back"));
backButton.setToolTipText(GraphicUtils.createToolTip(FpRes.getString("tooltip.back.one.page")));
goButton.setToolTipText(GraphicUtils.createToolTip(FpRes.getString("tooltip.push.url")));
goButton.setText(FpRes.getString("go"));
pushCurrentPageButton.setToolTipText(GraphicUtils.createToolTip(FpRes.getString("tooltip.push.current.page")));
pushCurrentPageButton.setText(FpRes.getString("button.start.cobrowsing.session"));
load(getStartLocation());
buildUI();
add(mainPanel, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
urlField.addKeyListener(new KeyListener() {
public void keyPressed(KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
showSpecifiedPage();
}
}
public void keyReleased(KeyEvent e) {
}
public void keyTyped(KeyEvent e) {
}
});
followMeButton.setOpaque(false);
}
use of java.awt.event.KeyListener in project artisynth_core by artisynth.
the class ViewerManager method doAddViewer.
private void doAddViewer(GLViewer viewer) {
myViewers.add(viewer);
myPopupManagers.add(new PopupManager(viewer));
viewer.setSelectionEnabled(selectionEnabledP);
viewer.setSelectOnPress(selectOnPressP);
setMouseBindings(viewer, getMouseBindings());
viewer.getMouseHandler().setMouseWheelZoomScale(myMouseWheelZoomScale);
for (MouseInputListener l : myMouseListeners) {
viewer.addMouseInputListener(l);
}
for (KeyListener l : myKeyListeners) {
viewer.addKeyListener(l);
}
}
Aggregations