Moving a method from one class to another issues

Hi, im new. Let me explain what i am trying to achieve. I am basically trying to move a method from one class to another in order to refactor the code. However every time i do, the program stops working and i am struggling. I have literally tried 30 times these last two days. Can some one help please? If shown once i should be ok, i pick up quickly.
Help would seriously be appreciated.
Class trying to move from, given that this is an extraction:
class GACanvas extends Panel implements ActionListener, Runnable {
private WorldMenuItems speedMenuItems, designMenuItemsPlantGrowth, designMenuItemsPlantCount;
     private WorldMenuItems designMenuItemsPlantEaten, designMenuItemsApproximatePopulation;
     private WorldMenuItems designMenuItemsEatersBorn,designMenuItemsMutationProbability;
     private WorldMenuItems designMenuItemsCrossoverProbability;
MenuBar getMenuBar() {
          menuBar = new MenuBar();
          addControlItemsToMenuBar();
          addSpeedItemsToMenuBar();
          addWorldDesignItemsToMenuBar();
          return menuBar;
This is the method i am trying to move (below)
public void itemsInsideWorldDesignMenu() {
          designMenuItemsPlantGrowth = new WorldMenuItems("Plants Grow",
                    new String[] { "In Rows", "In Clumps", "At Random",
                              "Along the Bottom", "Along the Edges" }, 1);
          designMenuItemsPlantCount = new WorldMenuItems("Number Of Plants",
                    new String[] { "50", "100", "150", "250", "500" }, 3);
          designMenuItemsPlantEaten = new WorldMenuItems("When a Plant is Eaten",
                    new String[] { "It grows back somewhere",
                              "It grows back nearby", "It's Gone" }, 0);
          designMenuItemsApproximatePopulation = new WorldMenuItems(
                    "Approximate Population", new String[] { "10", "20", "25",
                              "30", "40", "50", "75", "100" }, 2);
          designMenuItemsEatersBorn = new WorldMenuItems("Eaters are Born",
                    new String[] { "At the Center", "In a Corner",
                              "At Random Location", "At Parent's Location" }, 2);
          designMenuItemsMutationProbability = new WorldMenuItems(
                    "Mutation Probability", new String[] { "Zero", "0.25%", "0.5%",
                              "1%", "2%", "3%", "5%", "10%" }, 3);
          designMenuItemsCrossoverProbability = new WorldMenuItems(
                    "Crossover Probability", new String[] { "Zero", "10%", "25%",
                              "50%", "75%", "100%" }, 4);
Class Trying to move to:
class WorldMenuItems extends Menu implements ItemListener {
   private CheckboxMenuItem[] items;
   private int selectedIndex = -1;
   WorldMenuItems(String menuName, String[] itemNames) {
      this(menuName, itemNames, -1);
   WorldMenuItems(String menuName, String[] itemNames, int selected) {
      super(menuName);
      items = new CheckboxMenuItem[itemNames.length];
      for (int i = 0; i < itemNames.length; i++) {
         items[i] = new CheckboxMenuItem(itemNames);
add(items[i]);
items[i].addItemListener(this);
selectedIndex = selected;
if (selectedIndex < 0 || selectedIndex >= items.length)
selectedIndex = 1;
items[selectedIndex].setState(true);
     public int getSelectedIndex() {
          return selectedIndex;
public void itemStateChanged(ItemEvent evt) {  // This works on other systems
CheckboxMenuItem newSelection = (CheckboxMenuItem)evt.getSource();
for (int i = 0; i < items.length; i++) {
if (newSelection == items[i]) {
items[selectedIndex].setState(false);
selectedIndex = i;
newSelection.setState(true);
return;

Ok i've done this. I am getting an error on the line specified. Can someone help me out and tell me what i need to do?
GACanvas
//IM GETTING AN ERROR ON THIS LINE UNDER NAME, SAYING IT IS NOT VISIBLE
WorldMenuItems worldmenuitems = new WorldMenuItems(name, null);
public MenuBar getMenuBar() {
          menuBar = new MenuBar();
          addControlItemsToMenuBar();
          addSpeedItemsToMenuBar();
          worldmenuitems.addWorldDesignItemsToMenuBar();
          return menuBar;
class WorldMenuItems extends Menu implements ItemListener {
     private WorldMenuItems speedMenuItems, designMenuItemsPlantGrowth, designMenuItemsPlantCount;
     private WorldMenuItems designMenuItemsPlantEaten, designMenuItemsApproximatePopulation;
     private WorldMenuItems designMenuItemsEatersBorn,designMenuItemsMutationProbability;
     private WorldMenuItems designMenuItemsCrossoverProbability;
     GACanvas gacanvas = new GACanvas(null);
   private CheckboxMenuItem[] items;
   private int selectedIndex = -1;
   WorldMenuItems(String menuName, String[] itemNames) {
      this(menuName, itemNames, -1);
   WorldMenuItems(String menuName, String[] itemNames, int selected) {
      super(menuName);
      items = new CheckboxMenuItem[itemNames.length];
      for (int i = 0; i < itemNames.length; i++) {
         items[i] = new CheckboxMenuItem(itemNames);
add(items[i]);
items[i].addItemListener(this);
selectedIndex = selected;
if (selectedIndex < 0 || selectedIndex >= items.length)
selectedIndex = 1;
items[selectedIndex].setState(true);
     public int getSelectedIndex() {
          return selectedIndex;
public void itemStateChanged(ItemEvent evt) {  // This works on other systems
CheckboxMenuItem newSelection = (CheckboxMenuItem)evt.getSource();
for (int i = 0; i < items.length; i++) {
if (newSelection == items[i]) {
items[selectedIndex].setState(false);
selectedIndex = i;
newSelection.setState(true);
return;
public void itemsInsideWorldDesignMenu() {
     designMenuItemsPlantGrowth = new WorldMenuItems("Plants Grow",
               new String[] { "In Rows", "In Clumps", "At Random",
                         "Along the Bottom", "Along the Edges" }, 1);
     designMenuItemsPlantCount = new WorldMenuItems("Number Of Plants",
               new String[] { "50", "100", "150", "250", "500" }, 3);
     designMenuItemsPlantEaten = new WorldMenuItems("When a Plant is Eaten",
               new String[] { "It grows back somewhere",
                         "It grows back nearby", "It's Gone" }, 0);
     designMenuItemsApproximatePopulation = new WorldMenuItems(
               "Approximate Population", new String[] { "10", "20", "25",
                         "30", "40", "50", "75", "100" }, 2);
     designMenuItemsEatersBorn = new WorldMenuItems("Eaters are Born",
               new String[] { "At the Center", "In a Corner",
                         "At Random Location", "At Parent's Location" }, 2);
     designMenuItemsMutationProbability = new WorldMenuItems(
               "Mutation Probability", new String[] { "Zero", "0.25%", "0.5%",
                         "1%", "2%", "3%", "5%", "10%" }, 3);
     designMenuItemsCrossoverProbability = new WorldMenuItems(
               "Crossover Probability", new String[] { "Zero", "10%", "25%",
                         "50%", "75%", "100%" }, 4);
public void addWorldDesignItemsToMenuBar() {
     gacanvas = new GACanvas(null);
     itemsInsideWorldDesignMenu();
     Menu designMenuItems = new Menu("WorldDesign");
     designMenuItems.add(designMenuItemsPlantGrowth);
     designMenuItems.add(designMenuItemsPlantCount);
     designMenuItems.add(designMenuItemsPlantEaten);
     designMenuItems.add(designMenuItemsApproximatePopulation);
     designMenuItems.add(designMenuItemsEatersBorn);
     designMenuItems.add(designMenuItemsMutationProbability);
     designMenuItems.add(designMenuItemsCrossoverProbability);
     gacanvas.menuBar.add(designMenuItems);

Similar Messages

  • Calling Parameterized Method from one class to another class

    Hi, below is my sample code
    test.java
    public class test
         int op1[][]=new int[][]{{1,2},{2,3},{4,5}};
         int row=0;
        public void  test() {
              int op2[][]=new int[][]{{2,3},{4,5},{6,7}};
                             row=1010;
              getRow(row);
        int[][] getList()
             return op1;
       public  int getRow(int klm)
             System.out.println("Row Value in GetRow Method  is:     "+row);
             return klm;
    test_2.java
    package aa;
    public class test_2
    int a;
         test t11=new test();
         int abc[][] = t11.getList();
         int rowCount=t11.getRow(a);
         public void test_2()
              System.out.println("Row Value is:     "+rowCount);
              System.out.println("Value in abc[1][1] is:     "+abc[0][1]);
    main_class.java
    package aa;
    public class main_class {
         public static void main(String args[])
              test ab=new test();
              ab.test();
              test_2 ba=new test_2();
              ba.test_2();
        public main_class() {
    }now that my question is,for 'rowCount' in class test_2.java i need to get the value of 'row'(which is 1010)from class test.java. How could that be done?
    Any reply is highly appreciable.
    Thanks in advance

    netbeans2eclipse wrote:
    hmm, i did chaged the test object in main method to same as the test object that i used in test_2 (ie; i changed test ab=new test() in main_class.java to test t1=new test()).What? How does this help?
    Again, simplify the problem
    For instance, say you have a class, Fubar1, like so:
    class Fubar1
      int value = 0;
      public void setValue(int v)
        value = v;
      public int getValue()
        return value;
    }and two different Fubar2 classes, both which try to get the value from Fubar1, one doing it badly:
    class Fubar2Bad
      Fubar1 f1 = new Fubar1(); // totally internal Fubar1 object
      public int getFubar1Value()
        return f1.getValue();
    }and one that does it well, that holds a reference to whatever Fubar1 object is passed to it:
    class Fubar2Good
      Fubar1 f1;
      public Fubar2Good(Fubar1 f1)
        this.f1 = f1;
      public int getFubar1Value()
        return f1.getValue();
    }Then if you test these:
    public class TestFubars
      public static void main(String[] args)
        Fubar1 f1 = new Fubar1();
        f1.setValue(35);
        Fubar2Bad f2Bad = new Fubar2Bad();
        Fubar2Good f2Good = new Fubar2Good(f1); // here we pass a reference to the main's Fubar1 object into the Fubar2Good object.
        System.out.println("Bad: " + f2Bad.getFubar1Value());
        System.out.println("Good: " + f2Good.getFubar1Value());
    }

  • Calling a drawLine() from one class to another from an ActionEvent

    I have several JPanel objects called and placed on a JFrame. The JFrame has a RadioButton group with radio buttons. If I select a radio button and call a drawLine() method from a JPanel, I receive a "NullPointerException". Is it not possible to call this graphic method from one class to another?
    Thanks for any input you can provide.
    John

    Remember that each panel draws it's own current state. So you need the ActionPerformed to change the state in your target panel.
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.geom.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class PanelComm extends JPanel {
      private SubPanelOne subPanelOne = new SubPanelOne();
      private SubPanelTwo subPanelTwo = new SubPanelTwo();
      public class SubPanelOne extends JPanel {
        public SubPanelOne () {
          setLayout ( new BorderLayout() );
          setBorder ( BorderFactory.createTitledBorder ( "SubPanel One" ) );
          Reactor     reactor    = new Reactor();
          ButtonGroup group      = new ButtonGroup();
          JPanel      radioPanel = new JPanel(new GridLayout(0, 1));
          JRadioButton buttonOne = new JRadioButton ( "One" );
          buttonOne.addActionListener ( reactor );
          group.add ( buttonOne );
          radioPanel.add ( buttonOne );
          JRadioButton buttonTwo = new JRadioButton ( "Two" );
          buttonTwo.addActionListener ( reactor );
          group.add ( buttonTwo );
          radioPanel.add ( buttonTwo );
          JRadioButton buttonThree = new JRadioButton ( "Three" );
          buttonThree.addActionListener ( reactor );
          group.add ( buttonThree );
          radioPanel.add ( buttonThree );
          add ( radioPanel ,BorderLayout.LINE_START );
        protected void paintComponent ( Graphics _g ) {
          super.paintComponent ( _g );
          Graphics2D g = (Graphics2D)_g;
          g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
      public class SubPanelTwo extends JPanel {
        private JLabel text = new JLabel();
        public SubPanelTwo () {
          setLayout ( new BorderLayout() );
          setBorder ( BorderFactory.createTitledBorder ( "SubPanel Two" ) );
          text.setFont ( new Font ( "Verdana" ,Font.PLAIN ,30 ) );
          text.setHorizontalAlignment ( JLabel.CENTER );
          add ( text ,BorderLayout.CENTER );
        protected void paintComponent ( Graphics _g ) {
          super.paintComponent ( _g );
          Graphics2D g = (Graphics2D)_g;
          g.setRenderingHint ( RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON );
        public void setChoice ( String cmd ) {
          text.setText ( cmd );
      public class Reactor implements ActionListener {
        public void actionPerformed ( ActionEvent e ) {
          subPanelTwo.setChoice ( e.getActionCommand() );
      public PanelComm () {
        setLayout ( new GridLayout ( 1 ,2 ) );
        add ( subPanelOne );
        add ( subPanelTwo );
      //  main
      public static void main ( String[] args ) {
        JFrame f = new JFrame ( "Panel Communication" );
        f.setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
        f.getContentPane().add ( new PanelComm() ,BorderLayout.CENTER );
        f.setSize ( 320 ,120 );
        f.setVisible ( true );
      }  // main
    }

  • 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

  • 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.

  • I have over 200 hours of HD video on 5 different TB Thunderbolt GRaid hard drives. I need to reorganize my projects, moving large files from one drive to another. Advice?

    I have over 200 hours of HD video on 5 different TB Thunderbolt GRaid hard drives. I need to reorganize my projects, moving large files from one drive to another. Advice?

    Do some testing to get your method working right with some less than important footage.
    Copy/paste files where you want then.
    Use the FCE Reconnect feature to tell FCE where the newly copied files reside.
    Make sure the new location and files are working as expected with your Projects.
    Delete the original files if no longer required.
    Al

  • How to transter contents of itab from one class to another...

    Hello experts,
    I am currently having problems on how to transfer the contents of an itab or even
    the value of a variable from one class to another. For example, I have 10 records
    in it_spfli in class 1 and when I loop at it_spfli in the method of class 2 it has no records!
    This is an example:
    class lcl_one definition.
    public section.
    data: gt_spfli type table of spfli.
    methods get_data.
    endclass.
    class lcl_one implementation.
    method get_data.
      select * from spfli
      into table gt_spfli.
    endmethod.
    endclass.
    class lcl_two definition inheriting from lcl_one.
    public section.
      methods loop_at_itab.
    endclass.
    class lcl_two implementation.
    method loop_at_itab.
      field-symbols: <fs_spfli> like line of gt_spfli.
      loop at gt_spfli assigning <fs_spfli>.
       write: / <fs_spfli>-carrid.
      endloop.
    endmethod.
    endclass.
    start-of-selection.
    data: one type ref to lcl_one,
          two type ref to lcl_two.
    create object: one, two.
    call method one->get_data.
    call method two->loop_at_itab.
    In the example above, the contents of gt_spfli in class lcl_two is empty
    even though it has records in class lcl_one. Help would be appreciated.
    Thanks a lot guys and take care!

    Hi Uwe,
    It is still the same. Here is my code:
    REPORT zfi_ors_sms
           NO STANDARD PAGE HEADING
           LINE-SIZE 255
           LINE-COUNT 65
           MESSAGE-ID zz.
    Include program/s                            *
    INCLUDE zun_standard_routine.           " Standard Routines
    INCLUDE zun_header.                     " Interface Header Record
    INCLUDE zun_footer.                     " Interface Footer Record
    INCLUDE zun_interface_control.          " Interface Control
    INCLUDE zun_external_routine.           " External Routines
    INCLUDE zun_globe_header.               " Report header
    INCLUDE zun_bdc_routine.                " BDC Routine
    Data dictionary table/s                      *
    TABLES: bkpf,
            rf05a,
            sxpgcolist.
    Selection screen                             *
    SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-001.
    PARAMETERS: p_file TYPE sxpgcolist-parameters.
    SELECTION-SCREEN END OF BLOCK b1.
    */ CLASS DEFINITIONS
          CLASS lcl_main DEFINITION
    CLASS lcl_main DEFINITION ABSTRACT.
      PUBLIC SECTION.
    Structure/s                                  *
        TYPES: BEGIN OF t_itab,
                rec_content(100) TYPE c,
               END OF t_itab.
        TYPES: BEGIN OF t_upfile,
                record_id(2)    TYPE c,            " Record ID
                rec_date(10)    TYPE c,            " Record Date MM/DD/YYYY
                prod_line(10)   TYPE c,            " Product Line
                acc_code(40)    TYPE c,            " Acc Code
                description(50) TYPE c,            " Description
                hits(13)        TYPE c,            " Hits
                amount(15)      TYPE c,            " Amount
               END OF t_upfile.
    Internal table/s                             *
        DATA: gt_bdcdata    TYPE STANDARD TABLE OF bdcdata,
              gt_bdcmsgcoll TYPE STANDARD TABLE OF bdcmsgcoll,
              gt_itab       TYPE STANDARD TABLE OF t_itab,
              gt_header     LIKE TABLE OF interface_header,
              gt_footer     LIKE TABLE OF interface_footer,
              gt_upfile     TYPE STANDARD TABLE OF t_upfile.
    Global variable/s                            *
        DATA: gv_target             TYPE rfcdisplay-rfchost,
              gv_err_flag(1)        TYPE n VALUE 0,
              gv_input_dir(100)     TYPE c
                                     VALUE '/gt/interface/FI/ORS/inbound/',
              gv_inputfile_dir(255) TYPE c,
              gv_eof_flag           TYPE c VALUE 'N',
              gv_string             TYPE string,
              gv_delimiter          TYPE x VALUE '09',
              gv_input_records(3)   TYPE n,
              gv_input_file_ctr(6)  TYPE n,
              gv_proc_tot_amt(14)   TYPE p DECIMALS 2,
              gv_prg_message        TYPE string,
              gv_gjahr              TYPE bkpf-gjahr,
              gv_monat              TYPE bsis-monat.
    Work area/s                                  *
        DATA: wa_itab               LIKE LINE OF gt_itab,
              wa_upfile             LIKE LINE OF gt_upfile,
              wa_footer             LIKE LINE OF gt_footer,
              wa_header             LIKE LINE OF gt_header.
    ENDCLASS.
          CLASS lcl_read_app_server_file DEFINITION
    CLASS lcl_read_app_server_file DEFINITION INHERITING FROM lcl_main.
      PUBLIC SECTION.
        METHODS: read_app_server_file,
                 read_input_file,
                 split_header,
                 process_upload_file,
                 split_string,
                 conv_num CHANGING value(amount) TYPE t_upfile-amount,
                 split_footer,
                 update_batch_control,
                 process_data.
    ENDCLASS.
          CLASS lcl_process_data DEFINITION
    CLASS lcl_process_data DEFINITION INHERITING FROM
                                                 lcl_read_app_server_file.
      PUBLIC SECTION.
        METHODS process_data REDEFINITION.
    ENDCLASS.
    */ CLASS IMPLEMENTATIONS
          CLASS lcl_read_app_server_file IMPLEMENTATION
    CLASS lcl_read_app_server_file IMPLEMENTATION.
    */ METHOD read_app_server_file  -  MAIN METHOD
      METHOD read_app_server_file.
        gv_target = sy-host.
        PERFORM file_copy USING 'ZPPDCP' p_file 'HP-UX'
                gv_target CHANGING gv_err_flag.
        CONCATENATE gv_input_dir p_file INTO gv_inputfile_dir.
      open application server file
        PERFORM open_file USING gv_inputfile_dir 'INPUT'
                                   CHANGING gv_err_flag.
        WHILE gv_eof_flag = 'N'.
          READ DATASET gv_inputfile_dir INTO wa_itab.
          APPEND wa_itab TO gt_itab.
          IF sy-subrc <> 0.
            gv_eof_flag = 'Y'.
            EXIT.
          ENDIF.
          CALL METHOD me->read_input_file.
        ENDWHILE.
      close application file server
        PERFORM close_file USING gv_inputfile_dir.
        IF wa_footer-total_no_rec <> gv_input_file_ctr.
          MOVE 'Header Control on Number of Records is Invalid' TO
               gv_prg_message.
          PERFORM call_ws_message USING 'E' gv_prg_message 'Error'.
          gv_err_flag = 1.
        ELSEIF wa_footer-total_no_rec EQ 0 AND gv_input_file_ctr EQ 0.
          MOVE 'Input File is Empty. Batch Control will be Updated' TO
               gv_prg_message.
          PERFORM call_ws_message USING 'I' gv_prg_message 'Information'.
          CALL METHOD me->update_batch_control.
          gv_err_flag = 1.
        ENDIF.
        IF gv_err_flag <> 1.
          IF wa_footer-total_amount <> gv_proc_tot_amt.
            MOVE 'Header Control on Amount is Invalid' TO gv_prg_message.
            PERFORM call_ws_message USING 'E' gv_prg_message 'Error'.
            gv_err_flag = 1.
          ENDIF.
        ENDIF.
      ENDMETHOD.
    */ METHOD read_input_file
      METHOD read_input_file.
        CASE wa_itab-rec_content+0(2).
          WHEN '00'.
            CALL METHOD me->split_header.
          WHEN '01'.
            CALL METHOD me->process_upload_file.
            ADD 1 TO gv_input_file_ctr.
            ADD wa_upfile-amount TO gv_proc_tot_amt.
          WHEN '99'.
            CALL METHOD me->split_footer.
          WHEN OTHERS.
            gv_err_flag = 1.
        ENDCASE.
      ENDMETHOD.
    */ METHOD split_header
      METHOD split_header.
        CLEAR: wa_header,
               gv_string.
        MOVE wa_itab TO gv_string.
        SPLIT gv_string AT gv_delimiter INTO
              wa_header-record_id
              wa_header-from_system
              wa_header-to_system
              wa_header-event
              wa_header-batch_no
              wa_header-date
              wa_header-time.
        APPEND wa_header TO gt_header.
      ENDMETHOD.
    */ METHOD process_upload_file
      METHOD process_upload_file.
        CLEAR gv_string.
        ADD 1 TO gv_input_records.
        MOVE wa_itab-rec_content TO gv_string.
        CALL METHOD me->split_string.
        CALL METHOD me->conv_num CHANGING amount = wa_upfile-amount.
        APPEND wa_upfile TO gt_upfile.
      ENDMETHOD.
    */ METHOD split_string
      METHOD split_string.
        CLEAR wa_upfile.
        SPLIT gv_string AT gv_delimiter INTO
              wa_upfile-record_id
              wa_upfile-rec_date
              wa_upfile-prod_line
              wa_upfile-acc_code
              wa_upfile-description
              wa_upfile-hits
              wa_upfile-amount.
      ENDMETHOD.
    */ METHOD conv_num
      METHOD conv_num.
        DO.
          REPLACE gv_delimiter WITH ' ' INTO amount.
          IF sy-subrc <> 0.
            EXIT.
          ENDIF.
        ENDDO.
      ENDMETHOD.
    */ METHOD split_footer
      METHOD split_footer.
        CLEAR: wa_footer,
               gv_string.
        MOVE wa_itab TO gv_string.
        SPLIT gv_string AT gv_delimiter INTO
              wa_footer-record_id
              wa_footer-total_no_rec
              wa_footer-total_amount.
        CALL METHOD me->conv_num CHANGING amount = wa_footer-total_amount.
        APPEND wa_footer TO gt_footer.
      ENDMETHOD.
    */ METHOD update_batch_control
      METHOD update_batch_control.
        DATA: lv_sys_date      TYPE sy-datum,
              lv_sys_time      TYPE sy-uzeit,
              lv_temp_date(10) TYPE c.
        CONCATENATE wa_header-date4(4) wa_header-date2(2)
                    wa_header-date+0(2)
               INTO lv_temp_date.
        MOVE lv_temp_date TO wa_header-date.
        APPEND wa_header-date TO gt_header.
      Update ZTF0001 Table
        PERFORM check_interface_header USING wa_header 'U' 'GLOB'
                                       CHANGING gv_err_flag.
      Archive files
        PERFORM archive_files USING 'ZPPDARC' gv_inputfile_dir 'HP-UX'
                gv_target CHANGING gv_err_flag.
      ENDMETHOD.
      METHOD process_data.
        SORT gt_upfile ASCENDING.
        CLEAR wa_upfile.
        READ TABLE gt_upfile INDEX 1 INTO wa_upfile.
        IF sy-subrc = 0.
          MOVE: wa_upfile-rec_date+6(4) TO gv_gjahr,
                wa_upfile-rec_date+0(2) TO gv_monat.
        ENDIF.
      ENDMETHOD.
    ENDCLASS.
          CLASS lcl_process_data IMPLEMENTATION
    CLASS lcl_process_data IMPLEMENTATION.
      METHOD process_data.
        CALL METHOD super->process_data.
        IF NOT gt_upfile[] IS INITIAL.
        ENDIF.
      ENDMETHOD.
    ENDCLASS.
    Start of selection                           *
    START-OF-SELECTION.
      DATA: read TYPE REF TO lcl_read_app_server_file,
            process TYPE REF TO lcl_process_data.
      CREATE OBJECT: read, process.
      CALL METHOD read->read_app_server_file.
      CALL METHOD process->process_data.

  • 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

  • Fire event from one class to another.

    I have a Login JFrame class that allows users to enter username and password. I then have another JFrame class which will monitor when someone logs in. I am trying to get the username and password to appear on the monitor login frame text area when the user presses enter on the login frame.
    I can get it ot work by passing the Monitor class into the Login classes constructor but I want to be able to open the classes separately.When I try to open separatley at present I get java.lang.NullPointerException
         at project.LoginGUI.actionPerformed(LoginGUI.java:70) which is referring to the following code:      
    if(listen.equals("OK")){
         GymMonitor.username.setText(username.getText());     
    Both classes are in the same package. What I want to know is how to fire an event from one class to another? when the class you are firing to is constructed separately.
    I hope this question is not too verbose.
    Thanks

    Generally for something like this you would use a listener.
    Your login window is its own entity--it has a user interface, and it gets some information which someone else could ask it for. It could even generate its own events, such as when the user presses "OK". You would first define an interface for anyone who wants to know when someone logs in:
    public interface ILoginListener extends java.util.EventListener
      public void login(LoginEvent event);
    }You would then define the LoginEvent class to contain information like what the user entered for username and password. You could give your login dialog a couple of methods:
      private Vector myListeners = new Vector();
      public void addLoginListener(ILoginListener listener) {
        myListeners.add(listener);
      public void removeLoginListener(ILoginListener listener) {
        myListeners.remove(listener);
      protected void fireLogin(LoginEvent event) {
        for (Iterator it = myListeners.iterator(); it.hasNext(); ) {
          ILoginListener listener = (ILoginListener)it.next();
          listener.login(event);
      }You'd have your login dialog call fireLogin every time the user logged in.
    Then, you could implement ILoginListener in your monitor window:
      public void login(LoginEvent event) {
        // now do something with the event you just got.
      }All the code I put in here is really generic stuff. You'll write this kind of stuff hundreds of times probably during your career. I haven't tested it though.
    Hope this helps. :)

  • I bought a new laptop and used Windows Easy Transfer cable and moved all files from one computer to another. I installed iTunes and found my iTunes music Library.  However, when I plug in my iPod it says it is already synced with another iTunes Library.

    I bought a new laptop and used Windows Easy Transfer cable and moved all files from one computer to another. I installed iTunes and found my iTunes music Library.  However, when I plug in my iPod it says it is already synced with another iTunes Library. 
    I don't see anything in Help that shows when you already have transfered all the files over.  Why would it want to erase and sync when I already have all the music folder copied over?  I didn't have an issue when I had another technician copy from one laptop to another.  Home sharing is also on but not being recognized.

    I suspect you only migrated the media folder instead of the complete working library. Either review the transfer process and copy over the entire iTunes folder from your old profile's music folder or see Recovering your iTunes library from your iPod or iOS device.
    tt2

  • Passing a parameter from one class to another class in the same package

    Hi.
    I am trying to pass a parameter from one class to another class with in a package.And i am Getting the variable as null every time.In the code there is two classes.
    i. BugWatcherAction.java
    ii.BugWatcherRefreshAction.Java.
    We have implemented caching in the front-end level.But according to the business logic we need to clear the cache and again have to access the database after some actions are happened.There are another class file called BugwatcherPortletContent.java.
    So, we are dealing with three java files.The database interaction is taken care by the portletContent.java file.Below I am giving the code for the perticular function in the bugwatcherPortletContent.java:
    ==============================================================
    public Object loadContent() throws Exception {
    Hashtable htStore = new Hashtable();
    JetspeedRunData rundata = this.getInputData();
    String pId = this.getPorletId();
    PortalLogger.logDebug(" in the portlet content: "+pId);
    pId1=pId;//done by sraha
    htStore.put("PortletId", pId);
    htStore.put("BW_HOME_URL",CommonUtil.getMessage("BW.Home.Url"));
    htStore.put("BW_BUGVIEW_URL",CommonUtil.getMessage("BW.BugView.Url"));
    HttpServletRequest request = rundata.getRequest();
    PortalLogger.logDebug(
    "BugWatcherPortletContent:: build normal context");
    HttpSession session = null;
    int bugProfileId = 0;
    Hashtable bugProfiles = null;
    Hashtable bugData = null;
    boolean fetchProfiles = false;
    try {
    session = request.getSession(true);
    // Attempting to get the profiles from the session.
    //If the profiles are not present in the session, then they would have to be
    // obtained from the database.
    bugProfiles = (Hashtable) session.getAttribute("Profiles");
    //Getting the selected bug profile id.
    String bugProfileIdObj = request.getParameter("bugProfile" + pId);
    // Getting the logged in user
    String userId = request.getRemoteUser();
    if (bugProfiles == null) {
    fetchProfiles = true;
    if (bugProfileIdObj == null) {
    // setting the bugprofile id as -1 indicates "all profiles" is selected
    bugProfileIdObj =(String) session.getAttribute("bugProfileId" + pId);
    if (bugProfileIdObj == null) {
    bugProfileId = -1;
    else {
    bugProfileId = Integer.parseInt(bugProfileIdObj);
    else {
    bugProfileId = Integer.parseInt(bugProfileIdObj);
    session.setAttribute(
    ("bugProfileId" + pId),
    Integer.toString(bugProfileId));
    //fetching the bug list
    bugData =BugWatcherAPI.getbugList(userId, bugProfileId, fetchProfiles);
    PortalLogger.logDebug("BugWatcherPortletContent:: got bug data");
    if (bugData != null) {
    Hashtable htProfiles = (Hashtable) bugData.get("Profiles");
    } else {
    htStore.put("NoProfiles", "Y");
    } catch (CodedPortalException e) {
    htStore.put("Error", CommonUtil.getErrMessage(e.getMessage()));
    PortalLogger.logException
    ("BugWatcherPortletContent:: CodedPortalException!!",e);
    } catch (Exception e) {
    PortalLogger.logException(
    "BugWatcherPortletContent::Generic Exception!!",e);
    htStore.put(     "Error",CommonUtil.getErrMessage(ErrorConstantsI.GET_BUGLIST_FAILED));
    if (fetchProfiles) {
    bugProfiles = (Hashtable) bugData.get("Profiles");
    session.setAttribute("Profiles", bugProfiles);
    // putting the stuff in the context
    htStore.put("Profiles", bugProfiles);
    htStore.put("SelectedProfile", new Integer(bugProfileId));
    htStore.put("bugs", (ArrayList) bugData.get("Bugs"));
    return htStore;
    =============================================================
    And I am trying to call this function as it can capable of fetching the data from the database by "getbugProfiles".
    In the new class bugWatcherRefreshAction.java I have coded a part of code which actually clears the caching.Below I am giving the required part of the code:
    =============================================================
    public void doPerform(RunData rundata, Context context,String str) throws Exception {
    JetspeedRunData data = (JetspeedRunData) rundata;
    HttpServletRequest request = null;
    //PortletConfig pc = portlet.getPortletConfig();
    //String userId = request.getRemoteUser();
    /*String userId = ((JetspeedUser)rundata.getUser()).getUserName();//sraha on 1/4/05
    String pId = request.getParameter("PortletId");
    PortalLogger.logDebug("just after pId " +pId);  */
    //Calling the variable holding the value of portlet id from BugWatcherAction.java
    //We are getting the portlet id here , through a variable from BugWatcherAction.java
    /*BugWatcherPortletContent bgAct = new BugWatcherPortletContent();
    String portletID = bgAct.pId1;
    PortalLogger.logDebug("got the portlet ID in bugwatcherRefreshAction:---sraha"+portletID);*/
    // updating the bug groups
    Hashtable result = new Hashtable();
    try {
    request = data.getRequest();
    String userId = ((JetspeedUser)data.getUser()).getUserName();//sraha on 1/4/05
    //String pId = (String)request.getParameter("portletId");
    //String pId = pc.getPorletId();
    PortalLogger.logDebug("just after pId " +pId);
    PortalLogger.logDebug("after getting the pId-----sraha");
    result =BugWatcherAPI.getbugList(profileId, userId);
    PortalLogger.logDebug("select the new bug groups:: select is done ");
    context.put("SelectedbugGroups", profileId);
    //start clearing the cache
    ContentCacheContext cacheContext = getCacheContext(rundata);
    PortalLogger.logDebug("listBugWatcher Caching - removing markup content - before removecontent");
    // remove the markup content from cache.
    PortletContentCache.removeContent(cacheContext);
    PortalLogger.logDebug("listBugWatcher Caching-removing markup content - after removecontent");
    //remove the backend content from cache
    CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(((JetspeedUser)data.getUser()).getUserName()));
    PortalLogger.logDebug("listBugWatcher Caching User: " +((JetspeedUser)data.getUser()).getUserName());
    PortalLogger.logDebug("listBugWatcher Caching pId: " +pId);
    if (pdata != null)
    // User's data found in cache!
    PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null");
    pdata.removeObject(PortletCacheHelper.getUserPortletHandle(((JetspeedUser)data.getUser()).getUserName(),pId));
    PortalLogger.logDebug("listBugWatcher Caching -inside pdata!=null- after removeObject");
    PortalLogger.logDebug("listBugWatcher Caching -finish calling the remove content code");
    //end clearing the cache
    // after clearing the caching calling the data from the database taking a fn from the portletContent.java
    PortalLogger.logDebug("after clearing cache---sraha");
    BugWatcherPortletContent bugwatchportcont = new BugWatcherPortletContent();
    Hashtable httable= new Hashtable();
    httable=(Hashtable)bugwatchportcont.loadContent();
    PortalLogger.logDebug("after making the type casting-----sraha");
    Set storeKeySet = httable.keySet();
    Iterator itr = storeKeySet.iterator();
    while (itr.hasNext()) {
    String paramName = (String) itr.next();
    context.put(paramName, httable.get(paramName));
    PortalLogger.logDebug("after calling the databs data from hashtable---sraha");
    } catch (CodedPortalException e) {
    PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
    context.put("Error", CommonUtil.getErrMessage(e.getMessage()));
    catch (Exception e) {
    PortalLogger.logException("bugwatcherRefreshAction:: Exception- ",e);
    context.put(     "Error",CommonUtil.getErrMessage(ErrorConstantsI.EXCEPTION_CODE));
    try {
    ((JetspeedRunData) data).setCustomized(null);
    if (((JetspeedRunData) data).getCustomized() == null)
    ActionLoader.getInstance().exec(data,"controls.EndCustomize");
    catch (Exception e)
    PortalLogger.logException("bugwatcherRefreshAction", e);
    ===============================================================
    In the bugwatcher Action there is another function called PostLoadContent.java
    here though i have found the portlet Id but unable to fetch that in the bugWatcherRefreshAction.java . I am also giving the code of that function under the bugWatcherAction.Java
    ================================================
    // Get the PortletData object from intermediate store.
    CacheablePortletData pdata =(CacheablePortletData) PortletCache.getCacheable(PortletCacheHelper.getUserHandle(
    //rundata.getRequest().getRemoteUser()));
    ((JetspeedUser)rundata.getUser()).getUserName()));
    pId1 = (String)portlet.getID();
    PortalLogger.logDebug("in the bugwatcher action:"+pId1);
    try {
    Hashtable htStore = null;
    // if PortletData is available in store, get current portlet's data from it.
    if (pdata != null) {
    htStore =(Hashtable) pdata.getObject(     PortletCacheHelper.getUserPortletHandle(
    ((JetspeedUser)rundata.getUser()).getUserName(),portlet.getID()));
    //Loop through the hashtable and put its elements in context
    Set storeKeySet = htStore.keySet();
    Iterator itr = storeKeySet.iterator();
    while (itr.hasNext()) {
    String paramName = (String) itr.next();
    context.put(paramName, htStore.get(paramName));
    bugwatcherRefreshAction bRefAc = new bugwatcherRefreshAction();
    bRefAc.doPerform(pdata,context,pId1);
    =============================================================
    So this is the total scenario for the fetching the data , after clearing the cache and display that in the portal.I am unable to do that.Presently it is still fetching the data from the cache and it is not going to the database.Even the portlet Id is returning as null.
    I am unable to implement that thing.
    If you have any insight about this thing, that would be great .As it is very urgent a promt response will highly appreciated.Please send me any pointers or any issues for this I am unable to do that.
    Please let me know as early as possible.
    Thanks and regards,
    Santanu Raha.

    Have you run it in a debugger? That will show you exactly what is happening and why.

  • Moving multiple queries from one category to another in QM

    Hi All,
    Is there is any way of moving multiple queries from one category to another in the query manager?
    Or is the only way of doing it by saving each one individually into a different category.
    Any ideas ?
    Regards,
    Rakesh N

    Hi Rakesh,
    The query manager has limited function compare with normal file management applications. Under current design, you have to do this one by one. You just need to make sure move the smaller amount of queries to large category. Category name can be changed easily.
    Thanks,
    Gordon

  • Transfering text from one class to another

    Hi, I'm having a lot of trouble with getting the text from a textArea in a frame to transfer from one class to another.
    I could really use any help given.
    Thanks
    Here's where the text should come from
    import javax.swing.*;
    import BreezySwing.*;
    import java.util.*;
    public class UserFrame extends GBFrame {
    //String Design = null;
    private
       JTextArea InputArea = addTextArea
       ("...",1,1,1,1);
       JButton drawButton = addButton
       ("Draw" ,3,1,1,1);
    //  UserPanel dPanel = new UserPanel();
       GraphicsInputPanel dPanel = new GraphicsInputPanel();
       GBPanel panel = addPanel(dPanel, 1, 2, 1, 1);
       public void buttonClicked (JButton buttonObj){
          GraphicsInputPanel.setdesign(InputArea.getText());
    // rbPanel setDesign(graphicCodeArea.getText());
    public static void main(String[] args) {
    UserFrame tpo = new UserFrame();
    tpo.setSize(400, 300);
    tpo.setVisible(true);
    and here's where it should be going
    import BreezySwing.*;
    import java.awt.*;
    import java.util.*;
    public class GraphicsInputPanel extends GBPanel{
       String design;
       public void setdesign (String d){
          design = d;
       public void paintComponent (Graphics g){
          super.paintComponent(g);
          StringTokenizer lines = new StringTokenizer(design, "\n");
          while (lines.hasMoreTokens()){
             String line = lines.nextToken();
             if (design.equals ("Blue")){
                g.setColor(Color.blue);      
             }else if (design.equals("Green")){
                g.setColor(Color.green);
             g.fillRect(0,0,100,100);
         public void setDesign(String d){
          design = d;
          repaint();
    }

    Hello Saqib,
    The requirement to transfer asset with value date in the past year contradict the objective of audit trail established in the system although it is technically possible to do. Perhaps you should convince your client to adopt the standard approach, i.e. value date as at the date of asset transfer.
    Kind regards,
    John Chin

  • Moving CMS database from one server to another

    Using the following:
    Crystal Enterprise 10, installed on W2K3 Server R2 (not making any changes to this server);
    CMS database, installed on W2K Server, SQL Server 2000, SP3
    New database server: W2K3 Server R2, SQL Server 2005, SP2
    I found what I think are the steps to moving the database from one place to another in the CE10 Administrator's guide (pages 291-300, but I want to make sure there aren't any "gotchas" when moving the database location and/or upgrading the database version.  I'm primarily a DBA, so I already know about the Schema security change going from SQL 2000 to SQL 2005.
    In a nutshell, here's my plan:
    1. Take fresh backup of the existing CMS database
    2. Stop Crystal Management Server
    3. Click "Specify CMS Data Source" on the toolbar.
    4. ETC--following the steps in the admin guide
    If anyone has done this and has run into any problems (what I'm expecting) or had it go smoothly (I would be surprised), please let me know what to expect.
    Thanks!

    All you really need to do is stop the crystal services.
    Backup the CMS and Auditing database
    Detach the CMS and Auditing database
    Copy CMS and Auditing databases to new DB server
    Attach the CMS and Auditing databases
    Set the compatibility mode
    On the servers/s that host the CMS service, modify the ODBC connections to point to the new database server
    Start the CMS service, fire up the Crystal services.
    One thing to note, I don't think SQL 2005 is a supported platform for CE10 - this doesn't mean it won't work and since the support lifecycle for the product is long gone it doesn't really make much difference however you may want to run some thorough testing prior to the move.
    Edited by: James Pretorius (CCLTD) on Aug 5, 2009 9:20 PM

  • Methods of One Class In Another

    Can I make the methods of one class work in another?

    Thank you to all who responded so quickly. I want to be able to get information from my JTextFields in one class and put it into the Film class parameters of the class below. The film class is a JavaBean.
        import java.io.*;
    class SerializeFilm {
      public static void main(String args[]) {
        String [] actors = { "Harrison Ford", "Jean Connery" };
        String name= "Indiana Jones";
        Film film = new Film("Indiana Jones", "Aventure", 1989, actors, 2.0, 90);
        try {
          FileOutputStream file = new FileOutputStream(name + ".ser");
          ObjectOutputStream output = new ObjectOutputStream(file);
          output.writeObject(film);
          output.flush();
          output.close();
          } catch (IOException ex) {
             ex.printStackTrace();
    }

Maybe you are looking for