473,326 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Public variables not available for all classes? (IDE: NetBeans)

Hi all!

I have a problem with NetBeans. Although I've declared my variables as public, I can't access them from all classes. Refer to the screenshot below:

[img=http://img45.imageshack.us/img45/3964/netbeansyx8.th.gif]

I have declared the following variables in BookReviewsGUI.java:

public JFrame configFrame = new ConfigurationGUI();
public String user;
public String password;
public String ip;

How come I can't call them in ConfigurationGUI.java?

Please have patience with me - I'm new at this...
Aug 21 '08 #1
5 2272
r035198x
13,262 8TB
How are you accessing them in ConfigurationGUI? Are you creating an object of the class in which they are declared?
Aug 21 '08 #2
JosAH
11,448 Expert 8TB
Hi all!

I have a problem with NetBeans. Although I've declared my variables as public, I can't access them from all classes. Refer to the screenshot below:

[img=http://img45.imageshack.us/img45/3964/netbeansyx8.th.gif]

I have declared the following variables in BookReviewsGUI.java:

public JFrame configFrame = new ConfigurationGUI();
public String user;
public String password;
public String ip;

How come I can't call them in ConfigurationGUI.java?

Please have patience with me - I'm new at this...
Only if you have an instance (object) of your BookReviewsGUI class available
then you can access those public variables. If they would've been static then
all you need is the BookReviewsGUI class to access the variables.

kind regards,

Jos
Aug 21 '08 #3
Thanks for the quick answers r035198x and JosAH =)

I'm accessing them in a rather normal way:

user = userField.getText();
ip = ipField.getText();

How do I create an instance of a class? ClassLoader?
Aug 21 '08 #4
r035198x
13,262 8TB
Thanks for the quick answers r035198x and JosAH =)

I'm accessing them in a rather normal way:

user = userField.getText();
ip = ipField.getText();

How do I create an instance of a class? ClassLoader?
You will want to bookmark this page
Aug 21 '08 #5
@r035198x

Problem solved. I'll read before I ask next time.
Aug 21 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Phil | last post by:
I went to sun to get J2SE 1.4.2 and fount only J2SE v 1.4.2 with NetBeans IDE v 3.5 Cobundle is there a place for just 1.4.2 and no netbeans?
2
by: King W.Wang | last post by:
Hi all, I've installed NetBeans IDE 3.5 on Windows XP. But if I try to start it, a message box shows "cannot load jvm.dll". This library does exist in a subdirectory. My questions are: 1) Is...
0
by: John Ochiltree | last post by:
Can anyone here help me with a configuration problem. How do I configure netbeans to use jar files. I am trying to use the Jena RDF jars with NetBeans IDE 3.5.1 but can't seem to get netbeans to...
3
by: Francis M | last post by:
Nowadays when you obtain the SDK form java.com you get a new interactive programming environemt much like the Borland C++ IDE. Up to now I've been developing applications "the old way" using...
1
by: tmb | last post by:
I'm a newbie to Java. At http://java.sun.com/j2se/1.4.2/download.html I see I can download... NetBeans IDE + J2SE SDK as a 'bundle' I beleive is both NetBeans and the Java SDK... My...
12
by: jelle | last post by:
That's basically the idea... Often i find myself annotating what variables actually stand for, so to refer back to the code in half a year or so. # check if ID's or coords self.pointIDs = ptIDs...
86
by: jopperdepopper | last post by:
Hi, finally giving php 5 a go, and going over the new approach to classes. Can someone clarify the public, private and protected to me? I quote the php manual: "The visibility of a property or...
17
by: JD | last post by:
hi, i m new to java, i want to know if there is a good and free Java IDE that i can use that'll help me, i dont care if its complicated , i just want it to be good, i tried netbeans which comes...
0
by: sokeefe | last post by:
I use NetBeans IDE to develop a Java application. In the past, I could use the Design Editor to edit my form for the GUI. Spontaneously, NetBeans is unable to open the form file, producing this...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.