Results 1 to 2 of 2
  1. #1
    sumit1mca is offline Member
    Join Date
    Jan 2009
    Rep Power

    Default how to access jTextField of one JFrame1 from JFrame2 & Modify JTextField contents


    I have created a package with JFrame having Panel on it. On the panel i have created button "Tab" which will behave like Tab button. I also have a button which will act as input for alpbabets (a,b,c ... z) i.e. one character at a time per click of that button.

    This is working fine, if i modifying only one textField within that package, as i am reading text from the textField and then appending that TextField with old text from that TextField and adding new alphabet on per click of alphabet button.
    but, but..

    I have created another package within that project having another JFrame with panel and many jTextField on that panel. I want to use the already earlier created package and generalize the behaviour that it was showing with that package having a single textField, with the textField in the another created Package's TextField also. I had already imported the earlier package in new one.

    behavour should be like this.

    i should able to focus on each textField by clicking on Tab button created in earlier Package. when focus is on the textField i should able to append the text with new alphabets.

    i have attached an snapshot of crated page ... to make my problem more clear

    thanks in advance..
    Attached Thumbnails Attached Thumbnails how to access jTextField of one JFrame1 from JFrame2 & Modify JTextField contents-test.jpg  

  2. #2
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Rep Power


    So, you have two classes that extend JFrame.

    MyJFrame1 contains a JPanel, myJPanel1, with the buttons.

    You want to show myJPanel1 inside MyJFrame2.

    The secret is to move myJPanel1 into its own class, MyJPanel1. You can then use MyJPanel1 from both of your other classes.

    This is so simple, it sounds complicated. Just assume that it really is simple.

    This is one of the truly great features of Swing. You can create your own components and use them anywhere with almost no effort.

Similar Threads

  1. Got problem with JtextField
    By hungleon88 in forum AWT / Swing
    Replies: 4
    Last Post: 12-06-2008, 03:01 PM
  2. JtextField
    By kashifu in forum Advanced Java
    Replies: 2
    Last Post: 06-27-2008, 04:25 PM
  3. how to focus to another JTextfield?
    By birdofprey in forum AWT / Swing
    Replies: 2
    Last Post: 04-09-2008, 01:08 PM
  4. Using Columns With JTextField
    By The Evil Genius in forum AWT / Swing
    Replies: 1
    Last Post: 03-17-2008, 01:01 AM
  5. help with JTextfield
    By gary in forum New To Java
    Replies: 4
    Last Post: 07-11-2007, 01:58 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts