how to move pointer in Textfield to newline

how to move pointer in Textfield to newline

consider my case and provide me solutions: import java.awt.; import java.awt.event.; class Table1 extends Frame implements ActionListener{ TextField tf1,tf2,tf3;

Table1(){
Label l1=new Label("WELCOME TO TABLE WIZARD");
l1.setBounds(100,10,200,30);


Label l2=new Label("Enter the value to get its Table");
l2.setBounds(100,50,200,20);

tf1=new TextField();
tf1.setBounds(100,80,200,20);

Label l3=new Label("Enter the till you want the table");
l3.setBounds(100,110,200,20);

tf2=new TextField();
tf2.setBounds(100,140,200,20);

Button b=new Button("click me");
b.setBounds(310,140,60,20);

Label l4=new Label("The Result is:");
l4.setBounds(100,170,200,20);

tf3=new TextField();
tf3.setBounds(100,200,200,200);
add(b);
b.addActionListener(this);
add(l1);
add(l2);
add(l3);
add(l4);
add(tf1);
add(tf2);
add(tf3);
setSize(400,600);
setLayout(null);
setVisible(true);
}
public void actionPerformed(ActionEvent a)
{
String s1=tf1.getText();
String s2=tf2.getText();
int a1=Integer.parseInt(s1);
int a2=Integer.parseInt(s2);

int c[]=new int[10];
for(int i=1;i<=a2;i++)
c[i]=a1*i;

String s3="",s4="",s5="";

s3=String.valueOf(a1);

for(int i=1;i<=a2;i++)
{
int a3=0;
s4=String.valueOf(i);
a3=c[i];
s5=s5+String.valueOf(a3);
tf3.setText("\n");
tf3.setText(s3+"X"+s4+"="+s5+"\n");
}
}
public static void main(String args[])
{
new Table1();
}
}
View Answers

June 7, 2012 at 1:42 PM

The given code accepts the two integer values from the user and display the multiplication table on to the textarea. Using the append() method of textarea, the value is easily added to the textarea.

 import java.awt.*;
    import java.awt.event.*;
    class Table1 extends Frame implements ActionListener{ 
                TextField tf1,tf2;
                TextArea area;

                Table1(){
                    Label l1=new Label("WELCOME TO TABLE WIZARD");
                    l1.setBounds(100,10,200,30);

                    Label l2=new Label("Enter the value to get its Table");
                    l2.setBounds(100,50,200,20);

                    tf1=new TextField();
                    tf1.setBounds(100,80,200,20);

                    Label l3=new Label("Enter the till you want the table");
                    l3.setBounds(100,110,200,20);

                    tf2=new TextField();
                    tf2.setBounds(100,140,200,20);

                    Button b=new Button("click me"); 
                    b.setBounds(310,140,60,20);

                    Label l4=new Label("The Result is:");
                    l4.setBounds(100,170,200,20);

                    area=new TextArea(10,20);
                    area.setBounds(100,200,200,200);
                    add(b);
                    b.addActionListener(this); 
                    add(l1); 
                    add(l2);
                    add(l3);
                    add(l4); 
                    add(tf1); 
                    add(tf2); 
                    add(area);
                    setSize(400,600); 
                    setLayout(null); 
                    setVisible(true);
                 } 
                    public void actionPerformed(ActionEvent a) {
                        String s1=tf1.getText(); 
                        String s2=tf2.getText();
                        int a1=Integer.parseInt(s1);
                        int a2=Integer.parseInt(s2);
                                   for(int i=1;i<=a2;i++) {
                                         System.out.println(a1+"*"+i+"="+(a1*i)); 
                                         area.append(a1+"*"+i+"="+(a1*i)); 
                                         area.append("\n");
                                       }
                    }
                   public static void main(String args[]) {
                       new Table1();
                } 
          }

June 7, 2012 at 6:00 PM

Thank you very much sir for this answer. actually i am developing the javap tool, in that this concept is applied. dear sir if you have any programs or like simple application source code that can be helpful for a java beginner please send me by mail.









Related Tutorials/Questions & Answers:
how to move pointer in Textfield to newline
how to move pointer in Textfield to newline  consider my case...; class Table1 extends Frame implements ActionListener{ TextField tf1,tf2,tf3..."); l2.setBounds(100,50,200,20); tf1=new TextField(); tf1.setBounds(100,80,200,20
how to move curosr from one text field to another automatically when the first textfield reaches its maximum length
how to move curosr from one text field to another automatically when the first textfield reaches its maximum length  how to move curosr from one text field to another automatically when the first textfield reaches its maximum
Advertisements
how can i remove newline characters and tabs
how can i remove newline characters and tabs   how can i remove newline characters and tabs ? but i wont to using GUI .please help
how to set the value of textfield constant
how to set the value of textfield constant  how to set the value of textfield constant
how to print dot in python without newline
how to print dot in python without newline  Hi, I a debugging... to print 20 dots without new line. Is there any easy solution? how to print dot in python without newline? Can I use variable to decide no of times dot
how to print dot in python without newline
? how to print dot in python without newline?ADS_TO_REPLACE_2 Can I use variable...how to print dot in python without newline  Hi, I a debugging python program and I am using following code to print dots: print
how to set size of button,textfield.
how to set size of button,textfield.  how we set size of button textfield etc and reduce problem when click maximize button the text or textfield get large how to set as a preferd size in the panel or frame .when we click
How to Type in japanese in java Textfield?
How to Type in japanese in java Textfield?  Hello Sir/madam; Am... in textfield ..Please help me and tell me how to write in japanese... user.User needs to type in japanese in the textField.but I dont know how to type
How to move a value in array?
How to move a value in array?   Enter value at the End: 5 Display...]5 Index at [3]8 and when i enter 0 in last index it will move and if i enter again zero in last index it will not move anymore... pls help..thank you
How to move a value in array?
How to move a value in array?   Enter value at the End: 5 Display...]5 Index at [3]8 and when i enter 0 in last index it will move and if i enter again zero in last index it will not move anymore... pls help..thank you
pointer
pointer  CONSTRTUCT A STRUCTURE FOR EMPLOYEE RECORD THAT CONTAINS A PERSON'S NAME, AGE, EMPLOYEE AND SALARY.WRITE A STATEMENT THAT DECLARES A VARIABLE empInfo and a pointer emPtr of type EMPLOYEE.then use the pointer to display
How to pass value of a link to a textfield
How to pass value of a link to a textfield  Dear Sir, in my project I'm initially making a value of the textfield as a link. Now, I want to pass the value of the link in the textfield after clicking the link and dont want to open
how to move label in jframe in java?
how to move label in jframe in java?  please any one can give me code for moving a java label in Jframe
how to move file in python script
how to move file in python script  Hi, In my Python program I have to move a file from one directory to another. What is the best way to move the file from one directory to another in Python? Thanks (adsbygoogle
how can u reduce the size of textfield?
how can u reduce the size of textfield?  how can u reduce the size of textfield? thanks in advance   import javax.swing.*; public class ReduceTextField extends JFrame { public static void main(String
print the newline
print the newline  Why doesn?t the following code print the newline properly? <?php $str = ?Hello, there.\nHow are you?\nThanks for visiting.?; print $str; ?>   Hi friends, Inside the single quotes \n (newline
TextField on the Image
TextField on the Image  how we set label or textfield etc. on the Image
How to move a file from a directory to other directory
How to move a file from a directory to other directory  I tried the above example it will move the folder to other directory but it does not move the image file or other file to a specified directory. Can anyone help me? Thanks
python replace newline with space
python replace newline with space  Hi, I want to replace newline character \n With space in python. How to replace newline with space in python? Thanks   Hi, Its easy in python. You can use the replace method
python replace newline with space
python replace newline with space  Hi, I want to replace newline character \n With space in python. How to replace newline with space in python? Thanks   Hi, Its easy in python. You can use the replace method
ModuleNotFoundError: No module named 'flake8-class-newline'
: No module named 'flake8-class-newline' How to remove the ModuleNotFoundError: No module named 'flake8-class-newline' error? Thanks   Hi...ModuleNotFoundError: No module named 'flake8-class-newline'  Hi
Java write newline
Java write newline       Following example demonstrates,  how to get newline feature... of abstract writer class. ADS_TO_REPLACE_1 In the example newLine feature
how to enable textfield in j2me netbeans when a choice element is selected?
how to enable textfield in j2me netbeans when a choice element is selected?  How to enable a textfield in j2me using netbeans when a choice element is selected and how to keep it disabled when any choice element corresponding
how to enable textfield in j2me netbeans when a choice element is selected?
how to enable textfield in j2me netbeans when a choice element is selected?  How to enable a textfield in j2me using netbeans when a choice element is selected and how to keep it disabled when any choice element corresponding
How To Move Image Smoothly
How To Move Image Smoothly       In this example you will see how to move image smoothly on mouse motion using Java.  To move an image, we have used the Listener interface
print without newline in python
print without newline in python  Hi, I have a Python program...") But the output is coming in new lines. I want to know how to print without newline in python? Thanks   Hi, You can use following code
print without newline in python
print without newline in python  Hi, I have a Python program... ") print("Python") But the output is coming in new lines. I want to know how to print without newline in python? Thanks   Hi,ADS_TO_REPLACE_2
TextField validations
TextField validations  I want to know How to check first letter capital or not in a text field and also check all are characters or not in same textfield? and also want to know how to check all digits or not in a textfield? ex
How to put Focus on TextField - Design concepts & design patterns
How to put Focus on TextField  Dear Sir..... Once again, I am here for your help, Since, I am making a project, just for my own sake so that I can... on my TextField of the latter Window.... Hoping you can help me
Pointer a variable
Pointer a variable  hii, Pointer is a variable or not ?   hello,ADS_TO_REPLACE_1 Yes, a pointer is a variable
pointer error java
pointer error java  How to catch null pointer errors in java if the if(value != null) or null
is there is pointer in java or not??
is there is pointer in java or not??  is there is pointer in java or not plz tell me this with brief?? thank you
TextField
TextField      ... as the TextField. In the example given below, shown a textfield in the applet by creating its...;new TextField("Type in the box");    
null pointer
null pointer  dear sir , what is mean by null pointer in c
ModuleNotFoundError: No module named 'pointer'
'pointer' How to remove the ModuleNotFoundError: No module named 'pointer...ModuleNotFoundError: No module named 'pointer'  Hi, My Python... to install padas library. You can install pointer python with following command
textfield selected text
textfield selected text  How to select text in text field
TextField validations
TextField validations  I want to know How to check first letter capital or not in a text field and also check all are characters or not in same textfield? and also want to know how to check all digits or not in a textfield? ex
incomplete pointer type NSMutableDictionary
incomplete pointer type NSMutableDictionary  My iphone app is throwing the "incomplete pointer type NSMutableDictionary" issue on running the iphone app. What is this issue and how can i remove it. NSMutableDictionary *dict
pointer to a reference
pointer to a reference  pointer to a reference in C++    #include <iostream> using namespace std; void foo1(int& x) { int* p = &x; *p = 123; } void foo2(int* x) { int
pointer to a reference
pointer to a reference  pointer to a reference in C++    #include <iostream> using namespace std; void foo1(int& x) { int* p = &x; *p = 123; } void foo2(int* x) { int
s:textfield - Struts
s:textfield  I am using the s:textfield tag in an appication and need to display % after the field on the same line. How would I go about doing this?  Hi friend, Textfield Tag Example
Java file move
Java file move In this section, you will learn how to move a file... is used to rename a file but here we have used this method to move a file from... an object of File class and parse the file with its full path. Now to move this file
Pointer in java - JSP-Servlet
Pointer in java   Hello ! All i know that java has no pointer type facility. but i have a problem to related pointer. Actually m using a dll... . i want to get address of a byte type variable, how can i do
how to output text from comboBox from first frame to textField on the second frame? please help me.. thank you in advance..
how to output text from comboBox from first frame to textField on the second frame? please help me.. thank you in advance..  how to output text from comboBox from first frame to textField on the second frame? please help me
Pointer in C
operator Example: In this example you will see how pointer works. ADS...About Pointer A pointer is a variable which contain the memory address...; used  when dealing with pointer. 1    &   
ModuleNotFoundError: No module named 'json_pointer'
'json_pointer' How to remove the ModuleNotFoundError: No module named 'json_pointer' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'json_pointer'  Hi, My Python
ModuleNotFoundError: No module named 'json_pointer'
'json_pointer' How to remove the ModuleNotFoundError: No module named 'json_pointer' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'json_pointer'  Hi, My Python
ModuleNotFoundError: No module named 'sky-pointer'
'sky-pointer' How to remove the ModuleNotFoundError: No module named 'sky-pointer' error? Thanks   Hi, In your python environment...ModuleNotFoundError: No module named 'sky-pointer'  Hi, My Python
ModuleNotFoundError: No module named 'json_pointer'
'json_pointer' How to remove the ModuleNotFoundError: No module named 'json_pointer' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'json_pointer'  Hi, My Python
Validate textfield in Java Swing
Validate Jtextfield in Java Swing In this section,you will learn how to validate the textfield by allowing only numbers to enter. For this purpose, we have used the keyEvent class.Using the method getKeyChar() of keyEvent class, we have

Ads