You could write your own class which extends JPanel and implements KeyListener. Also it should override JPanel's add-method, and it that method you can assign every component you add an KeyListerner
ex.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class KeyPanel...
With this line
test obTest[] = new test[10];
you have meade the declaration but the array is still empty you have to fill it with test-Objects
ex.
for(int i=0; i<obTest.length; i++)
obTest[i]=new test();
You can use the method setText(String) eks.
buttonName.setText("Back");
and of course the button should have added an ActionListerner, to monitor the click
You get the error because the line
s = new String[n];
tries to assign a String array of size n to s, and you can assign a String array to a String.
The String constructor you are trying to use takes a char array as a parameter.
But why don't you cast into a String in the first place?
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.