by Dinesh Thakur Category: Swing


import javax.swing.*;

import java.awt.*;
import java.awt.event.*;
public class KeyFrameJavaExample extends JFrame implements KeyListener
       private JLabel prmpt = new JLabel("Type Something in the TextBox");
       private JLabel OutPutLbl = new JLabel("Key Typed:");
       private JTextField TxtFld = new JTextField(10);
       public KeyFrameJavaExample()
             setTitle("Key Frame in Java Swing");
             setLayout(new BorderLayout());
             add(prmpt, BorderLayout.NORTH);
             add(TxtFld, BorderLayout.CENTER);
             add(OutPutLbl, BorderLayout.SOUTH);
             public void keyTyped(KeyEvent e)
                  char c = e.getKeyChar();
                  OutPutLbl.setText("Last Character you Typed : " + c);
                  public void keyPressed(KeyEvent e)
                     public void keyReleased(KeyEvent e)
                     public static void main(String[] args)
                                 KeyFrameJavaExample keyFrame = new KeyFrameJavaExample();
                                     final int WIDTH = 250;
                        final int HEIGHT = 100;
                                 keyFrame.setSize(WIDTH, HEIGHT);

Key Frame  in Java Swing Example

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.C.A, MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.

Related Articles