« Return to Thread: no "Friend"s in Java

Re: no "Friend"s in Java

by Johnny Kewl :: Rate this Message:

Reply to Author | View in Thread

Some parts of this message have been removed. Learn more about Nabble's security policy.
 
---------------------------------------------------------------------------
HARBOR: http://coolharbor.100free.com/index.htm
The most powerful application server on earth.
The only real POJO Application Server.
Making the Java dream come true.
---------------------------------------------------------------------------
 
Matthew,
 
You just on a little learning curve, and you coming from C++ and it is a little weird at first.
I remember struggling with trying to see what java did with pointers.
Its still all possible, its a little different but much much easier once you click.
C++ programmers have great insight, and you'll end up making superb apps.. just hang in there a little.
 
Two things to get you going really quick...
Google for the SUN JAVA TUT... read the whole thing
 
In the SWING... UI stuff... if in doubt right click on a UI component and click javadoc... that will have a reference to another tut with enuf examples to make you click.
 
Lots to learn... but it wont be long before you show us a few new tricks ;)
Friends... no but living without them, is no sweat in Java... I dont really miss pointers either ;)
Typedef... not something I miss too much either ;)
Its different... but Java is very very clean... it is a beautiful simple language.
 
To me Java is (over simplified), something that happens if a programmer has used C++ for a million years.
Once they get all their tools working, and automate memory management and its perfect... then its Java ;)
 
Have fun ;)
 
----- Original Message -----
From: matt.lengenfelder@...
To: nbusers@...
Sent: Thursday, May 08, 2008 5:37 AM
Subject: [nbusers] no "Friend"s in Java

I'm started to do some java programming in netbeans and thought I'd toss this out there.

simple example:
create a new project - Java Desktop Application, basic application "D1"
on "D1View" drop some controls in the design view,
create a new java class
create a function in that class and try to connect to any of the controls you created in the D1View class
for instance you can't set the value of JTextArea1

I've tried making a new function for instance

    public void setText(String test) { jTextArea1.append(test); }

in the D1View class that takes a string and appends JTextArea1 and it works but that function also can't be called outside of the class...

There is no way to set "Friend" classes in Java.

public class D1View
 - this is how the class is declared, so it's public and my simple setText function is public, why in the world will it not let me access it in another class, in the same package?

if I set "setText" to be static then other classes can see it, but it won't compile while accepting a string.

I've also gone through the designer and used custom code to set both JTextArea1 and the mainPanel to be public in the hopes that something would show up as usable in the NewClass but so far nothing is.

Thoughts?

Matt Lengenfelder

 « Return to Thread: no "Friend"s in Java