1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| comment = new JTextField();
comment.addKeyListener(new KeyListener() {
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode()== KeyEvent.VK_ENTER) {
j.setText("comment");
j.setVisible(true);
frame.getContentPane().add(j);
JLabel label1 = new JLabel("comment", 1);
JTextField textFeld = new JTextField(1);
label1.setLabelFor(textFeld);
contentPane.add(textFeld);
contentPane.add(label1);
;
}
}
@Override
public void keyTyped(KeyEvent e) {
// TODO Auto-generated method stub
}
@Override
public void keyReleased(KeyEvent e) {
// TODO Auto-generated method stub
}
}); |
Partager