use of java.awt.event.KeyListener in project sldeditor by robward-scisys.
the class WKTDialog method createUI.
/**
* Creates the ui.
*/
@SuppressWarnings("unchecked")
private void createUI() {
JPanel wktSelectionPanel = new JPanel();
getContentPane().add(wktSelectionPanel, BorderLayout.NORTH);
model = new WKTTypeComboBoxModel(WKTConversion.getWKTTypeData());
geometryTypeComboBox = new JComboBox<WKTType>(model);
geometryTypeComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
geometryTypeUpdated();
}
});
wktSelectionPanel.add(geometryTypeComboBox);
JPanel buttonPanel = new JPanel();
FlowLayout flowLayout = (FlowLayout) buttonPanel.getLayout();
flowLayout.setAlignment(FlowLayout.RIGHT);
getContentPane().add(buttonPanel, BorderLayout.SOUTH);
JButton btnOk = new JButton(Localisation.getString(WKTDialog.class, "common.ok"));
btnOk.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = true;
setVisible(false);
}
});
buttonPanel.add(btnOk);
JButton btnCancel = new JButton(Localisation.getString(WKTDialog.class, "common.cancel"));
btnCancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
okButtonPressed = false;
setVisible(false);
}
});
buttonPanel.add(btnCancel);
JPanel mainPanel = new JPanel();
getContentPane().add(mainPanel, BorderLayout.CENTER);
mainPanel.setLayout(new BorderLayout(0, 0));
JPanel panel = new JPanel();
BoxLayout boxLayout = new BoxLayout(panel, BoxLayout.X_AXIS);
panel.setLayout(boxLayout);
mainPanel.add(panel, BorderLayout.WEST);
//
// Multi shape panel
//
createMultiShapePanel(panel);
panel.add(Box.createRigidArea(new Dimension(5, 0)));
//
// Segment panel
//
createSegmentPanel(panel);
panel.add(Box.createRigidArea(new Dimension(5, 0)));
//
// Coordinate panel
//
createPointPanel(panel);
//
// Text area
//
JPanel stringPanel = new JPanel();
mainPanel.add(stringPanel, BorderLayout.SOUTH);
stringPanel.setLayout(new BorderLayout(0, 0));
JScrollPane textAreaScrollPane = new JScrollPane();
stringPanel.add(textAreaScrollPane);
wktTextArea = new JTextArea();
wktTextArea.setRows(5);
wktTextArea.setEditable(true);
wktTextArea.addKeyListener(new KeyListener() {
@Override
public void keyTyped(KeyEvent e) {
btnReload.setEnabled(true);
}
@Override
public void keyPressed(KeyEvent e) {
// Do nothing
}
@Override
public void keyReleased(KeyEvent e) {
// Do nothing
}
});
textAreaScrollPane.setViewportView(wktTextArea);
JPanel textAreaButtonPanel = new JPanel();
stringPanel.add(textAreaButtonPanel, BorderLayout.EAST);
btnReload = new JButton(Localisation.getString(WKTDialog.class, "WKTDialog.reload"));
btnReload.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
reload();
}
});
textAreaButtonPanel.add(btnReload);
this.setSize(520, 365);
}
use of java.awt.event.KeyListener in project cytoscape-impl by cytoscape.
the class ImportTablePanel method initComponents.
private void initComponents() {
attrTypeButtonGroup = new ButtonGroup();
nodeRadioButton = new JRadioButton("Node");
edgeRadioButton = new JRadioButton("Edge");
networkRadioButton = new JRadioButton("Network");
ontologyComboBox = new JComboBox<>();
browseOntologyButton = new JButton("Browse...");
annotationComboBox = new JComboBox<>();
browseAnnotationButton = new JButton("Browse...");
targetDataSourceTextField = new JTextField();
selectAttributeFileButton = new JButton();
mappingAttributeComboBox = new JComboBox<>();
delimiterLabel = new JLabel("Delimiter:");
delimiterLabel.setHorizontalAlignment(JLabel.RIGHT);
commaCheckBox = new JCheckBox("<html><b><font size=+1 face=Monospaced>,<font></b> <font size=-2>(comma)</font><html>");
semicolonCheckBox = new JCheckBox("<html><b><font size=+1 face=Monospaced>;<font></b> <font size=-2>(semicolon)</font><html>");
spaceCheckBox = new JCheckBox("<html><b><font size=-1 face=Monospaced>SPACE<font></b><html>");
tabCheckBox = new JCheckBox("<html><b><font size=-1 face=Monospaced>TAB<font></b><html>");
otherCheckBox = new JCheckBox("Other:");
otherDelimiterTextField = new JTextField();
defaultInteractionTextField = new JTextField();
attributeFileLabel = new JLabel();
attrTypeButtonGroup.add(nodeRadioButton);
attrTypeButtonGroup.add(edgeRadioButton);
attrTypeButtonGroup.add(networkRadioButton);
/*
* Set tooltips options.
*/
ToolTipManager tp = ToolTipManager.sharedInstance();
tp.setInitialDelay(40);
tp.setDismissDelay(50000);
if (importType == ONTOLOGY_IMPORT) {
/*
* Data Source Panel Layouts.
*/
nodeRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
nodeRadioButton.setMargin(new Insets(0, 0, 0, 0));
nodeRadioButton.setSelected(true);
nodeRadioButton.addActionListener((ActionEvent evt) -> {
attributeRadioButtonActionPerformed(evt);
});
edgeRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
edgeRadioButton.setMargin(new Insets(0, 0, 0, 0));
edgeRadioButton.addActionListener((ActionEvent evt) -> {
attributeRadioButtonActionPerformed(evt);
});
networkRadioButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
networkRadioButton.setMargin(new Insets(0, 0, 0, 0));
networkRadioButton.addActionListener((ActionEvent evt) -> {
attributeRadioButtonActionPerformed(evt);
});
}
if (importType == ONTOLOGY_IMPORT) {
panelBuilder = new OntologyPanelBuilder(this, factory, serviceRegistrar);
panelBuilder.buildPanel();
}
if ((importType == TABLE_IMPORT) || (importType == NETWORK_IMPORT)) {
// titleIconLabel.setIcon(SPREADSHEET_ICON_LARGE.getIcon());
attributeFileLabel.setText("Input File");
selectAttributeFileButton.setText("Select File(s)");
selectAttributeFileButton.addActionListener((ActionEvent evt) -> {
try {
setPreviewPanel();
} catch (Exception e) {
JOptionPane.showMessageDialog(serviceRegistrar.getService(CySwingApplication.class).getJFrame(), "<html>Could not read selected file.<p>See <b>Help->Error Dialog</b> for further details.</html>", "Error", JOptionPane.ERROR_MESSAGE);
logger.warn("Could not read selected file.", e);
}
});
}
/*
* Layout data for advanced panel
*/
if (importType == ONTOLOGY_IMPORT) {
mappingAttributeComboBox.setEnabled(true);
mappingAttributeComboBox.addActionListener((ActionEvent evt) -> {
updateTypes(getPreviewPanel().getFileType());
setKeyList();
});
}
final ChangeListener delimitersChangeListener = new ChangeListener() {
@Override
public void stateChanged(ChangeEvent evt) {
otherDelimiterTextField.setEnabled(otherCheckBox.isSelected());
try {
if (!updating)
updatePreview();
} catch (IOException e) {
logger.error("Error on ChangeEvent of checkbox " + ((JCheckBox) evt.getSource()).getText(), e);
}
}
};
commaCheckBox.addChangeListener(delimitersChangeListener);
semicolonCheckBox.addChangeListener(delimitersChangeListener);
spaceCheckBox.addChangeListener(delimitersChangeListener);
tabCheckBox.addChangeListener(delimitersChangeListener);
otherCheckBox.addChangeListener(delimitersChangeListener);
otherDelimiterTextField.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent evt) {
}
@Override
public void keyReleased(KeyEvent evt) {
try {
if (otherCheckBox.isSelected())
updatePreview();
} catch (IOException e) {
logger.error("Error on otherDelimiterTextField.keyReleased", e);
}
}
@Override
public void keyTyped(KeyEvent evt) {
}
});
defaultInteractionTextField.setText(TypeUtil.DEFAULT_INTERACTION);
defaultInteractionTextField.setToolTipText("<html>If <b>Default Interaction</b>" + " is selected, this value will be used for <i>Interaction Type</i><br></html>");
globalLayout();
if (basicPanel != null)
basicPanel.repaint();
this.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
getPreviewPanel().disposeEditDialog();
}
});
}
use of java.awt.event.KeyListener in project SeqMonk by s-andrews.
the class SmoothingSubtractionQuantitation method getOptionsPanel.
/* (non-Javadoc)
* @see uk.ac.babraham.SeqMonk.Quantitation.Quantitation#getOptionsPanel(uk.ac.babraham.SeqMonk.SeqMonkApplication)
*/
public JPanel getOptionsPanel() {
if (optionPanel != null) {
// We've done this already
return optionPanel;
}
optionPanel = new JPanel();
optionPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 0.5;
gbc.weighty = 0.1;
gbc.fill = GridBagConstraints.HORIZONTAL;
optionPanel.add(new JLabel("Smoothing method"), gbc);
gbc.gridx = 2;
correctionActions = new JComboBox(new String[] { "Adjacent Probes", "Window Size" });
optionPanel.add(correctionActions, gbc);
gbc.gridx = 1;
gbc.gridy++;
optionPanel.add(new JLabel("Size"), gbc);
distanceField = new JTextField("" + distance);
distanceField.addKeyListener(new NumberKeyListener(false, false));
distanceField.addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent arg0) {
}
public void keyReleased(KeyEvent arg0) {
optionsChanged();
}
public void keyPressed(KeyEvent arg0) {
}
});
gbc.gridx++;
optionPanel.add(distanceField, gbc);
return optionPanel;
}
use of java.awt.event.KeyListener in project SeqMonk by s-andrews.
the class LogTransformQuantitation method getOptionsPanel.
/* (non-Javadoc)
* @see uk.ac.babraham.SeqMonk.Quantitation.Quantitation#getOptionsPanel(uk.ac.babraham.SeqMonk.SeqMonkApplication)
*/
public JPanel getOptionsPanel() {
if (optionPanel != null) {
// We've done this already
return optionPanel;
}
optionPanel = new JPanel();
optionPanel.setLayout(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 1;
gbc.gridy = 1;
gbc.weightx = 0.5;
gbc.weighty = 0.1;
gbc.fill = GridBagConstraints.HORIZONTAL;
optionPanel.add(new JLabel("Log Base "), gbc);
gbc.gridx = 2;
logBaseField = new JTextField("" + logBase);
logBaseField.addKeyListener(new NumberKeyListener(true, false));
logBaseField.addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent arg0) {
}
public void keyReleased(KeyEvent arg0) {
optionsChanged();
}
public void keyPressed(KeyEvent arg0) {
}
});
optionPanel.add(logBaseField, gbc);
gbc.gridx = 1;
gbc.gridy++;
optionPanel.add(new JLabel("Threshold "), gbc);
thresholdField = new JTextField("" + threshold);
thresholdField.addKeyListener(new NumberKeyListener(true, false));
thresholdField.addKeyListener(new KeyListener() {
public void keyTyped(KeyEvent arg0) {
}
public void keyReleased(KeyEvent arg0) {
optionsChanged();
}
public void keyPressed(KeyEvent arg0) {
}
});
gbc.gridx++;
optionPanel.add(thresholdField, gbc);
return optionPanel;
}
use of java.awt.event.KeyListener in project com.revolsys.open by revolsys.
the class ValueField method showDialog.
@SuppressWarnings("unchecked")
public <V> V showDialog(final Component parent) {
Window window;
if (parent == null) {
window = SwingUtil.getActiveWindow();
} else if (parent instanceof Window) {
window = (Window) parent;
} else {
window = SwingUtilities.windowForComponent(parent);
}
final JDialog dialog = new JDialog(window, this.title, ModalityType.APPLICATION_MODAL);
if (this.iconImage != null) {
dialog.setIconImage(this.iconImage);
}
dialog.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
dialog.setLayout(new BorderLayout());
dialog.addKeyListener(new KeyListener() {
@Override
public void keyPressed(final KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ESCAPE) {
cancel(dialog);
} else if (e.getKeyCode() == KeyEvent.VK_ENTER) {
save(dialog);
}
}
@Override
public void keyReleased(final KeyEvent e) {
}
@Override
public void keyTyped(final KeyEvent e) {
}
});
dialog.add(this, BorderLayout.CENTER);
final JRootPane rootPane = dialog.getRootPane();
final InputMap inputMap = rootPane.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
final ActionMap actionMap = rootPane.getActionMap();
final JPanel buttons = new JPanel(new FlowLayout(FlowLayout.RIGHT));
final Runnable cancelRunnable = () -> cancel(dialog);
buttons.add(RunnableAction.newButton("Cancel", cancelRunnable));
final KeyStroke escapeStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0);
inputMap.put(escapeStroke, "cancel");
actionMap.put("cancel", new RunnableAction(cancelRunnable));
final Runnable saveRunnable = () -> save(dialog);
buttons.add(RunnableAction.newButton("OK", saveRunnable));
dialog.add(buttons, BorderLayout.SOUTH);
final KeyStroke enterStroke = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
inputMap.put(enterStroke, "save");
actionMap.put("save", new RunnableAction(saveRunnable));
dialog.pack();
SwingUtil.autoAdjustPosition(window, dialog);
this.saved = false;
dialog.setVisible(true);
final V value = (V) getFieldValue();
SwingUtil.dispose(dialog);
return value;
}
Aggregations