java - adding jtextfield automatically record from corresponding jtextfield value -


my question when insert first name in jtextfield corresponding last name of record show automatically in jtextfield?

it means dont want insert same data again , again..once insert record in database next time same record inserted automatically in next form

so here give me snippet? in advance

@mirroredfate (to comments in answer here) never use keylistener, use documentlistener, there can determine possible users inputs types inside jtextcomponents

enter image description here

import java.awt.gridlayout; import javax.swing.*; import javax.swing.event.documentevent; import javax.swing.event.documentlistener;  public class textlabelmirror {      private jpanel mainpanel = new jpanel();     private jtextfield field = new jtextfield(20);     private jtextfield field1 = new jtextfield(20);      public textlabelmirror() {         field.getdocument().adddocumentlistener(new documentlistener() {              @override             public void changedupdate(documentevent e) {                 updatelabel(e);             }              @override             public void insertupdate(documentevent e) {                 updatelabel(e);             }              @override             public void removeupdate(documentevent e) {                 updatelabel(e);             }              private void updatelabel(documentevent e) {                 java.awt.eventqueue.invokelater(new runnable() {                      @override                     public void run() {                         field1.settext(field.gettext());                     }                 });             }         });          mainpanel.setlayout(new gridlayout(1, 0, 10, 0));         mainpanel.add(field);         mainpanel.add(field1);     }      public jcomponent getcomponent() {         return mainpanel;     }      private static void createandshowui() {         jframe frame = new jframe("textlabelmirror");         frame.getcontentpane().add(new textlabelmirror().getcomponent());         frame.setdefaultcloseoperation(jframe.exit_on_close);         frame.pack();         frame.setlocationrelativeto(null);         frame.setvisible(true);     }      public static void main(string[] args) {         java.awt.eventqueue.invokelater(new runnable() {              @override             public void run() {                 createandshowui();             }         });     } } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -