Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Swing-AWT how to move pointer in Textfield to newline

Have Programming Question? Ask it here!
 
 
 


Faiz Ahmad
how to move pointer in Textfield to newline
2 Answer(s)      2 years and 2 months ago
Posted in : Swing AWT


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();
}
}

Advertisement
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 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
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 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 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
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 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
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
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
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
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
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 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
TextField on the Image
TextField on the Image  how we set label or textfield etc. on the Image
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
Java file move
Java file move In this section, you will learn how to move a file... a file but here we have used this method to move a file from one directory... class and parse the file with its full path. Now to move this file, we have called
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
Move text on the frame
Move text on the frame using Java Program In this section, you will learn how to move text on the frame. As you have already learned about the html marquee... to move the specified string. import java.awt.*; import 
Pointer a variable
Pointer a variable  hii, Pointer is a variable or not ?   hello, Yes, a pointer is a variable
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
how to move records from one table to other based on its creation time
how to move records from one table to other based on its creation time  Hi all,, As part of my requirement ,the records in one table have to move... not be present in first table after creation of two days,and it has to move
pointer error java
pointer error java  How to catch null pointer errors in java if the if(value != null) or null
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); 
null pointer
null pointer  dear sir , what is mean by null pointer in c
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
Move Image in Java Swing
How to Move Image in Java Swing In this section, you will learn how to move an image using mouse. For this purpose, we have specified an image and using... to move this image, we have used public void mouseMoved() and public void
textfield selected text
textfield selected text  How to select text in text field
move an object
move an object   //Dear Deepak i want to write a code which mover the ball along x-co-ordinates 9 times on for loop execution, but the ball... visit the following link: Move ball
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
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
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
Pointer in C
operator Example: In this example you will see how pointer works...About Pointer A pointer is a variable which contain the memory address...; used  when dealing with pointer. 1    &   
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
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
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
NULL POINTER EXCEPTION
NULL POINTER EXCEPTION    What is the Root cause for Class caste exception in struts frame work .and how 2 handle that 1 please help me
Null pointer execption
Null pointer execption  what is null pointer exception. I am getting the null pointer exception in this line conn= com.mypay.dao.Connection.getConnection(); what is wrong
Null pointer execption
Null pointer execption  what is null pointer exception. I am getting the null pointer exception in this line conn= com.mypay.dao.Connection.getConnection(); what is wrong
null pointer exception in java
null pointer exception in java  What is null pointer exception in Java and when it occurs? Show it with an example.Thanks!   Java Null Pointer Exception
Function pointer in c
Function pointer in c  What is the difference between function call with function pointer and without function pointer(normal function call
c-language pointer functions
c-language pointer functions  what is the execution process of character pointer functions with example
Move Curve Control Point
Move Curve Control Point       In this section, you will studied how to move the curve control point and manipulates the shape of curve. The Control points
Null Pointer Exception - Java Beginners
Null Pointer Exception  How Can I Handle NullPoiniterException without using try/catch mechanism
Httpservletresponse null pointer exception.
Httpservletresponse null pointer exception.  What is Httpservletresponse null pointer exception?   NullPointerException occurs when we try to implement an application without referencing the object and allocating
Advertisements
 

 

 

DMCA.com