use of java.awt.event.MouseAdapter in project aerospike-client-java by aerospike.
the class GuiDisplay method initialize.
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frmAerospikeExamples = new JFrame();
frmAerospikeExamples.setTitle("Aerospike Java Client Examples");
frmAerospikeExamples.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frmAerospikeExamples.pack();
frmAerospikeExamples.getContentPane().setLayout(new BorderLayout(0, 0));
splitPane = new JSplitPane();
splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
frmAerospikeExamples.getContentPane().add(splitPane, BorderLayout.CENTER);
mainPanel = new JPanel();
splitPane.setLeftComponent(mainPanel);
mainPanel.setLayout(new BorderLayout(0, 0));
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
runButton = new JButton("Run");
runButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent ev) {
consoleTextArea.setText("");
run_selected_examples();
}
});
buttonPanel.add(runButton);
mainPanel.add(buttonPanel, BorderLayout.SOUTH);
exitButton = new JButton("Quit");
exitButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent arg0) {
Container Frame = exitButton.getParent();
do {
Frame = Frame.getParent();
} while (!(Frame instanceof JFrame));
((JFrame) Frame).dispose();
}
});
buttonPanel.add(exitButton);
sourceTextPane = new JTextArea();
sourceTextPane.setTabSize(2);
sourceTextPane.setEditable(false);
scrollPane = new JScrollPane(sourceTextPane);
scrollPane.setViewportBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null));
scrollPane.setPreferredSize(new Dimension(600, 100));
mainPanel.add(scrollPane, BorderLayout.CENTER);
connectionPanel = new JPanel();
connectionPanel.setLayout(new FlowLayout(FlowLayout.LEFT));
lblServerHost = new JLabel("Server Host");
connectionPanel.add(lblServerHost);
seedHostTextField = new JTextField();
seedHostTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
params.host = seedHostTextField.getText();
}
});
connectionPanel.add(seedHostTextField);
seedHostTextField.setColumns(10);
lblPort = new JLabel("Port");
connectionPanel.add(lblPort);
portTextField = new JTextField();
portTextField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent arg0) {
String newValue = namespaceTextField.getText();
if (newValue != null && newValue != "") {
try {
params.port = Integer.parseInt(newValue);
} catch (NumberFormatException ne) {
// ne.printStackTrace();
}
}
}
});
connectionPanel.add(portTextField);
portTextField.setColumns(4);
lblusername = new JLabel("User");
connectionPanel.add(lblusername);
usernameTextField = new JTextField();
usernameTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
params.user = usernameTextField.getText();
}
});
connectionPanel.add(usernameTextField);
usernameTextField.setColumns(8);
lblpassword = new JLabel("Password");
connectionPanel.add(lblpassword);
passwordTextField = new JPasswordField();
passwordTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
params.user = new String(passwordTextField.getPassword());
}
});
connectionPanel.add(passwordTextField);
passwordTextField.setColumns(8);
lblnameSpace = new JLabel("Namespace");
connectionPanel.add(lblnameSpace);
namespaceTextField = new JTextField();
namespaceTextField.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
params.namespace = namespaceTextField.getText();
}
});
connectionPanel.add(namespaceTextField);
namespaceTextField.setColumns(8);
lblSet = new JLabel("Set");
connectionPanel.add(lblSet);
txtSetTextfield = new JTextField();
txtSetTextfield.addKeyListener(new KeyAdapter() {
@Override
public void keyTyped(KeyEvent e) {
params.set = txtSetTextfield.getText();
}
});
connectionPanel.add(txtSetTextfield);
txtSetTextfield.setColumns(8);
mainPanel.add(connectionPanel, BorderLayout.NORTH);
examplePanel = new JPanel();
examplePanel.setLayout(new BoxLayout(examplePanel, BoxLayout.Y_AXIS));
exampleScrollPane = new JScrollPane(examplePanel);
mainPanel.add(exampleScrollPane, BorderLayout.WEST);
// init values
seedHostTextField.setText(params.host);
portTextField.setText(Integer.toString(params.port));
namespaceTextField.setText(params.namespace);
txtSetTextfield.setText(params.set);
// int width = 785;
int width = 1000;
int height = 180;
consoleTextArea = new JTextArea();
consoleTextArea.setSize(new Dimension(width, height));
consoleTextArea.setEditable(false);
consoleScrollPane = new JScrollPane(consoleTextArea);
consoleScrollPane.setPreferredSize(new Dimension(width, height));
consoleScrollPane.setSize(new Dimension(width, height));
splitPane.setRightComponent(consoleScrollPane);
buttonGroup = new ButtonGroup();
JRadioButton jrb;
for (String example : Main.getAllExampleNames()) {
jrb = new JRadioButton(example);
jrb.setActionCommand(example);
jrb.addActionListener(this);
buttonGroup.add(jrb);
examplePanel.add(jrb);
}
frmAerospikeExamples.pack();
}
use of java.awt.event.MouseAdapter in project cayenne by apache.
the class BaseGraphBuilder method addMouseListeners.
private void addMouseListeners() {
graph.addMouseListener(new MouseAdapter() {
@Override
public void mouseReleased(MouseEvent e) {
if (e.isPopupTrigger()) {
Object selected = graph.getSelectionCell();
if (selected != null && selected instanceof DefaultGraphCell) {
Object userObject = ((DefaultGraphCell) selected).getUserObject();
if (userObject instanceof EntityCellMetadata) {
showPopup(e.getPoint(), ((EntityCellMetadata) userObject).fetchEntity());
}
}
}
}
});
graph.addMouseWheelListener(e -> {
// limit scale
double scale = graph.getScale() / Math.pow(ZOOM_FACTOR, e.getWheelRotation());
scale = Math.max(scale, 0.1);
scale = Math.min(scale, 3);
graph.setScale(scale);
});
}
use of java.awt.event.MouseAdapter in project jPOS by jpos.
the class ISOMeter method createLogList.
public JComponent createLogList() {
final JList logList = new JList(parent.getLog());
JPanel A = new JPanel();
A.setLayout(new BorderLayout());
MouseListener mouseListener = new MouseAdapter() {
public void mouseClicked(MouseEvent e) {
ISOMsg m = (ISOMsg) logList.getSelectedValue();
if (m != null) {
JFrame f = new JFrame(parent.getSymbolicName() + ":" + m.toString());
ISOMsgPanel p = new ISOMsgPanel(m);
f.getContentPane().add(p);
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.pack();
f.show();
}
}
};
logList.addMouseListener(mouseListener);
logList.setPrototypeCellValue("9999 99999999 999999");
JScrollPane scrollPane = new JScrollPane(logList);
A.add(scrollPane, BorderLayout.CENTER);
return A;
}
use of java.awt.event.MouseAdapter in project knime-core by knime.
the class JSnippetPanel method initComponents.
private void initComponents() {
m_colList = new JList(new DefaultListModel());
m_colList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
m_colList.addKeyListener(new KeyAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void keyTyped(final KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
Object selected = m_colList.getSelectedValue();
if (selected != null) {
onSelectionInColumnList(selected);
}
}
}
});
m_colList.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 2) {
Object selected = m_colList.getSelectedValue();
if (selected != null) {
onSelectionInColumnList(selected);
}
}
}
});
m_colList.setCellRenderer(new ListRenderer());
m_flowVarsList = new JList(new DefaultListModel());
m_flowVarsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
// enable tooltip
m_flowVarsList.setToolTipText("");
m_flowVarsList.addKeyListener(new KeyAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void keyTyped(final KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
Object selected = m_flowVarsList.getSelectedValue();
if (selected != null) {
onSelectionInVariableList(selected);
}
}
}
});
m_flowVarsList.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 2) {
Object selected = m_flowVarsList.getSelectedValue();
if (selected != null) {
onSelectionInVariableList(selected);
}
}
}
});
m_flowVarsList.setCellRenderer(new FlowVariableListCellRenderer());
m_categories = new JComboBox(m_manipProvider.getCategories().toArray());
m_categories.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) {
JComboBox cb = (JComboBox) e.getSource();
String category = (String) cb.getSelectedItem();
updateManipulatorList(category);
}
});
m_manipulators = new JList(new DefaultListModel());
m_manipulators.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
m_manipulators.setCellRenderer(new ManipulatorListCellRenderer());
m_manipulators.addKeyListener(new KeyAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void keyTyped(final KeyEvent e) {
if (e.getKeyChar() == KeyEvent.VK_ENTER) {
Object selected = m_manipulators.getSelectedValue();
if (selected != null) {
onSelectionInManipulatorList(selected);
}
}
}
});
m_manipulators.addMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent e) {
if (e.getClickCount() == 2) {
Object selected = m_manipulators.getSelectedValue();
if (selected != null) {
onSelectionInManipulatorList(selected);
}
}
}
});
m_manipulators.addListSelectionListener(new ListSelectionListener() {
@Override
public void valueChanged(final ListSelectionEvent e) {
Object selected = m_manipulators.getSelectedValue();
if (selected != null) {
Manipulator manipulator = (Manipulator) selected;
m_description.setText(manipulator.getDescription());
m_description.setCaretPosition(0);
} else {
m_description.setText("");
}
}
});
HTMLEditorKit kit = new HTMLEditorKit();
StyleSheet css = new StyleSheet();
css.addRule("* { font-family: sans-serif; }");
kit.setStyleSheet(css);
m_description = new JTextPane();
m_description.setEditorKit(kit);
m_description.setEditable(false);
m_description.setBackground(getBackground());
updateManipulatorList(ManipulatorProvider.ALL_CATEGORY);
initSubComponents();
}
use of java.awt.event.MouseAdapter in project knime-core by knime.
the class TimeMissingValueHandlingNodeDialogPane method loadSettingsFrom.
/**
* {@inheritDoc}
*/
@Override
protected void loadSettingsFrom(final NodeSettingsRO settings, final DataTableSpec[] specs) throws NotConfigurableException {
m_searchableListModifier = m_searchableListPanel.update(specs[0]);
TimeMissingValueHandlingColSetting[] defaults = TimeMissingValueHandlingColSetting.loadMetaColSettings(settings, specs[0]);
TimeMissingValueHandlingColSetting[] individuals = TimeMissingValueHandlingColSetting.loadIndividualColSettings(settings, specs[0]);
m_defaultsPanel.removeAll();
for (int i = 0; i < defaults.length; i++) {
final TimeMissingValueHandlingPanel p = new TimeMissingValueHandlingPanel(defaults[i], (DataColumnSpec) null);
m_defaultsPanel.add(p);
}
m_individualsPanel.removeAll();
Set<String> invalidColumns = new LinkedHashSet<String>();
for (int i = 0; i < individuals.length; i++) {
String[] names = individuals[i].getNames();
ArrayList<DataColumnSpec> colSpecs = new ArrayList<DataColumnSpec>();
for (int j = 0; j < names.length; j++) {
final DataColumnSpec cspec = specs[0].getColumnSpec(names[j]);
if (cspec == null) {
LOGGER.debug("No such column in spec: " + names[j]);
DataColumnSpec createUnkownSpec = createUnkownSpec(names[j], individuals[i]);
colSpecs.add(createUnkownSpec);
invalidColumns.add(names[j]);
} else {
colSpecs.add(cspec);
}
}
if (!colSpecs.isEmpty()) {
names = new String[colSpecs.size()];
for (int j = 0; j < names.length; j++) {
names[j] = colSpecs.get(j).getName();
}
individuals[i].setNames(names);
markIncompatibleTypedColumns(individuals[i].getType(), colSpecs);
final TimeMissingValueHandlingPanel p = new TimeMissingValueHandlingPanel(individuals[i], colSpecs.toArray(new DataColumnSpec[0]));
p.registerMouseListener(new MouseAdapter() {
/**
* {@inheritDoc}
*/
@Override
public void mouseClicked(final MouseEvent me) {
selectColumns(p.getSettings());
}
});
addToIndividualPanel(p);
}
}
m_searchableListModifier.addInvalidColumns(invalidColumns.toArray(new String[invalidColumns.size()]));
m_individualsPanel.setPreferredSize(m_defaultsPanel.getPreferredSize());
checkButtonStatus();
}
Aggregations