Passing Variables from One Class to Another

Hello, I am new to Java Programming and I'm currently starting off by trying to build a simple application.
I need help to pass variables created in one class to another.
In my source package, I created 2 java classes.
1. Main.java
2. InputFileDeclared.java
InputFileDeclared reads numerical data from an external text file and store them as string variables within the main method while Main converts a text string into a number.
Hence, I would like to pass these strings variables from the InputFileDeclared class to the Main class so that they can be converted into numbers.
I hope somebody out there may enlighten me on this.
Thank you very much in advance!

Values are passed from method to method, rather than from class to class. In a case such as you describe the code of a method in Main will probably call a method in InputFileDeclared which will return the String you want. The method in Main stores that in a local variable and processes it. It really doesn't matter here which class the method is in.
You InputFileDeclared object probably contains "state" information in its fields such as the details of the file it's reading and how far it's got, but generally the calling method in Main won't need to know about this state, just the last data read.
So the sequence in the method in Main will be:
1) Create an new instance of InputFileDeclared, probably passing it the file path etc..
2) Repeatedly call a method on that instance to return data values, until the method signals that it's reached the end of file, e.g. by returning a null String.
3) Probably call a "close()" method on the instance, which you should have written to close the file.

Similar Messages

  • How to pass a variable from one class to another class?

    Hi,
    Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
    class A {
      int a;
      int doA() {
          a = a + 1;
          return a;
    class B {
      int b;
      A r = new A();
      r.a;  // error: <identifier> expected. What does that mean ?
      int doB() {
         int c = b/a;  // error: operator / cannot be applied to a
    }Thank you!

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • Moving Variable from one class to another.

    I need to get a Variable from one class to another how would I do this?

    Well this is a very tipical scehario for every enterprise application. You always create logger classes that generate log files for your application, as that is the only way to track errors in your system when its in the production enviorment.
    Just create a simple class that acts as the Logger, and have a method in it that accepts a variable of the type that you are are trying to pass; most commonly a String; but can be overloaded to accept constom classes. e.g.
    class Logger
      public void log(String message)
        writeToFile("< " + new Date() + " > " + message);
      public void log(CustomClass queueEvent)
        log("queue message was: " + queueEvent.getMessage() + " at: " + queueEven.getEventTime());
    }Hope this makes things clearer
    Regards
    Omer

  • OBIEE 11g How to pass variable from one prompt to another prompt in dashboard page.

      How to pass variable from one prompt to another prompt in dashboard page.
    I have two prompt in dashboard page as below.
    Reporttype
    prompt: values(Accounting, Operational) Note: values stored as
    presentation variable and they are not coming from table.
    Date prompt values (Account_date, Operation_date)
    Note:values are coming from dim_date table.  
    Now the task is When user select First
    Prompt value  “Accounting” Then in the
    second prompt should display only Accounting_dates , if user select “operational”
    and it should display only operation_dates in second prompt.
    In order to solve this issue I made the
    first prompt “Reporttype” values(Accounting, Operational) as presentation
    values (custom specific values) and default presentation value is accounting.
    In second prompt Date are coming from
    dim_date table and I selected Sql results as shown below.
    SELECT case when '@{Reporttype}'='Accounting'
    then "Dates (Receipts)"."Acct Year"
    else "Dates (Receipts)"."Ops
    Year"  End  FROM "Receipts"
    Issue: Presentation variable value is not
    changing in sql when user select “operation” and second prompt always shows
    acct year in second prompt.
    For testing pupose I kept this presentation
    variable in text object of dashboard and values are changing there, but not in
    second prompt sql.
    Please suggest the solution.

    You will want to use the MoveClipLoader class (using its loadClip() and addListener() methods) rather than loadMovie so that you can wait for the file to load before you try to access anything in it.  You can create an empty movieclip to load the swf into, and in that way the loaded file can be targeted using the empty movieclip instance name.

  • Passing variables from one swf to another

    I am facing problem to pass variable from one swf to another.
    I am using loadMovie to load another swf. how can I pass a variable
    value to another swf. Can anyone help me plz? It is somewhat
    urgent.
    thanx in advance.

    first of all:
    this is the Flash Media Server and your problem is not
    related to FMS....
    second thing related to the "somewhat urgent" :
    we, users on this forum, are not there to do your job... so
    calm down otherwise no people will answer your question. This forum
    is a free support forum that community of Flash developer use to
    learn tricks and to solve problems.
    Possibles solutions:
    If the two swf are seperate you can use LocalConnection to
    establish a connection between different swf.
    If you load a second swf into the first one you can interact
    like a standard movieClip(only if there from the same domain or if
    you a policy file on the other server)
    You can use SetVariable(via Javascript) to modify a root
    variable on the other swf and check with an _root.onEnterFrame to
    see if the variable had changed in the second swf.
    * MovieClipLoader will do a better job, in your specify case,
    than the loadMovie. Use the onLoadInit event to see when the swf is
    really totaly loaded into the first one otherwise you will have
    timing issues.
    My final answer(lol) is the solution 2 with the
    notice(*)

  • Passing Variables from one View to another

    First of all Hi this is my first post on the sap forums.
    Aplogies if I have come to the wrong place or if this question is very easy, but I am new to abap and web dynpro and have found myself struggling a little bit.  So I stumbled across this site and thought I would ask for help.
    My problem is this, I have 2 variables on my MAIN view, one called MONTH and the other called YEAR.  What I want to do is on a button click on the MAIN view pass the values of these variables to another view called SUMMARY_RPT and then use these variables in an SQL query I have on this view.
    Anybody out there that can help ?
    Many Thanks,
    George

    Hi George,
    Welcome to webdynpro abap community. To pass data from one view to another, you can should create two attributes (type string) in the attribute tab of of the component controller. Now these will act as global variable for you. Now you can access these attribute in your view in this way:
    wd_comp_controller->gv_val "gv_val is the name of the attribute
    Populate the value in it and use it anywhere you want.
    There is one more way to do the same.
    Create a node under context in component controller and create 2 attributes(type string) after that. Map this node to both the views. Now get the value of month , year and set these attribute with the same values with the help of code wizard in view 1. Now in the view2 simply read those attribute and you'll get the value of month and year which was entered in the first view. Read the attribute with the help of code wizard. Now you can use them accordingly.
    I would suggest you to use 1st method as it is better performance wise.
    I hope it helps.
    Regards
    Arjun

  • Passing variables from one jsp to another

    Hi All,
    I've searched thru the forum and can't find an answer to a prob I'm having, trying to pass a variable from one jsp to another.
    in file searchBar.jsp i have
    <%
    String archiveSearch = "off";
    %>
    and
    <%
    if (userUtils != null && userUtils.getSearch().equals("on"))
    %>
    <a href="/webLayout/webSideBar.jsp?searchState=<%=archiveSearch%>onclick="archiveSearch = "on""></a>
    and in file webSideBar.jsp
    <%
    String searchState = "off";
    String archiveSearch = (String)request.getParameter("searchState");
    %>
    basically it will give me a variable archiveSearch set to on in webSideBar when the user clicks on the search button, but as it is it's not passing the variable from the searchBar.jsp to the webSideBar.jsp and I think it looks ok !!!! but it's not
    Help

    Looks good to me as well.
    Couple of suggestions
    1 - view source on searchbar.jsp - see what the generated source code for that link is
    2 - Look at the url used to generate webSideBar.jsp. If its not in the address bar, right click the webSideBar page and choose properties.
    Check to see what parameter was passed.
    Are these pages in a frameset? Do you have to specify a target frame for your link?

  • Pass RowSet from one class to another

    Hi, i am trying to pass a rowset from one class to another but i keep getting the error messages:
    method does not return a value
    statement not reachable
    Does anybody know why?
    package project1;
    import java.sql.SQLException;
    public class readdata {
        public static void main(String[] args) {
            Class2 cl = new Class2();
            try {
            while (cl.openConnection().next()) {
                System.out.println(cl.openConnection().getInt("id") + "-");
            catch (SQLException se)
                    System.out.println(se);
           // while (rs.next())
             //       System.out.println(rs.getInt("id") + "-");
             //       System.out.println(rs.getString("field1") + '\n');
    package project1;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import javax.sql.RowSet;
    public class Class2 {
       private Connection conn;
        public Class2() {
            openConnection();
        public RowSet openConnection()
                try
                        Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                        conn = DriverManager.getConnection("jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=D:\\test.mdb;PWD=","admin","");
                        Statement command = conn.createStatement();
                        RowSet rs = (RowSet)command.executeQuery("select * FROM testing");
                        return rs;
                        System.out.println("Connected To Access");
                        rs.close();
                        conn.close();
                catch (SQLException se)
                        System.out.println(se);
                catch (Exception ex)
                        System.out.println(ex);
    }Thanks in advance
    Message was edited by:
    snipered2003
    Message was edited by:
    snipered2003

    Hi snipered2003
    I'm fairly new to java, so check out anything I say.
    to me it appears that the code within your try block in the main method of readdata class can never throw a SQLException since the calls are to cl.openConnection() which catches any SQLException and does not throw it.
    So one statement not reachable is the statement in the catch blockSystem.out.println(se);Second, the only return statement in your openConnection() method is inside the try block, whic means that if an exception is encountered there will be no RowSet returned by the method.
    Secondly, the code in the try block in your Class2.openConnection() after the return statement will also never be reached.
    You may need something like    public RowSet openConnection()
            RowSet rs = null;
            try
                Class.forName("sun.jdbc.odbc.JdbcOdbcDriver").newInstance();
                conn = DriverManager.getConnection("jdbc:odbc:;DRIVER=Microsoft Access Driver (*.mdb);DBQ=D:\\test.mdb;PWD=","admin","");
                Statement command = conn.createStatement();
                rs = (RowSet)command.executeQuery("select * FROM testing");
                System.out.println("Connected To Access");
            catch (SQLException se)
                System.out.println(se);
            catch (Exception ex)
                System.out.println(ex);
            return rs;
        }But you will have to check for a null return value in the call to the method.
    It also looks like the code in your main method, when these things are ironed out, will run an infinite loop, but I could be wrong on that.
    I think (note: think) this part should be        RowSet rs = cl.openConnection()
            if (rs != null) {
                while (rs.next()) {
                    System.out.println(rs.getInt("id") + "-");
                rs.close();
            }Anybody please correct me if I am wrong.
    And I don't know where the conn.close would fit in this scheme of things.
    Cheers, Darryl

  • Passing variable from one JSP to another

    Hi....
    I am working on customizing Oracle Application(istore).
    I need to pass variable from 1 JSP to another.
    JSP 1 contains the following line of code:
    <INPUT type="HIDDEN" name="soldtoCustPartyName" value="<%=soldtoCustPartyName%>">
    How can I pass this to another JSP Page. The other JSP should take the 'soldtoCustPartyName' and find out the primary address country.
    So please help me in getting variable passed from 1st JSP to next.
    By default, 1st JSP is not fwded to 2nd JSP.
    This is very very urgent...Please help.....

    When you push the submit button on jsp1 - it goes to jsp2?
    ie
    // in jsp1.jsp
    <form action="jsp2.jsp">
    <INPUT type="HIDDEN" name="soldtoCustPartyName" value="<%=soldtoCustPartyName%>">
    <input type="submit">
    </form>
    //Then in jsp2.jsp all you need is
    request.getParameter("soldtoCustPartyName");This will pick up the value that is coming from the hidden field on jsp1

  • How can I pass variables from one project to another using Javascript?

    Hi all, I am trying to do this: let learners take one course and finish a quiz. Then based on their quiz scores, they will be sent to other differenct courses.
    However, I wish keep track on their previous quiz scores as well as many other variables.
    I found this nice widge of upload/download variables by CPguru (http://www.cpguru.com/2011/05/18/save-and-load-data-widget-for-adobe-captivate-4-and-adobe -captivate-5/). However, this widget works by storing variables from one project in local computer and then upload it to another project.
    My targeted learners may not always use the same computer though, so using this widget seems not work.
    All these courses resided in a local-made LMS which I don't have access to their code. Therefore, passing variables to PHP html files seems not work.
    Based on my limited programing knowledge, I assume that using Javascript to pass variables may be the only possible way.
    Can someone instruct me how to do this?
    Thank you very much.

    If you create two MIDlet in a midlet suite, it will display as you mentioned means you can't change the display style.

  • Passing a variable from one class to another

    Hello:
    I am new to java programming. I am developing an application in Java
    At a particular JTextField call it jtf3, I am invoking Calendar application by clikcing a jbutton.
    I would like to set text in jtf by obtaining the date clicked by the user. I am storing complete date string in the Calendar application during ActionPerformed event at Calendar Application level.
    I do not know how to pass this string to calling frame as it does not listen to the button event happening at the Calendar Application.
    Much appreciated
    Thanks a lot for your time
    regards

    This is the application from which the I am calling the calendar application.
    The method setDate set the date obtained from calendar class during actionperformed event.
    The actionperfomed event from CalendarClass is pasted below as well.
    Much appreciated
    import javax.swing.JFrame;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    import java.awt.*;
    public class TestDrive
    public static void main(String[] args) {
    DatePanelFrame dpf = new DatePanelFrame();
    dpf.addWindowListener(new WindowAdapter( ) {
    public void windowClosing(WindowEvent we) { System.exit(0); }
    dpf.pack();
    dpf.setVisible(true);
    class DatePanelFrame extends JFrame {
    JTextField djtf;
    String dateInput;
    public DatePanelFrame() {
    setTitle("Date Panel");
    setSize(100, 800);
    setLocation(300, 100);
    Container content = getContentPane();
    JPanel datePanel = new JPanel();
    JButton calButton = new JButton(".....");
    datePanel.add(calButton, BorderLayout.SOUTH);
    djtf = new JTextField(" ");
    datePanel.add(djtf, BorderLayout.NORTH);
    content.setLayout(new BorderLayout());
    content.add(datePanel, BorderLayout.CENTER);
    calButton.addActionListener(new ActionListener()
              public void actionPerformed(ActionEvent event)
    JFrame fr = new CalendarClass();
    fr.setSize(400, 400);
    fr.setLocation(600, 100);
    ObjCal oc = new ObjCal();
    fr.setVisible(true);
    public void setDate(String d)
    djtf.setText(d);
    repaint();
    System.out.println(djtf.getText());
    The ActionPerformed event from CalendarClass
    jbtArray.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent event)
    if (event.getActionCommand() != " ")
              daySelected = event.getActionCommand();
              yearSelected = jtfYear.getText();
              int intYearSelected = Integer.valueOf(yearSelected).intValue();
              monthSelected = jtfMonth.getText();
              intDaySelected = Integer.valueOf(daySelected).intValue();
              int intMonthSelected = getMonthNum(monthSelected);
              dateSelected = getDate(intYearSelected, intMonthSelected, intDaySelected);
              TestDrive td = new TestDrive();
              DatePanelFrame dpf = new DatePanelFrame();
              dpf.setDate(dateSelected);

  • Using a variable from one class to another

    Hi !
    I've a class called ModFam (file ModFam.java) where I define a variable as
    protected Connection dbconn;
    Inside ModFam constructor I said:
    try
    String url = "jdbc:odbc:baselocal";
    Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver" );
    dbconn = DriverManager.getConnection(url);
    System.err.println("Connection successful");
    } ..... rest of code
    This class define a TabbedPane as follows:
    tabbedPane.addTab("Welcome",null,new Familias(),"Familias");
    As you can see it call a new instance of the Familias class (file Familias.java).
    This constructor will try to connect with the DB to populate a combo box with some data retireved from the DB.
    If I do
    Statement stmt;
    stmt = dbconn.createStatement();
    inside Familias constructor I receive the message
    Familias.java:50: cannot resolve symbol
    symbol : variable dbconn
    location: class fam.Familias
    stmt = dbconn.createStatement();
    at compile time.
    While I can�t use a variable defined as "protected" in one class of my package on another class of the same package ?
    How could I do ?
    Thanks in advance
    <jl>

    Familias doesn't have a reference to ModFam or the Connection.
    So change the constructor in Familias to be
    public class Familias {
      private ModFam modFam;
      public Familias(ModFam m) {
        modFam = m;
    // ... somewhere else in the code
    Statement stmt = modFam.dbconn.createStatement();
    }or
    public class Familias {
      private Connection dbconn;
      public Familias(Connection c) {
        dbconn = c;
    // ... somewhere else in the code
    Statement stmt = dbconn.createStatement();
    }And when you instantiate Familias it should then be
    new Familias(this) // ModFam reference
    or
    new Familias(dbconn)

  • Variable from one class to another

    I have a Program that contains a JDesktop Pane, and when the program starts, it creates the "main" window as in JInternal Frame.
    When a certain check box is checked, I call an external class that creates and returns a JInternalFrame. What I need to do is have the external class get a Vector from the main class (I pass it in when i create the object), edit the Vector, then return it to the main class. If i try to create a method in the main class like "returnVector()" or whatever to get the vector back to the main class, I get the error of "Non-static variable cannot be referenced from a non-static context". How can I get around that? The NEXT issue is this: I would like to cause the JInternalFrame that is created from the external class (on the JDesktopPane in the main class) to close itself when a button in it is clicked. I'm guess I'd need a Listener somewhere. Would that listener be in the Main class or in the external one. Does this make sense? Any help would be greatly appreciated.

    Sorry, This might be a bit lengthy, but it works and illustrates my problem. I created it in NetBeans. There are the two classes I'm jusing. The issue is illustrated in the button listener on the 2nd class:
    The First:
    package javaapplication3;
    import java.beans.PropertyVetoException;
    import java.util.Vector;
    import javax.swing.JInternalFrame;
    public class NewJFrame extends javax.swing.JFrame {
        Vector <String> TestVector = new Vector <String> (0); //Vector to move around.
        public NewJFrame() {
            //add some test strings to the Vector
            TestVector.add("String1");
            TestVector.add("String2");
            TestVector.add("String3");
            initComponents();
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">                         
        private void initComponents() {
            jDesktopPane1 = new javax.swing.JDesktopPane();
            jInternalFrame1 = new javax.swing.JInternalFrame();
            jLabel1 = new javax.swing.JLabel();
            jButton1 = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jInternalFrame1.getContentPane().setLayout(new java.awt.FlowLayout());
            jInternalFrame1.setVisible(true);
            jLabel1.setText("This is a VERY simple example");
            jInternalFrame1.getContentPane().add(jLabel1);
            jButton1.setText("Press this");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ButtonListen(evt);
            jInternalFrame1.getContentPane().add(jButton1);
            jInternalFrame1.setBounds(10, 10, 350, 120);
            jDesktopPane1.add(jInternalFrame1, javax.swing.JLayeredPane.DEFAULT_LAYER);
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jDesktopPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jDesktopPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 300, Short.MAX_VALUE)
            pack();
        }// </editor-fold>                       
        private void ButtonListen(java.awt.event.ActionEvent evt) {                             
            JInternalFrame newFrame;
            NewJFrame2 roadframe = new NewJFrame2(TestVector);
            newFrame= roadframe.getFrameBack();
            newFrame.setVisible(true);
            jDesktopPane1.add(newFrame);
            try {
                newFrame.setSelected(true);
            } catch (PropertyVetoException ex) {
                ex.printStackTrace();
        //created this in hopes of using it to return the vector from NewJFrame2
        public void returnVector(Vector<String> vectorAgain){
            this.TestVector=vectorAgain;
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new NewJFrame().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.JButton jButton1;
        private javax.swing.JDesktopPane jDesktopPane1;
        private javax.swing.JInternalFrame jInternalFrame1;
        private javax.swing.JLabel jLabel1;
        // End of variables declaration                  
    }The 2nd:
    package javaapplication3;
    import java.util.Vector;
    import javax.swing.DefaultListModel;
    import javax.swing.JInternalFrame;
    public class NewJFrame2 extends javax.swing.JFrame {
        Vector <String> testVector=new Vector<String>(0);
        DefaultListModel model;
        public NewJFrame2(Vector <String> TestVector) {
            this.testVector=TestVector;
            initComponents();
        public JInternalFrame getFrameBack(){
            return jInternalFrame1;
        // <editor-fold defaultstate="collapsed" desc=" Generated Code ">
        private void initComponents() {
            jInternalFrame1 = new javax.swing.JInternalFrame();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            model=new DefaultListModel();
            for (int a=0; a<testVector.size();a++){
                model.addElement(testVector.get(a));
            jList1 = jList1=new javax.swing.JList(model);
            jButton1 = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            jInternalFrame1.setVisible(true);
            jLabel1.setText("This is the 2nd class I was referencing I passed TestVector from NewFrame. It Contains:");
            jInternalFrame1.getContentPane().add(jLabel1, java.awt.BorderLayout.NORTH);
            jLabel2.setText("Now I want to Edit this list here, and then send it back to NewFrame1. The button will attemp.");
            jInternalFrame1.getContentPane().add(jLabel2, java.awt.BorderLayout.SOUTH);
            jScrollPane1.setViewportView(jList1);
            jInternalFrame1.getContentPane().add(jScrollPane1, java.awt.BorderLayout.CENTER);
            jButton1.setText("Return Vector");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    ReturnVectorButtonListener(evt);
            jInternalFrame1.getContentPane().add(jButton1, java.awt.BorderLayout.EAST);
            org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jInternalFrame1)
            layout.setVerticalGroup(
                layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                .add(jInternalFrame1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
            pack();
        }// </editor-fold>
        private void ReturnVectorButtonListener(java.awt.event.ActionEvent evt) {
        NewJFrame.returnVector(testVector);
        // Variables declaration - do not modify
        private javax.swing.JButton jButton1;
        private javax.swing.JInternalFrame jInternalFrame1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JList jList1;
        private javax.swing.JScrollPane jScrollPane1;
        // End of variables declaration
    }

  • Passing variable from one template to another

    We have problems in the BI7 environment with passing variables across from one web template to another.
    In BW3.x there was a Java Script Command SAP_BW_URL_Get used to construct URLs.
    (Please also see the SAP documentation: http://help.sap.com/saphelp_nw04/helpdata/en/b4/0fa239cec06b40e10000000a11402f/content.htm)
    In BI7 this command seems to be not existent.
    But as it is such a basic functionality I can’t believe that is not available anymore.
    I guess it is replaced by another command.
    Could you help us to find a functionality that replaces the SAP_BW_URL_Get command?

    Hi Andrew,
    Did you manage to find any solution for this one?
    Currently we are also facing the same problem.
    Thank you in advance.
    Best regards,
    Fen

  • Sending a variable from one class to another?

    Dear Java Users - please can you help me out here... I know that what I am asking should be straight forward BUT I just don't understand any of the responses people have put on the web....
    Here is what I am trying to do:
    This piece of code - creates a window with a simple textbox on it to enter a word...
    The button then calls another class file to open a new window...
    All I want to do is to take the word from the text box and print it in the new window....
    The first .java file I have is this:
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class FrontPageGUI extends JFrame implements ActionListener
         //declare all instance variables for THIS per class
              JLabel lblInfoOne;
              JLabel lblButtonPopUp;
              JTextField txtName;
              JButton close;
              JButton popUp;
         public FrontPageGUI()
              //set characteristics of the JFrame object
              super("Title Bar");
              setSize(600,600);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              setVisible(true);
              //we need to define a Container to place objects onto the frame - this is inside the JFrame Object Above
              Container ca = getContentPane( );
              ca.setSize(600,600);
              ca.setBackground(Color.white);
              ca.setLayout(null);                
              //define all other objects and set thier characteristics
              lblInfoOne     = new JLabel("Enter a word in the box above to send:");
              lblButtonPopUp = new JLabel("Click Here:");
              txtName          = new JTextField("");
              //create Button components
              close = new JButton("Close");
              popUp = new JButton("Click Me");
              //now add all objects to the container
              //Labels
              addXY(ca,lblInfoOne, 30, 160, 550,45);
              addXY(ca,lblButtonPopUp, 30, 210, 550,45);
              //TextField
              addXY(ca,txtName, 120, 100, 200,30);
              //Buttons
              addButtonXY(ca, popUp, 30, 260, 200, 45);
              addButtonXY(ca, close, 30, 310, 80, 30);
              // add the Container to the Frame     
              setContentPane(ca);          
         void addButtonXY(Container c, JButton cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               cp.addActionListener(this);
               c.add(cp);     
         void addXY(Container c, Component cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               c.add(cp);
         public void actionPerformed(ActionEvent event)
              if (event.getSource()== popUp)
                   //This is WHERE THE PROBLEM IS...
                   //Here I want to send to contents of the textfield - txtName
                   String temp = txtName.getText();
                   new PopUpGUI(temp);
              if (event.getSource()==close)
                   closeUp();
         void closeUp()
              System.exit(0);
              //dispose();
    //we need a driver program - this is the only time MAIN is used.
    public class FrontPage
         //create an instance of the GUI and showit
         public static void main(String args [])
              new FrontPageGUI();
                   The second .java file I have is this:
    import java.io.*;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    class PopUpGUI extends JFrame implements ActionListener
         //declare all instance variables ie per class
              JLabel headerLabel;
              JLabel sentLabel;          
              JButton close;
         public PopUpGUI(String Sent)
              //set characteristics of the JFrame object
              super("Pop Up Window");
              setSize(320,450);
              setVisible(true);
              //need to define a Container to place objects onto the frame
              Container ca = getContentPane( );
              ca.setSize(320,450);
              ca.setLayout(null);                
              //define all other objects and set characteristics
              headerLabel = new JLabel("New Window!"); //heading label
              sentLabel = new JLabel(Sent);
              close = new JButton("Close");
              //now add all objects to the container
              addXY(ca,headerLabel,10,10,380,80);
              addXY(ca,sentLabel,10,100,380,80);
              addButtonXY(ca, close, 50, 200, 100, 30); //Bottom Left
              // add the Container to the Frame     
              setContentPane(ca);
         //We need these 2 methods - EVERY TIME
         void addButtonXY(Container c, JButton cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               cp.addActionListener(this);
               c.add(cp);     
         void addXY(Container c, Component cp, int x, int y, int w, int h)
               cp.setBounds(x,y,w,h);
               c.add(cp);
         //What to do when the click happens
         public void actionPerformed(ActionEvent event)
              if (event.getSource()==close)
                   dispose();
                   //closeUp(); - Doesn't run CLOSEUP this time (i.e. exit program) - instead just DISPOSEs of the window
    //Driver class is in FrontPage.javaThis seems to work... but is it the best way to do it????
    Tony.

    Well,
    Using the constructor is the way to go. Otherwise create a method that takes the string as parameter.

Maybe you are looking for

  • Don't function applet

    Hello, I have problem, this applet shows error. How to fix it? I need this applet for school project. Thank you. [http://www.uvm.edu/~mfuris/INTRO_PHYSLETS/contents/optics/refraction/prob34_2.html]

  • Dropped my iPhone, white screen, have AppleCare service

    I am such a dumb duck for dropping my iPhone while playing tennis, and now, my phone is just a white screen. I have a AppleCare service for my iPhone, so does that cover my phone for damage?

  • Organize / create folder in archive?

    I notice that I can not drop individual email in the archive folder but I can not create any folder in there. I'm trying to move some folders that I no longer need to see everyday in the archive folder

  • With Muti-clip gone from FCP X, is there a new way to sync two cameras with FCP X

    With Muti-clip gone from FCP X, is there a new way to sync two cameras with FCP X

  • Battery updater

    Hi, do you know if is possible determinate the issue period of a battery from its serial number? I've downloaded yesterday battery updater, my PB is in range of updating but I don't remember if the application has started or not. I've bought on aucti