Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-04-2007, 12:07 PM
Member
 
Join Date: Dec 2007
Posts: 10
Mr tuition is on a distinguished road
getting attributes from one class to another in 2 different .java files
Hi there,

I have run in to a little trouble which should be quite simple

I have 2 java files: one that loads the data, the second that displays data in a jframe

how can I pass the data from one to another?
in file ReadXML.java:
PHP Code:
public class ReadXML {
    public 
ReadXML() {
        
init();
       
// Reads in the data from XML
      // sets StrAllData
}
private 
String StrAllData
in file Cpass.java:
public class Cpass extends javax.swing.JFrame {

PHP Code:
    /** Creates new form Cpass */
    
public Cpass() {
        
initComponents();
   
// on pushing a button new ReadXML();
   // need a way to grab  StrAllData
  // can then set a text field to this 
  

__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 12-04-2007, 12:38 PM
Member
 
Join Date: Dec 2007
Posts: 10
Mr tuition is on a distinguished road
I have set StrAllData to puclic and tried to get this via ReadXML.StrAllData, but it tells me non-static variable can not be refrenced from a static context:
jTextArea13.setText(ReadXML.StrAllData);
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 12-04-2007, 12:49 PM
Member
 
Join Date: Dec 2007
Posts: 10
Mr tuition is on a distinguished road
This works:

In ReadXML create a getter for the StrAllData like this:

public String getStrAllData() {
return this.StrAllData;
}



In Cpass call getStrAllData on the ReadXML instance, for example:

ReadXML reader = new ReadXML();
String xmlContent = reader.getStrAllData();
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using static and final attributes – An example (II) JavaForums Java Blogs 0 03-06-2008 01:40 PM
Using static and final attributes – An example (I) JavaForums Java Blogs 0 03-06-2008 01:40 PM
Eclipse adding $1.class files eboraks Eclipse 1 11-28-2007 06:35 PM
how to see the code of class files mary Advanced Java 1 08-02-2007 03:52 PM
'class' and 'jar' files ai_2007 Advanced Java 1 06-29-2007 05:11 PM


All times are GMT +3. The time now is 01:52 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org