Article View: borland.public.jbuilder.java.swing
Article #11005Re: jbuilder beginner question
From: Jonathan
Date: Fri, 16 Jul 1999 00:00
Date: Fri, 16 Jul 1999 00:00
66 lines
2136 bytes
2136 bytes
here is the code:
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Frame1 extends JFrame {
JTextField jTextField1 = new JTextField();
JTextArea jTextArea1 = new JTextArea();
public Frame1() {
try {
jbInit();
}
catch(Exception e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
Frame1 frame = new Frame1();
frame.setVisible(true);
}
private void jbInit() throws Exception {
setSize(300,300);
jTextField1.addKeyListener(new java.awt.event.KeyAdapter() {
public void keyPressed(KeyEvent e) {
jTextField1_keyPressed(e);
}
});
this.getContentPane().add(jTextField1, BorderLayout.NORTH);
this.getContentPane().add(jTextArea1, BorderLayout.CENTER);
}
void jTextField1_keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER){
jTextArea1.append(jTextField1.getText());
jTextField1.setText("");
}
}
}
Chitra Amarnath wrote in message <378E3080.473710C9@enterpriseworks.com>...
>Hi
>
>I am a beginner in Jbuilder. I am developing a java appication where I
>have a frame having panel embedded with a jTextField and jTextArea. What
>I am trying to do is whenever a user finished typing in the textfield
>and hit the return(enter) key I am trying to get the text from the
>textfield and append to the textarea.
>If I add a code like this jTextField.addActionListener(this) in the
>constructor class of the frame I am getting an error.
>
>I would really appreciate any help!
>Chitra
Technical Details
Message-ID:
<7mn93k$7nu12@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<378E3080.473710C9@enterpriseworks.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,dfa3b85fc0c64d53 X-Google-Attributes: gid111d45,public From: "Jonathan" <plaskowj@logica.com> Subject: Re: jbuilder beginner question Date: 1999/07/16 Message-ID: <7mn93k$7nu12@forums.borland.com> X-Deja-AN: 501717484 References: <378E3080.473710C9@enterpriseworks.com> Organization: Another Netscape Collabra Server User X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 Newsgroups: borland.public.jbuilder.java.swing