textField to textField
Page 1 of 1
textField to textField
#1
Posted 16 March 2009 - 09:53 PM
Hii all,
In my application i have two frame in which one frame work as chat box and other frame work playing board. i want to cut -past the score from playing board to chat box. The class of both frame are in same package.
Can u tell me how i can cut,past, any printed data from one jtextfield of one frame to another jtextfield on other frame........plz suggest me or give me sample code..
In my application i have two frame in which one frame work as chat box and other frame work playing board. i want to cut -past the score from playing board to chat box. The class of both frame are in same package.
Can u tell me how i can cut,past, any printed data from one jtextfield of one frame to another jtextfield on other frame........plz suggest me or give me sample code..
#3
Posted 16 March 2009 - 10:10 PM
#4
Posted 16 March 2009 - 10:18 PM
Well, you would have something relative to the following.
Then, later in the program, when you want to copy the text over...
Hope this helps!
FirstFrame first = new FirstFrame(); SecondFrame second = new SecondFrame(); // The FirstFrame class is your chat window, which // will receive the text that you copied. // The SecondFrame class has a textfield that you want to // copy from eventually, correct? Look at the next codebox // to see a very basic sample of a SecondFrame class.
class SecondFrame extends JFrame
{
String textToCopy;
JTextField text;
//...constructors, other methods, etc.
public void setText()
{
textToCopy = text.getText(); //get the TextField text
}
public String getCopiedText()
{
return textToCopy;
}
}
Then, later in the program, when you want to copy the text over...
// recall back to the first codebox // TEXTFIELD is the place you want to set your text in. first.TEXTFIELD.setText( second.getCopiedText() );
Hope this helps!
This post has been edited by Locke: 16 March 2009 - 10:19 PM
#5
Posted 17 March 2009 - 10:16 AM
Locke, on 16 Mar, 2009 - 10:18 PM, said:
Well, you would have something relative to the following.
Then, later in the program, when you want to copy the text over...
Hope this helps!
FirstFrame first = new FirstFrame(); SecondFrame second = new SecondFrame(); // The FirstFrame class is your chat window, which // will receive the text that you copied. // The SecondFrame class has a textfield that you want to // copy from eventually, correct? Look at the next codebox // to see a very basic sample of a SecondFrame class.
class SecondFrame extends JFrame
{
String textToCopy;
JTextField text;
//...constructors, other methods, etc.
public void setText()
{
textToCopy = text.getText(); //get the TextField text
}
public String getCopiedText()
{
return textToCopy;
}
}
Then, later in the program, when you want to copy the text over...
// recall back to the first codebox // TEXTFIELD is the place you want to set your text in. first.TEXTFIELD.setText( second.getCopiedText() );
Hope this helps!
I also used serverFile in b/t these to frame so ..i thing the code should be modified .. can u tell me sample code for that so i can access the server and the data is jtextfile can print into server .
Page 1 of 1

Start a new topic
Add Reply





MultiQuote


| 


