Java Program any letter to upper case Letter(JavaSWING) ActionListener
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
class MyFrame extends JFrame implements ActionListener{
Container c;
JTextField t1;
JButton b1;
MyFrame(){
c=this.getContentPane();
c.setLayout(null);
t1 = new JTextField();
t1.setBounds(100,50,210,50);
c.add(t1);
b1 = new JButton("CLick");
b1.setBounds(100,100,150,40);
c.add(b1);
b1.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
String str =t1.getText();
t1.setText(str.toUpperCase());
}
}
class Uper{
public static void main(String[] args) {
MyFrame f = new MyFrame();
f.setBounds(100,100,800,400);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setTitle("to upper case");
f.setVisible(true);
}
}
Comments
Post a Comment