Results 1 to 2 of 2
- 01-29-2009, 07:13 PM #1Member
- Join Date
- Jan 2009
- Rep Power
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.
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..
- 01-30-2009, 07:44 PM #2
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.
- By hungleon88 in forum AWT / SwingReplies: 4Last Post: 12-06-2008, 04:01 PM
- By kashifu in forum Advanced JavaReplies: 2Last Post: 06-27-2008, 05:25 PM
- By birdofprey in forum AWT / SwingReplies: 2Last Post: 04-09-2008, 02:08 PM
- By The Evil Genius in forum AWT / SwingReplies: 1Last Post: 03-17-2008, 02:01 AM
- By gary in forum New To JavaReplies: 4Last Post: 07-11-2007, 02:58 PM