Carlos Failde

Ranch Hand
+ Follow
since Oct 20, 2000
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Carlos Failde

Another way is to call repaint() after you have removed the old component and added the new one.
[ April 28, 2004: Message edited by: Carlos Failde ]
14 years ago
I am going to assume you mean DateChooser but I could be way off.
Add an action listener to your button that constructs a new DateChooser, displays it, and then queries it for the selected date.

[ April 25, 2004: Message edited by: Carlos Failde ]
14 years ago
Howdy.
If you put the following in your .bashrc file you can get something similar to what you are asking.
alias ccd="cd && cd $1"
It will:
1) cd to your home directory and then
2) either change to the specified directory if it exists
or complain if the directory does not exist.
Example invocation: ccd Scripts
I don't know about changing the default behaviour of the cd command itself but it does not sound like a good idea to anyway.
14 years ago
Howdy. There was a thread about this one ... found it:
super.super.method()
14 years ago
Howdy. You may remember this question from such popular threads as this and
this.
[ April 23, 2004: Message edited by: Carlos Failde ]
14 years ago
Ahh, an array object is an object! I had thought of array objects until now as a bunch of references to objects (umm, "an array of objects" I guess). But seeing as they're objects in their own right they obey the usual rules of objects, such as having a type.
Spelling things out we have Identifiers, array objects, and objects.

1) Identifiers
Component[] comps is a reference to an object of type Component[]. It can refer to an object of type Component[] or one of its subclasses such as an object of type JLabel[] (a JLabel[] is a Component[]).
JLabel[] labels is a reference to an object of type JLabel[]. It can refer to an object of type JLabel[].
2) array objects
new JLabel[4]; constructs an object of type JLabel[]. It can store references to objects of type JLabel.
new Component[4]; constructs an object of type Component[]. It can store references to objects of type Component or a subclass of Component such as JLabel.
The object constructed by new JLabel[4]; can be referred to by comps because JLabel[] is a Component[]. Additionally the object constructed by new Component[4]; or returned by getComponents() (which has return type Component[]) in Container can be referred to by comps.
The object constructed by new JLabel[4]; can be referred to by labels BUT the object constructed by new Component[4]; or returned by getComponents() can NOT be referred to by labels because Component[] is not a JLabel[].

3) Objects
new JLabel( "label " ); constructs an object of type JLabel. A reference to this object can be stored in the object constructed with new JLabel[4]; OR in the object constructed with new Component[4]; because a JLabel is a Component.
new Component(); constructs an object of type Component. A reference to this object can be stored in the object constructed with new Component[4]; BUT not in the object constructed with new JLabel[4]; because a Component is not a JLabel.
[ April 23, 2004: Message edited by: Carlos Failde ]
14 years ago

gives a ClassCastException at runtime -
Exception in thread "main" java.lang.ClassCastException: [Ljava.awt.Component;
The return type of the getComponents() method in the Component class is Component[]. The attempted cast seems valid since all the components returned are in fact instances of JLabel as can be proved by calling getCLass() on each of the returned components. The ClassCastException is claiming that the components are instances of Component.
Changing the troublesome line to

corrects the problem.
Another possible change is to replace the last three lines of the program with

which also gives the desired result.

Trying something a bit different:

I.E. record the components added to the panel so that the getContents() call is no longer needed. The JLabels are stored in an array of Component references which is later casted to an array of JLabel.
It works so it can not be a casting problem, it must be something peculiar about getContents() !?!?
[ April 22, 2004: Message edited by: Carlos Failde ]
14 years ago
int
There was a thread about this a few days ago that may be of some help, how can i determine the type of a variable?
14 years ago
A similar topic mentions the user of an InputVerifier.
14 years ago
An empty class with no fields must still extend another class. Say it extends object, it will inherit the methods of the Object class so must have a non-zero size.
There has been discussion on JavaWorld about object size such as Sizeof for Java. Playing around with the example program listed in that article suggests that an empty instance just like an object instance occupies eight bytes.
14 years ago
Howdy.
It works if you put a pause in after each beep with something like:
14 years ago
Subclass the relevant component and override the paint(Graphics g) method to draw the background image.
An example
14 years ago