use of java.awt.event.FocusAdapter 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.FocusAdapter in project intellij-community by JetBrains.
the class DarculaComboBoxUI method createEditor.
@Override
protected ComboBoxEditor createEditor() {
final ComboBoxEditor comboBoxEditor = super.createEditor();
Component editor = comboBoxEditor == null ? null : comboBoxEditor.getEditorComponent();
if (editor instanceof JComponent) {
((JComponent) editor).setBorder(JBUI.Borders.empty());
}
if (editor != null) {
editor.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
process(e);
}
private void process(KeyEvent e) {
final int code = e.getKeyCode();
if ((code == KeyEvent.VK_UP || code == KeyEvent.VK_DOWN) && e.getModifiers() == 0) {
comboBox.dispatchEvent(e);
}
}
@Override
public void keyReleased(KeyEvent e) {
process(e);
}
});
editor.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
update();
}
void update() {
if (comboBox != null) {
comboBox.revalidate();
comboBox.repaint();
}
}
@Override
public void focusLost(FocusEvent e) {
update();
}
});
}
return comboBoxEditor;
}
use of java.awt.event.FocusAdapter in project intellij-community by JetBrains.
the class MacIntelliJComboBoxUI method createEditor.
@Override
protected ComboBoxEditor createEditor() {
final ComboBoxEditor comboBoxEditor = new BasicComboBoxEditor.UIResource() {
@Override
protected JTextField createEditorComponent() {
return new JTextField() {
{
setOpaque(false);
setBorder(ourDefaultEditorBorder);
}
@Override
public Color getBackground() {
if (!isEnabled()) {
return Gray.xF8;
}
return super.getBackground();
}
public void setText(String s) {
if (getText().equals(s)) {
return;
}
super.setText(s);
}
@Override
public void setBorder(Border border) {
}
@Override
public Border getBorder() {
return ourDefaultEditorBorder;
}
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
return new Dimension(size.width, DEFAULT_ICON.getIconHeight() - 6);
}
};
}
};
if (comboBoxEditor.getEditorComponent() != null) {
comboBoxEditor.getEditorComponent().addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) {
process(e);
}
@Override
public void keyReleased(KeyEvent e) {
process(e);
}
private void process(KeyEvent e) {
final int code = e.getKeyCode();
if ((code == KeyEvent.VK_UP || code == KeyEvent.VK_DOWN) && e.getModifiers() == 0) {
comboBox.dispatchEvent(e);
}
}
});
comboBoxEditor.getEditorComponent().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
update();
}
@Override
public void focusLost(FocusEvent e) {
update();
}
void update() {
if (comboBox != null) {
comboBox.revalidate();
comboBox.repaint();
}
}
});
}
return comboBoxEditor;
}
use of java.awt.event.FocusAdapter in project jgnash by ccavanaugh.
the class JTextFieldEx method installFocusListener.
/*public JTextFieldEx(final String text, final int columns) {
super(text, columns);
installFocusListener();
}
public JTextFieldEx(final Document doc, final String text, final int columns) {
super(doc, text, columns);
installFocusListener();
}*/
private void installFocusListener() {
FocusListener focusListener = new FocusAdapter() {
@Override
public void focusGained(final FocusEvent e) {
EventQueue.invokeLater(() -> {
if (isEditable() && JTextFieldEx.select) {
selectAll();
}
});
}
};
addFocusListener(focusListener);
}
use of java.awt.event.FocusAdapter in project jgnash by ccavanaugh.
the class SellSharePanel method registerListeners.
private void registerListeners() {
FocusListener focusListener = new FocusAdapter() {
@Override
public void focusLost(final FocusEvent evt) {
updateTotalField();
}
};
feePanel.addFocusListener(focusListener);
feePanel.addActionListener(this);
gainsPanel.addActionListener(this);
quantityField.addFocusListener(focusListener);
priceField.addFocusListener(focusListener);
datePanel.getDateField().addKeyListener(keyListener);
feePanel.addKeyListener(keyListener);
memoField.addKeyListener(keyListener);
priceField.addKeyListener(keyListener);
quantityField.addKeyListener(keyListener);
securityCombo.addKeyListener(keyListener);
getReconcileCheckBox().addKeyListener(keyListener);
}
Aggregations