how to move pointer in Textfield to newline

Ads
 

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.

Ads









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 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
Advertisements
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 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 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  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 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
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 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 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 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
TextField on the Image
TextField on the Image  how we set label or textfield etc. on the Image
Java write newline
Java write newline       Following example demonstrates,  how to get newline feature... of abstract writer class. In the example newLine feature is brought using
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
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
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
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
pointer error java
pointer error java  How to catch null pointer errors in java if the if(value != null) or null
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...") 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
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...;TextField("Type in the box");    add(tf); 
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
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

Ads