Try setLocation() to make your Dialog and Frames appear at your prefered location. public void setLocation(int x,int y) Moves this component to a new location. The top-left corner of the new location is specified by the x and y parameters in the coordinate space of this component's parent. Parameters: x - The x-coordinate of the new location's top-left corner in the parent's coordinate space. y - The y-coordinate of the new location's top-left corner in the parent's coordinate space.
I suppose that u have to import the packages inorder to access the class and in turn the methods defined in those classes. Without importing Java doesn't know anything about the class A or B, in your case. Try with this import package.class; import package.*;
When we cast a data type with a lesser size to a bigger one, explicit cast is required. The reason is that when we convert a bigger date type to a smaller one (Byte Size), the bytes will be eliminated to meet the size if the smaller data type and the value won't be correct. If u cast a smaller data type to bigger datatype, say an short to integer, the conversion will be automatic as the bytes will fit in and there won't be any change in the values. And if the values are within the range, there is no need for explicit cast.
You need to pass the class as an argumnet to the class where you want to handle the event. If you pass the class' object in the addActionListener()you can handle the events as soon as it had occured.
An Event Listener is one which will catch the events which is occuring on a particular component it is added with. The event source will indicate the origin of the event. The Event Listener and the Event Source are associated. The events occured are caught within a method, and the method holds event as its argument with an object. Using that we can get the source.
For Example, public void actionListener(ActionEvent e) { String s = e.getSource(); ....... ....... }
Hi, I don't know what are you exactly asking for. But I think I can help you with this. When you have a junk of code inside a Static Block, it will be executed whenever a class gets loaded. I like to remind you that Static Block is different from Static Method.
Java is not a structured language. It is object oriented and we lack the structurs in one or another way. In C++, we can create an object array easily and can able to assign the variables so easily, even assigning the values of the member variables of an object array. In java, we will encounter NullPointerException if we try to assign value to an member variable directly. The solution is to create a temporary object of that particular object and assign the values in to the temporary object. After this we can assign the temporary object into the array. For example, class OArray { int a; char c; } class OArrayAccess { OArray o = new OArray; //temporary object OArray[] oa = new OArray[10]; //assigning values in to the temp' object o.a = 10; o.c = 'k'; //assigning values in to object array oa[0] = o; //temp' object is assigned to the object array } In order to retrive the values, we have to again assign the array object in to a temporary object and access the values. The thought of using the vector classes will help only when we deal with different instances of a class. In the case of same object in an oops environment, Object array is the only solution.