Answer to Question #236852 in Java | JSP | JSF for binura

Question #236852

I used constructor for my form2 because in form 2 there no student name so i used constructor with parameters string name. i need to get the name print using clicking a button ,because that name is can used to class so can anyone send me the code to declare and to use any where in the method or in buttons


1
Expert's answer
2021-09-14T06:35:08-0400
 import java.awt.*;    
import java.awt.event.*;    
public class Main {    
    public static void main(String[] args) {      
        Frame frame = new Frame("Students");    
        final TextField name=new TextField();    
        name.setBounds(30,30, 120,10);   
        Button btn=new Button("Click");      
        btn.setBounds(30,80,40,10);   
        btn.addActionListener(new ActionListener() {    
        public void actionPerformed (ActionEvent e) {    
                name.setText("Name");    
            }    
        });    
        frame.add(btn);  
        frame.add(name); 
        frame.setLayout(null);
        frame.setSize(500,500);    
        frame.setVisible(true);     
    }    
}   

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS