Corey Hollaway

+ Follow
since Jul 21, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
(keep public parts private until JForum day)
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt
Moderation Tools

Recent posts by Corey Hollaway

What does the protected do? I've tried using protected with public methods, and they all inherit the same. And they both seem to have the same protection as far as other classes using protected methods VS using public methods. Thank you!
13 years ago
I see now, thank you
[ July 22, 2004: Message edited by: Corey Hollaway ]
13 years ago

Originally posted by kalpana s:
hi all,

i have a scaled down image on a jlabel. i hava a popup menu wiht a "preview"
menuitem. if i click on preview, i show be able to bring up mspaint.exe loaded with the image file - say a gif file using java.

how do i do this.


I'm totally new, but just so I feel special :
1) Save the picture to a temp folder

2) Open this baby in msPaint

I hope this helps!
13 years ago
13 years ago
Ok I've been reading, and I've noticed that in composition they put instances of classes (that would be inherited if not composition) inside of a class even though it doesn't pass the HAS-A test!



I like it! It's like if you have a person, and you need that person to have:
-a mouth

And they all had instance variables! You can't extend them all, because you can only have one direct superclass. You can't use interfaces because their variables are final. So am I getting this ok? Thank you Peter den Haan
[ July 22, 2004: Message edited by: Corey Hollaway ]
13 years ago

Originally posted by Kevin Starr:
I was wondering, is there a way I can make it so that when I double click ???.class file it will open a command line to the right file and run as "java ???"?

That would be make it a lot easier for me to deploy my programs! I'm kind of new to Java, and my friends hate Java (because they're so lazy! Wake up and smell the Java!). But anyways, have you tried executable jar files?
This place talks about your problem with executing java programs, without having to go through the process of opening up the command line and blah blha blahe lol
13 years ago
Question: How do we add variables to subclasses while still using polymorphism? Is there a better option than the one below?

Background: Because we can only have one extends for a class, and the implements(interfaces) can only import final variables, I need to be able to change the variables though.
Because if I want Robodog to have pet variables(like boolean sitting), but Robodog is already extending Robot, then I have to handcode variables into every pet! And thus everyone that creates a Robot Pet would have to agree to a protocol for creates a RoboPet.

One Option: Create an abstract class that extends Robot called: "RobotPet". There I can put all of the pet specific variables & methods inside of. So I'd have:

class Robot{} <-- All Robots go here that aren't pets
class RobotPet extends Robot{} <-- All Robot pets go into here

class Robodog extends RobotPet{}

Interfaces seem so limited! If you can't change the variables (since they're final and must be declared inside of the interface), I have to keep building huge trees of polymorphism if I want variables! Thank you for your time!
13 years ago
Thank you Bear Bibeault and Joseph George. I third Bear's approach. But let's say I was crazy, and I wanted to make my coworkers hate me (but I that's because I'm using this technique in a bad way, but next time it will be really good!). I like what you said about instanceof!

And I got it! I was working with the instanceof VARIABLE, but all I needed to do was if People[i] instanceof Athlete! I thought I couldn't do that! Thank you! Here's all of the code for who needs it!

[ July 21, 2004: Message edited by: Corey Hollaway ]
13 years ago
How would I use reflection to see if kitKatBar existed inside of the Corey class?

This is the reason why I want to know:

I'm going to have a lot of people in a program using polymorphism. BUT, only some of them are going to be Athletes! And in main I'm going to have this:

People[] myPeople = new People[2];
myPeople = new Corey();
myPeople = new Sally();
for(int i=0; i<myPeople.length; i++){
if(They have the kitKatBar variable)
System.out.println(myPeople[i].name + " is an Athlete!");

Docs & source code can't help with this one! I need reflection? Thank you for your time! And your reply Stefan Wagner Peace out!
13 years ago

Originally posted by Stefan Wagner:
If the method is private, it is inherited too, of course.

I thought making a method private prevents inheritance? I thought only public and protected methods could be inherited.
13 years ago

How would I know that the "kitKatBar" variable existed inside of the Corey class?
13 years ago