
I found that function which does the Capslocks job,when am running my program if the capslock button switched on the letters on the keyboard becomes capital,and if switched off the letters become small,but i want of this to happen during the run time,i mean the capslocks switch button to become a button that i can switch it between on and off during the runtime,like that is present in the window, please help me,please!

import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.text.*;
import javax.swing.border.*;
public class CapslockKey extends JPanel implements ActionListener
{
static final String st = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
JButton buttonList[];
String buffer = "";
JTextField text;
JButton capsLock;
boolean capslock;
public void key() {
text = new JTextField(20);
text.setActionCommand(""+ buffer);
add(text);
int n = st.length();
buttonList = new JButton[n];
for (int i = 0; i < n; i++) {
buttonList[i] = new JButton( "" + st.charAt(i) );
add(buttonList[i]);
buttonList[i].addActionListener(this);
}
capsLock = new JButton("CapsLock Key");
add(capsLock);
capsLock.addActionListener(this);
}
public void actionPerformed( ActionEvent e) {
int n = st.length();
if (e.getSource() == capsLock)
{
if (capslock)
capslock = false;
else capslock = true;
}
else{
for (int i = 0; i < n; i++)
{
if (e.getSource() == buttonList[i])
{
if (capslock)
{
buffer += st.charAt(i);
}
else
{
buffer += st.toLowerCase().charAt(i);
}
text.setText(""+ buffer);
break;
}
}
}
}
public CapslockKey(){
JPanel pane = new JPanel();
add(pane);
}
public static void main(String s[])
{
JFrame frame = new JFrame();
CapslockKey keys= new CapslockKey();
frame.getContentPane().add(keys,"Center");
keys.key();
frame.setSize(500,200);
frame.setVisible(true);
}
}

i think u soooo respectable , thank u so much so much so much,.....,thank u to share it. can u give me same idea for ALT , SHIFT and CTRL button ?? and if instead of array {String st = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";} use Stack or ArrayList ?. if we can how ? thank u ...
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.