use of java.awt.event.KeyEvent in project frostwire by frostwire.
the class SearchOptionsPanel method createNameFilter.
private LabeledTextField createNameFilter() {
LabeledTextField textField = new LabeledTextField(I18n.tr("Name|Source|Ext."), 80, -1, 240);
textField.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent e) {
textFieldKeywords_keyReleased();
}
});
return textField;
}
use of java.awt.event.KeyEvent in project jgnash by ccavanaugh.
the class AbstractTransactionEntryPanel method init.
private void init() {
amountField = new JFloatField(account.getCurrencyNode());
accountPanel = new AccountExchangePanel(account.getCurrencyNode(), account, amountField);
enterButton = new JButton(rb.getString("Button.Enter"));
cancelButton = new JButton(rb.getString("Button.Clear"));
memoField = AutoCompleteFactory.getMemoField();
reconciledButton = new IndeterminateCheckBox(rb.getString("Button.Reconciled"));
reconciledButton.setHorizontalTextPosition(SwingConstants.LEADING);
reconciledButton.setMargin(new Insets(0, 0, 0, 0));
/* Connect the buttons to the form */
cancelButton.addActionListener(this);
enterButton.addActionListener(this);
/* Allows the user to submit the form from the keyboard when the enter button is selected */
KeyAdapter enterKeyListener = new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
enterAction();
}
}
};
enterButton.addKeyListener(enterKeyListener);
amountField.addKeyListener(enterKeyListener);
// focus will return to the first field
setFocusCycleRoot(true);
}
use of java.awt.event.KeyEvent in project jgnash by ccavanaugh.
the class RecurringPanel method initComponents.
private void initComponents() {
JPanel toolPanel = new JPanel(new BorderLayout());
JToolBar toolBar = new JToolBar();
toolBar.setFloatable(false);
toolBar.setRollover(true);
newButton = new RollOverButton(rb.getString("Button.New"), IconUtils.getIcon("/jgnash/resource/document-new.png"));
modifyButton = new RollOverButton(rb.getString("Button.Modify"), IconUtils.getIcon("/jgnash/resource/document-properties.png"));
deleteButton = new RollOverButton(rb.getString("Button.Delete"), IconUtils.getIcon("/jgnash/resource/edit-delete.png"));
remindersButton = new RollOverButton(rb.getString("Button.CheckReminders"), IconUtils.getIcon("/jgnash/resource/view-refresh.png"));
reminderTable = new FormattedJTable();
reminderTable.setAutoCreateRowSorter(true);
reminderTable.setFillsViewportHeight(true);
reminderTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
reminderTable.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(final KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_DELETE) {
deleteReminder();
}
}
});
reminderTable.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 2) {
showModifyDialog();
}
}
});
setLayout(new BorderLayout());
toolBar.add(newButton);
toolBar.add(modifyButton);
toolBar.add(deleteButton);
toolBar.addSeparator();
toolBar.add(remindersButton);
toolPanel.add(toolBar, BorderLayout.NORTH);
toolPanel.add(new JSeparator(), BorderLayout.CENTER);
add(toolPanel, java.awt.BorderLayout.NORTH);
JScrollPane scrollPane = new JScrollPane();
scrollPane.setBorder(new EmptyBorder(new Insets(0, 0, 0, 0)));
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setAutoscrolls(true);
scrollPane.setViewportView(reminderTable);
add(scrollPane, java.awt.BorderLayout.CENTER);
deleteButton.addActionListener(this);
modifyButton.addActionListener(this);
newButton.addActionListener(this);
remindersButton.addActionListener(this);
}
use of java.awt.event.KeyEvent in project jabref by JabRef.
the class ManageKeywordsAction method createDialog.
private void createDialog() {
if (diag != null) {
return;
}
// keyword to add
JTextField keyword = new JTextField();
keywordListModel = new DefaultListModel<>();
JList<Keyword> keywordList = new JList<>(keywordListModel);
keywordList.setVisibleRowCount(8);
JScrollPane kPane = new JScrollPane(keywordList);
diag = new JDialog(frame, Localization.lang("Manage keywords"), true);
JButton ok = new JButton(Localization.lang("OK"));
JButton cancel = new JButton(Localization.lang("Cancel"));
JButton add = new JButton(Localization.lang("Add"));
JButton remove = new JButton(Localization.lang("Remove"));
keywordList.setVisibleRowCount(10);
intersectKeywords = new JRadioButton(Localization.lang("Display keywords appearing in ALL entries"));
mergeKeywords = new JRadioButton(Localization.lang("Display keywords appearing in ANY entry"));
ButtonGroup group = new ButtonGroup();
group.add(intersectKeywords);
group.add(mergeKeywords);
ActionListener stateChanged = e -> fillKeyWordList();
intersectKeywords.addActionListener(stateChanged);
mergeKeywords.addActionListener(stateChanged);
intersectKeywords.setSelected(true);
FormBuilder builder = FormBuilder.create().layout(new FormLayout("fill:200dlu:grow, 4dlu, fill:pref", "pref, 2dlu, pref, 1dlu, pref, 2dlu, fill:100dlu:grow, 4dlu, pref, 4dlu, pref, "));
builder.addSeparator(Localization.lang("Keywords of selected entries")).xyw(1, 1, 3);
builder.add(intersectKeywords).xyw(1, 3, 3);
builder.add(mergeKeywords).xyw(1, 5, 3);
builder.add(kPane).xywh(1, 7, 1, 3);
builder.add(remove).xy(3, 9);
builder.add(keyword).xy(1, 11);
builder.add(add).xy(3, 11);
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
bb.addButton(ok);
bb.addButton(cancel);
bb.addGlue();
builder.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
ok.addActionListener(e -> {
canceled = false;
diag.dispose();
});
Action cancelAction = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent e) {
canceled = true;
diag.dispose();
}
};
cancel.addActionListener(cancelAction);
final ActionListener addActionListener = arg0 -> addButtonActionListener(keyword);
add.addActionListener(addActionListener);
final ActionListener removeActionListenter = arg0 -> {
List<Keyword> values = keywordList.getSelectedValuesList();
for (Keyword val : values) {
keywordListModel.removeElement(val);
}
};
remove.addActionListener(removeActionListenter);
keywordList.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent arg0) {
// Do nothing
}
@Override
public void keyReleased(KeyEvent arg0) {
// Do nothing
}
@Override
public void keyPressed(KeyEvent arg0) {
if (arg0.getKeyCode() == KeyEvent.VK_DELETE) {
removeActionListenter.actionPerformed(null);
}
}
});
AutoCompleter<String> autoComp = JabRefGUI.getMainFrame().getCurrentBasePanel().getAutoCompleters().get(FieldName.KEYWORDS);
AutoCompleteListener acl = new AutoCompleteListener(autoComp);
keyword.addKeyListener(acl);
keyword.addFocusListener(acl);
keyword.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
// Do nothing
}
@Override
public void keyReleased(KeyEvent e) {
// Do nothing
}
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
addActionListener.actionPerformed(null);
}
}
});
// Key bindings:
ActionMap am = builder.getPanel().getActionMap();
InputMap im = builder.getPanel().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
am.put("close", cancelAction);
diag.getContentPane().add(builder.getPanel(), BorderLayout.CENTER);
diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
}
use of java.awt.event.KeyEvent in project JMRI by JMRI.
the class PanelEditor method init.
@Override
protected void init(String name) {
Runnable r = new Runnable() {
@Override
public void run() {
try {
// Build resource catalog and load CatalogTree.xml now
jmri.jmrit.catalog.CatalogPanel catalog = new jmri.jmrit.catalog.CatalogPanel();
catalog.createNewBranch("IFJAR", "Program Directory", "resources");
} catch (Exception ex) {
log.error("Error in trying to setup preferences " + ex.toString());
}
}
};
Thread thr = new Thread(r);
thr.start();
java.awt.Container contentPane = this.getContentPane();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.Y_AXIS));
// common items
JPanel common = new JPanel();
common.setLayout(new FlowLayout());
common.add(new JLabel(" x:"));
common.add(nextX);
common.add(new JLabel(" y:"));
common.add(nextY);
contentPane.add(common);
setAllEditable(true);
setShowHidden(true);
super.setTargetPanel(null, makeFrame(name));
super.setTargetPanelSize(400, 300);
super.setDefaultToolTip(new ToolTip(null, 0, 0, new Font("SansSerif", Font.PLAIN, 12), Color.black, new Color(215, 225, 255), Color.black));
// set scrollbar initial state
setScroll(SCROLL_BOTH);
// add menu - not using PanelMenu, because it now
// has other stuff in it?
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
menuBar.add(fileMenu);
fileMenu.add(new jmri.jmrit.display.NewPanelAction(Bundle.getMessage("MenuItemNew")));
fileMenu.add(new jmri.configurexml.StoreXmlUserAction(Bundle.getMessage("MenuItemStore")));
JMenuItem storeIndexItem = new JMenuItem(Bundle.getMessage("MIStoreImageIndex"));
fileMenu.add(storeIndexItem);
storeIndexItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
jmri.jmrit.catalog.ImageIndexEditor.storeImageIndex();
}
});
JMenuItem editItem = new JMenuItem(Bundle.getMessage("editIndexMenu"));
editItem.addActionListener(new ActionListener() {
PanelEditor panelEd;
@Override
public void actionPerformed(ActionEvent e) {
ImageIndexEditor ii = ImageIndexEditor.instance(panelEd);
ii.pack();
ii.setVisible(true);
}
ActionListener init(PanelEditor pe) {
panelEd = pe;
return this;
}
}.init(this));
fileMenu.add(editItem);
editItem = new JMenuItem(Bundle.getMessage("CPEView"));
fileMenu.add(editItem);
editItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
changeView("jmri.jmrit.display.controlPanelEditor.ControlPanelEditor");
}
});
fileMenu.addSeparator();
JMenuItem deleteItem = new JMenuItem(Bundle.getMessage("DeletePanel"));
fileMenu.add(deleteItem);
deleteItem.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
if (deletePanel()) {
dispose(true);
}
}
});
setJMenuBar(menuBar);
addHelpMenu("package.jmri.jmrit.display.PanelEditor", true);
// allow naming the panel
{
JPanel namep = new JPanel();
namep.setLayout(new FlowLayout());
JButton b = new JButton(Bundle.getMessage("ButtonSetName"));
b.addActionListener(new ActionListener() {
PanelEditor editor;
@Override
public void actionPerformed(ActionEvent e) {
// prompt for name
String newName = JOptionPane.showInputDialog(null, Bundle.getMessage("PromptNewName"));
if (newName == null) {
// cancelled
return;
}
if (jmri.jmrit.display.PanelMenu.instance().isPanelNameUsed(newName)) {
JOptionPane.showMessageDialog(null, Bundle.getMessage("CanNotRename"), Bundle.getMessage("PanelExist"), JOptionPane.ERROR_MESSAGE);
return;
}
if (getTargetPanel().getTopLevelAncestor() != null) {
((JFrame) getTargetPanel().getTopLevelAncestor()).setTitle(newName);
}
editor.setTitle();
jmri.jmrit.display.PanelMenu.instance().renameEditorPanel(editor);
}
ActionListener init(PanelEditor e) {
editor = e;
return this;
}
}.init(this));
namep.add(b);
this.getContentPane().add(namep);
}
// add a text label
{
JPanel panel = new JPanel();
panel.setLayout(new FlowLayout());
panel.add(labelAdd);
labelAdd.setEnabled(false);
labelAdd.setToolTipText(Bundle.getMessage("ToolTipWillActivate"));
panel.add(nextLabel);
labelAdd.addActionListener(new ActionListener() {
PanelEditor editor;
@Override
public void actionPerformed(ActionEvent a) {
editor.addLabel(nextLabel.getText());
}
ActionListener init(PanelEditor e) {
editor = e;
return this;
}
}.init(this));
nextLabel.addKeyListener(new KeyAdapter() {
@Override
public void keyReleased(KeyEvent a) {
if (nextLabel.getText().equals("")) {
labelAdd.setEnabled(false);
labelAdd.setToolTipText(Bundle.getMessage("ToolTipWillActivate"));
} else {
labelAdd.setEnabled(true);
labelAdd.setToolTipText(null);
}
}
});
this.getContentPane().add(panel);
}
// Selection of the type of entity for the icon to represent is done from a combobox
_addIconBox = new JComboBox<ComboBoxItem>();
_addIconBox.setMinimumSize(new Dimension(75, 75));
_addIconBox.setMaximumSize(new Dimension(200, 200));
_addIconBox.addItem(new ComboBoxItem("RightTurnout"));
_addIconBox.addItem(new ComboBoxItem("LeftTurnout"));
_addIconBox.addItem(new ComboBoxItem("SlipTOEditor"));
// NOI18N
_addIconBox.addItem(new ComboBoxItem("Sensor"));
_addIconBox.addItem(new ComboBoxItem("SignalHead"));
_addIconBox.addItem(new ComboBoxItem("SignalMast"));
_addIconBox.addItem(new ComboBoxItem("Memory"));
_addIconBox.addItem(new ComboBoxItem("BlockLabel"));
_addIconBox.addItem(new ComboBoxItem("Reporter"));
_addIconBox.addItem(new ComboBoxItem("Light"));
_addIconBox.addItem(new ComboBoxItem("Background"));
_addIconBox.addItem(new ComboBoxItem("MultiSensor"));
_addIconBox.addItem(new ComboBoxItem("RPSreporter"));
_addIconBox.addItem(new ComboBoxItem("FastClock"));
_addIconBox.addItem(new ComboBoxItem("Icon"));
_addIconBox.setSelectedIndex(-1);
// must be AFTER no selection is set
_addIconBox.addItemListener(this);
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS));
JPanel p2 = new JPanel();
p2.setLayout(new FlowLayout());
p2.add(new JLabel(Bundle.getMessage("selectTypeIcon")));
p1.add(p2);
p1.add(_addIconBox);
contentPane.add(p1);
// edit, position, control controls
{
// edit mode item
contentPane.add(editableBox);
editableBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
setAllEditable(editableBox.isSelected());
hiddenCheckBoxListener();
}
});
editableBox.setSelected(isEditable());
// positionable item
contentPane.add(positionableBox);
positionableBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
setAllPositionable(positionableBox.isSelected());
}
});
positionableBox.setSelected(allPositionable());
// controlable item
contentPane.add(controllingBox);
controllingBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
setAllControlling(controllingBox.isSelected());
}
});
controllingBox.setSelected(allControlling());
// hidden item
contentPane.add(hiddenBox);
hiddenCheckBoxListener();
hiddenBox.setSelected(showHidden());
/*
contentPane.add(showCoordinatesBox);
showCoordinatesBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
setShowCoordinates(showCoordinatesBox.isSelected());
}
});
showCoordinatesBox.setSelected(showCoordinates());
*/
contentPane.add(showTooltipBox);
showTooltipBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setAllShowTooltip(showTooltipBox.isSelected());
}
});
showTooltipBox.setSelected(showTooltip());
contentPane.add(menuBox);
menuBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setPanelMenuVisible(menuBox.isSelected());
}
});
menuBox.setSelected(true);
// Show/Hide Scroll Bars
JPanel scrollPanel = new JPanel();
scrollPanel.setLayout(new FlowLayout());
scrollableLabel.setLabelFor(scrollableComboBox);
scrollPanel.add(scrollableLabel);
scrollPanel.add(scrollableComboBox);
contentPane.add(scrollPanel);
scrollableComboBox.addItem(Bundle.getMessage("ScrollNone"));
scrollableComboBox.addItem(Bundle.getMessage("ScrollBoth"));
scrollableComboBox.addItem(Bundle.getMessage("ScrollHorizontal"));
scrollableComboBox.addItem(Bundle.getMessage("ScrollVertical"));
scrollableComboBox.setSelectedIndex(SCROLL_BOTH);
scrollableComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
setScroll(scrollableComboBox.getSelectedIndex());
}
});
}
// register the resulting panel for later configuration
ConfigureManager cm = InstanceManager.getNullableDefault(jmri.ConfigureManager.class);
if (cm != null) {
cm.registerUser(this);
}
// when this window closes, set contents of target uneditable
addWindowListener(new java.awt.event.WindowAdapter() {
HashMap<String, JFrameItem> iconAdderFrames;
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
Iterator<JFrameItem> iter = iconAdderFrames.values().iterator();
while (iter.hasNext()) {
JFrameItem frame = iter.next();
frame.dispose();
}
}
WindowAdapter init(HashMap<String, JFrameItem> f) {
iconAdderFrames = f;
return this;
}
}.init(_iconEditorFrame));
// and don't destroy the window
setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE);
// move this editor panel off the panel's position
getTargetFrame().setLocationRelativeTo(this);
getTargetFrame().pack();
getTargetFrame().setVisible(true);
log.debug("PanelEditor ctor done.");
}
Aggregations