Retrieve method from class which extends JFrame

hi, i need some help with my program.
I have two class which both extends JFrame. The first class called security class and second class is available class.
In the SECURITY class, i create a button to operate the AVAILABLE class and it generate a result in method Count(). I want to view the result in Frame SECURITY by calling method count() but i could manage to do it. Could somebody help me how to manage this problem?
Thanks.

may be you could create a instance of the class you wanted to access method from or pass the instance from one class to another.
like this:
public class A extends JFrame
public B newB= new B();
public A(){}
public void someMethod()
newB.someOtherMethod();
public class B extends JFrame
public B(){}
public void someOtherMethod()
i hope it is what you are looking for

Similar Messages

  • Adding a JPanel from one class to another Class (which extends JFrame)

    Hi everyone,
    So hopefully I go about this right, and I can figure out what I'm doing wrong here. As an exercise, I'm trying to write a Tic-Tac-Toe (TTT) game. However, in the end it will be adaptable for different variations of TTT, so it's broken up some. I have a TTTGame.java, and TTTSquareFrame.java, and some others that aren't relavent.
    So, TTTGame:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import joshPack.jUtil.*;
    public class TTTGame extends JFrame
         private Integer sides = 3;
         private TTTSquareFrame mainSquare;
         private TTTGame newGame;
         private Container contents;
         private JPanel mainSquarePanel, addPanel;
         public static void main(String [] args)
              TTTGame newGame = new TTTGame();
              newGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TTTGame()
              super("Tic-Tac-Toe");
              contents = getContentPane();
              contents.setLayout(new FlowLayout());
              addPanel = startSimple();
              if(!addPanel.isValid())
                   System.out.println("Something's wrong");
              contents.add(addPanel);
              setSize(300, 300);
              setVisible(true);
         public JPanel startSimple()
              mainSquare = new TTTSquareFrame(sides);
              mainSquarePanel = mainSquare.createPanel(sides);
              return mainSquarePanel;
    }and TTTSquareFrame:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import joshPack.jUtil.Misc;
    public class TTTSquareFrame
         private JPanel squarePanel;
         private JButton [] squares;
         private int square, index;
         public TTTSquareFrame()
              System.out.println("Use a constructor that passes an integer specifying the size of the square please.");
              System.exit(0);
         public TTTSquareFrame(int size)
         public JPanel createPanel(int size)
              square = (int)Math.pow(size, 2);
              squarePanel = new JPanel();
              squarePanel.setLayout(new GridLayout(3,3));
              squares = new JButton[square];
              System.out.println(MIN_SIZE.toString());
              for(int i = 0; i < square; i++)
                   squares[i] = new JButton();
                   squares.setRolloverEnabled(false);
                   squares[i].addActionListener(bh);
                   //squares[i].setMinimumSize(MIN_SIZE);
                   squares[i].setVisible(true);
                   squarePanel.add(squares[i]);
              squarePanel.setSize(100, 100);
              squarePanel.setVisible(true);
              return squarePanel;
    }I've successfully added panels to JFrame within the same class, and this is the first time I'm modularizing the code this way. The issue is that the frame comes up blank, and I get the message "Something's wrong" and it says the addPanel is invalid. Originally, the panel creation was in the constructor for TTTSquareFrame, and I just added the mainSquare (from TTTGame class) to the content pane, when that didn't work, I tried going about it this way. Not exactly sure why I wouldn't be able to add the panel from another class, any help is greatly appreciated.
    I did try and cut out code that wasn't needed, if it's still too much let me know and I can try and whittle it down more. Thanks.

    Yea, sorry 'bout that, I just cut out the parts of the files that weren't relevant but forgot to compile it just to make sure I hadn't left any remnants of what I had removed. For whatever it's worth, I have no idea what changed, but something did and it is working now. Thanks for your help, maybe next time I'll post an actual question that doesn't somehow magically solve itself.
    EDIT: Actually, sorry, I've got the panel working now, but it's tiny. I've set the minimum size, and I've set the size of the panel, so...why won't it respond to that? It almost looks like it's being compressed into the top of the panel, but I'm not sure why.
    I've compressed the code into:
    TTTGame.java:
    import java.awt.*;
    import javax.swing.*;
    public class TTTGame extends JFrame
         private Integer sides = 3;
         private TTTSquareFrame mainSquare;
         private TTTGame newGame;
         private Container contents;
         private JPanel mainSquarePanel, addPanel;
         public static void main(String [] args)
              TTTGame newGame = new TTTGame();
              newGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TTTGame()
              super("Tic-Tac-Toe");
              contents = getContentPane();
              contents.setLayout(new FlowLayout());
              mainSquare = new TTTSquareFrame(sides.intValue());
              contents.add(mainSquare);
              setSize(400, 400);
              setVisible(true);
    }TTTSquareFrame.java
    import java.awt.*;
    import javax.swing.*;
    public class TTTSquareFrame extends JPanel
         private JButton [] squares;
         private int square, index;
         private final Dimension testSize = new Dimension(50, 50);
         public TTTSquareFrame(int size)
              super();
              square = (int)Math.pow(size, 2);
              super.setLayout(new GridLayout(size, size));
              squares = new JButton[square];
              for(int i = 0; i < square; i++)
                   squares[i] = new JButton();
                   squares.setMinimumSize(testSize);
                   squares[i].setVisible(true);
                   super.add(squares[i]);
              setSize(200, 200);
              setVisible(true);
    I've made sure the buttons are smaller than the size of the panel, and the panel is smaller than the frame, so...
    Message was edited by:
    macman104

  • Invoke a panel object in a class which extends JFrame

    I have a class LoginUI which extends JFrame and another class NewUserUI which extends JPanel. The LoginUI contains a button which when clicked should display the NewUserUI panel in a separate window. How should I invoke the NewUserUI object in the LoginUI class?

    One possibility would be the use of a JOptionPane containing the JPanel.
    Cheers
    DB

  • Japplet is not able to call a class that extends JFrame in internet Explore

    Hi
    I am doing an application on Japplet.The Japplet class calls anathor class which extends JFrame.When I am running this appication on Applet Viewer it works fine.but when I am running this aplication in internet Explorer the Frame window doesn't come.What might be the problem.
    Thanks
    Srikants

    There is no error or exceptio comming when i am running that application on Internet Explorer.Convert the html page to use the object tag instead of the applet tag.
    The IE build in jre (called msjvm) cannot display JFrame since the version is
    1.1.2 and it has no javax classes.
    Still problems?
    A Full trace might help us out:
    http://forum.java.sun.com/thread.jspa?threadID=656028

  • Writing a pause method in a class which extends TimerTask

    I run my method using this code:
    synchronized public void run() {
                  MainClass.myMethod();
             }and I want to run my method every 10 seconds so I do like this:
    public void start() {
                  try {
                      timer.scheduleAtFixedRate(getTimeOutControler(), new Date(), 10000);
                   } catch (Exception e) {
                        e.printStackTrace();
              }Now I want to push 2 buttons on a frame so when I click on "start" button the scheduled task begin and when I click on "pause" button the scheduled task pauses. how I can do this?

    I can see two solutions to this.
    1. You could add a volatile boolean paused flag which you could check in your run method (before it calls the MainClass.myMethod(). This won't actually pause the timer, but it will prevent the method from running. The major drawback I see with this is that if you un-pause then the timer could fire instantly, which may or may not be the desired behaviour.
    2. You could cancel the timer, and recreate it when you un-pause. This has the benefit of allowing the full time after you un-pause it (but again, it depends on the behaviour you require).

  • LoadClass    (error loading a class which extends other class  at run-time)

    Hey!
    I'm using the Reflection API
    I load a class called 'SubClass' which exists in a directory called 'subdir' at run-time from my program
    CustomClassLoader loader = new CustomClassLoader();
    Class classRef = loader.loadClass("SubClass");
    class CustomClassLoader extends ClassLoader. I have defined 'findClass(String className)' method in CustomClassLoader.
    This is what 'findClass(String className)' returns:
    defineClass (className,byteArray,0,byteArray.length);
    'byteArray' is of type byte[] and has the contents of subdir/SubClass.
    the problem:
    The program runs fine if SubClass does not extend any class.
    If however, SubClass extends another class, the program throws a NoClassDefFoundError. How is it conceptually different?
    Help appreciated in Advance..
    Thanks!

    Because i'm a newbie to the Reflection thing, i'm notI don't see reflection anywhere. All I see is class loading.
    sure what role does the superclass play when i'm
    trying to load the derived class and how to get away
    with the errorWell... hint: all the superclass's stuff is not copied into the subclass.
    I am quite sure it fails to load the superclass because of classpath issues.

  • Getting grid layout to work with a class that extends JFrame

    In my code, I have a class extending JFrame and setting the layout to grid works and the code to add with three parameters compiles just fine but when I run it I get this:
    java.lang.IllegalArgumentException: illegal component position
         at java.awt.Container.addImpl(Container.java:999)
         at java.awt.Container.add(Container.java:928)
         at javax.swing.JFrame.addImpl(JFrame.java:479)
         at java.awt.Container.add(Container.java:928)
    on the add(myLabel, 1, 1); line

    I see on these from
    http://java.sun.com/j2se/1.5.0/docs/api/java/awt/Container.html#add(java.awt.Component)
    1.public Component add(Component comp)
    2.public Component add(String name, Component comp)
    3.public Component add(Component comp, int index)
    you should use method add(...) of JPanel instead

  • How to call a method from class interface

    Hi ,
    I want to call a method from a 'class interface' in a BADI .
    Class Interface -- /SAPSRM/CL_PDO_DO_BASE
    Method -- /SAPSRM/IF_PDO_DO_PARTNER_BASE~UPDATE_ITEM_PARTNERS
    Please let me know how can I call this method in my BADI.
    Thanks-

    Hi Harmeet,
    Follow these simple steps.
    1. Create an instance of class interface /SAPSRM/CL_PDO_DO_BASE if method /SAPSRM/IF_PDO_DO_PARTNER_BASE~UPDATE_ITEM_PARTNERS is instance method and
    call instance -> /SAPSRM/IF_PDO_DO_PARTNER_BASE~UPDATE_ITEM_PARTNERS
    2.if method /SAPSRM/IF_PDO_DO_PARTNER_BASEUPDATE_ITEM_PARTNERS is static method ,call directly using class interface like /SAPSRM/CL_PDO_DO_BASE=> /SAPSRM/IF_PDO_DO_PARTNER_BASEUPDATE_ITEM_PARTNERS.
    If you feel any dificulty in declaring instances and call methods, 
    Goto EDIT-> Pattern ->ABAP Object Patterns, Give class name , instance name and method, you got the required code.
    Thanks,
    Prasad.

  • OO ABAP - Retrieve source from Class Builder?

    Hi. Is there a way to display the source code for a class or interface definition that was created with the class builder (se24).
    I looked through the drop downs, but I didn't see anything to display the source.
    Thanks in advance.
    Brendan

    A class is distributed upon several includes. The Se24 in my 45b system offers to view the source via button on the bottom of the method list.
    If you like you can try the following sample program also. Just paste the source and create the Pf-Status 'STA_MAIN' (line 135) and add the commands PICK(f2),Back, Exit, My_Edit(any key).
    PS: double clicking on a include navigates forward ( if PICK is set to F2 ).
    PPS: If you experience trouble with pasting the code and lost line termination, please paste into wordpad an save as text file.
    [code]
    report:   Ze80Lite
    created:  17.aug.2000
    purpose
    this report displays various informations of report-source files
    Change History
    #nn - dd.mmm.yyyy - Author
                         short description
    #00 - 17.aug.2000 - KZI
                         initial
    report Ze80Lite
      no standard page heading
      line-size 120
      message-id sx.
    *$ external types & constants =====================
    *======================================================================
    *$ local types ========================================================
    *======================================================================
    types:
      typ_source      type string,
      typ_source_tab  type standard table of typ_source,
      begin of typ_file_info,
        lsind         type syst-lsind,
        isvalid       type flag,
        r3state       type d010sinf-r3state,
        prgnam        type programm,
        srcnam        type programm,
        prgtyp        type d010sinf-subc,
      end of typ_file_info,
      begin of typ_line_info,
        flag_newline  type flag,
        flag_comment  type flag,
        text          type string,
      end of typ_line_info,
      begin of typ_method_info,
        methodname  type tmdir-methodname,
        methodindx  type tmdir-methodindx,
      end of typ_method_info,
      typ_method_info_tab type standard table of typ_method_info,
      typ_line_tab type standard table of typ_line_info.
    selection-screen begin of block sel1 with frame title text-s01.
    parameter:
      p_prgnam        type programm   obligatory,
      p_state         type d010sinf-r3state default 'I',
      p_typprg radiobutton group 0001 default 'X',
      p_typcla radiobutton group 0001,
      p_typifc radiobutton group 0001,
      p_typfct radiobutton group 0001,
      p_typmod radiobutton group 0001,
      p_typool radiobutton group 0001.
    selection-screen end of block sel1.
    constants:
      begin of gcr_rep,
        typ_prg   type  i          value 1,
        typ_cla   type  i          value 2,
        typ_ifc   type  i          value 3,
        typ_fct   type  i          value 4,
        typ_mod   type  i          value 5,
        typ_pool  type  i          value 6,
        max_modi  type  syst-lsind value 5,
        max_width type  i          value 80,
        mem_prg   type memoryid    value 'ST22_PRGNAME',
        mem_typ   type memoryid    value '91A',          " missuse
        mem_dir   type memoryid    value '91B',          " missuse
        mem_sta   type memoryid    value '91C',          " missuse
      end of gcr_rep.
    data:
      goa_file      type standard table of typ_file_info.
    =====================================================================
    *$ report eventing ====================================================
    =====================================================================
    initialization.
      perform sub_init.
    at selection-screen.
      perform sub_check.
    start-of-selection.
      perform sub_main.
    at line-selection.
      perform sub_click.
    at user-command.
      perform sub_command
        using sy-ucomm.
      sy-ucomm = ''.
    =====================================================================
    *$ subroutines ========================================================
    =====================================================================
    form   :  sub_main
    purp.  :  main entry point for procecssing
    param  :  <global>     from selectio screen
    rcode  :  ---
    hist.  :  #00 -  KZI - created
    form sub_main.
    data declaration
      data:
        lon_error          type i,
        lon_srctyp         type i,
        loc_srcnam         type programm,
        lor_file           type typ_file_info.
    init
      set pf-status 'STA_MAIN'.
      clear:
        lor_file,
        goa_file.
      do 10 times.
        append lor_file to goa_file[].
      enddo.
    get the type
      " keep in sync with parameter, sub_check, sub_init
      case 'X'.
        when p_typprg.
          lon_srctyp = gcr_rep-typ_prg.
        when p_typcla.
          lon_srctyp = gcr_rep-typ_cla.
        when p_typifc.
          lon_srctyp = gcr_rep-typ_ifc.
        when p_typfct.
          lon_srctyp = gcr_rep-typ_fct.
        when p_typmod.
          lon_srctyp = gcr_rep-typ_mod.
        when p_typool.
          lon_srctyp = gcr_rep-typ_pool.
        when others.
          lon_srctyp = gcr_rep-typ_prg.
      endcase.
    get true name
      perform sub_get_srcnam
        using
          lon_srctyp
          p_prgnam
        changing
          lon_error
          loc_srcnam.
      perform sub_dsp_source
        using
          p_prgnam
          loc_srcnam.
    the end
      exit. " form
    endform.                    "sub_main
    form   :  sub_click
    purp.  :  entry point for line selection
    param  :  <global>    sy-lisel
    rcode  :  ---
    hist.  :  #00 -  KZI - created
    form sub_click.
    data declaration
      data:
        lon_error          type i,
        loc_prgnam         type programm,
        loc_srcnam         type programm.
    get possibly program name
      if ( 0 eq lon_error ).
        perform sub_get_word_from_list
          changing
            loc_prgnam.
        if ( '' eq loc_prgnam ).
          lon_error = 1.
        else.
          translate loc_prgnam to upper case.
        endif.
      endif.
    get source name
      if ( 0 eq lon_error ).
        case loc_prgnam.
          when 'METHODS'.
            perform sub_dsp_methods.
          when others.
            perform sub_get_srcnam
              using
                gcr_rep-typ_prg
                loc_prgnam
              changing
                lon_error
                loc_srcnam.
            if ( 0 eq lon_error ).
              perform sub_dsp_source
                using
                  loc_srcnam
                  loc_srcnam.
            endif.
        endcase.
      endif.
    the end
      exit. " form
    endform.                    "sub_click
    form   :  sub_command
    purp.  :  entry point for user command
    param  :  ---
    rcode  :  ---
    hist.  :  #00 -  KZI - created
    form sub_command
      using
        value(poc_cmd)   type syst-ucomm.
    data declaration
      data:
        lon_error        type i,
        lon_lsind        type syst-lsind,
        lor_file         type typ_file_info.
    try to catch a valid file info
      if ( 0 eq lon_error ).
        read table goa_file[]
          into lor_file
          with key lsind = sy-lsind.
        if ( 0 ne sy-subrc ).
          lon_error = 1.
        elseif ( 'X' ne lor_file-isvalid ).
          lon_error = 1.
        endif.
      endif.
    dispatch work
      if ( 0 eq lon_error ).
        case poc_cmd.
          when 'MY_EDIT'.
            editor-call for report lor_file-srcnam display-mode.
          when 'MY_HELP'.
            perform sub_dsp_help.
          when others.
            " nop
        endcase.
      endif.
    endform.                    "sub_command
    form   :  sub_get_word_from_list
    purp.  :  get the word clicked on
    param  :  <global>     sy-lisel
    rcode  :  ---
    hist.  :  #00 -  created
               #01 -  fixed a problem with words starting in first column
    form sub_get_word_from_list
      changing
        prc_srcnam     type programm.
      data:
        loc_cmp(1)     type c,
        lon_bgn        type i,
        lon_end        type i,
        lon_len        type i.
    get fundamental data
      lon_len = strlen( sy-lisel ).
      lon_bgn = sy-cucol.
      lon_end = sy-cucol.
    find begin/end of word
      do.
        loc_cmp = sy-lisel+lon_bgn(1).
        if
            ''      eq loc_cmp or
            '"'',.' ca loc_cmp
          exit." do
        endif.
        lon_bgn = lon_bgn - 1.
        if ( 0 GT lon_bgn ).
          exit. " do
        endif.
      enddo.
      lon_bgn = lon_bgn + 1.
      do.
        loc_cmp = sy-lisel+lon_end(1).
        if
            lon_len le lon_end or
            ''      eq loc_cmp   or
            '"'',.' ca loc_cmp
          exit.
        endif.
        lon_end = lon_end + 1.
      enddo.
      lon_end = lon_end - 1.
    if end >= begin give it back
      if ( lon_end ge lon_bgn ).
        lon_len = lon_end - lon_bgn + 1.
        prc_srcnam = sy-lisel+lon_bgn(lon_len).
      endif.
    endform.                    "sub_get_word_from_list
    form   :  sub_get_srcnam
    purp.  :  builds sourcename according to selection screen settings
    param  :  pon_prgtyp   distinquish the various program types
               pon_prgnam   the program name used to build the source file
    rcode  :  prn_error    0 success, else failure
               prc_srcnam   name of sourcefile
    hist.  :  #00 -  KZI - created
    form sub_get_srcnam
      using
        value(pon_prgtyp)     type i
        value(poc_prgnam)     type program
      changing
        prn_error             type i
        prc_srcnam            type programm.
    data declaration
      data:
        lon_error type i,                 " local errorflag
        x type i,                         " simple counter
        y type i,                         " simple counter
        lor_tfdir type tfdir.             " prog info tab.
    build the true filename dependend on prg type
      " keep this source in sync with parameter, sub_check, sub_init
      case pon_prgtyp.
        when gcr_rep-typ_prg.
          " simple program
          prc_srcnam = poc_prgnam.
        when gcr_rep-typ_cla.
          " class
          prc_srcnam = poc_prgnam.
          x = strlen( poc_prgnam ).
          if ( 30 > x ).
            y = 30 - x.
            prc_srcnam+x(y) = '=============================='.
          endif.
          prc_srcnam+30(2) = 'CP'.
        when gcr_rep-typ_ifc.
          " interface
          prc_srcnam = poc_prgnam.
          x = strlen( poc_prgnam ).
          if ( 30 > x ).
            y = 30 - x.
            prc_srcnam+x(y) = '=============================='.
          endif.
          prc_srcnam+30(2) = 'IP'.
        when gcr_rep-typ_fct.
          " function pool
          concatenate
            'SAPL'
            poc_prgnam
            into prc_srcnam.
        when gcr_rep-typ_mod.
          " function module
          select
             single *
             into lor_tfdir
             from tfdir
             where funcname = poc_prgnam.
          if ( 0 eq sy-subrc ).
            concatenate
              'L'
              lor_tfdir-pname+4
              'U'
              lor_tfdir-include
              into prc_srcnam.
          else.
            lon_error = 1.
          endif.
        when gcr_rep-typ_pool.
          " type pool
          concatenate '%_C' poc_prgnam into prc_srcnam.
        when others.
          " unknown type
          lon_error = 1.
      endcase.
    the end
      if ( 0 eq lon_error ).
        prn_error = 0.
      else.
        prn_error =  1.
        prc_srcnam = p_prgnam.
      endif.
    endform.                    "sub_get_srcnam
    form   :  Sub_Dsp_Methods
    purp.  :  displays methods of a Class
    param  :  prc_ClassName the name of the class to display methods from
    rcode  :
    hist.  :  #00 -  KZI - created
    form sub_dsp_methods.
    data declaration
      constants:
        c_Num_Index  type   i value 35,
        c_Num_Modulo type   i value 36,
        c_Index(37)  type   c
                     value  '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ?'.
      data:
        lon_Fraction      type i,
        lon_Modulo        type i,
        lon_Index         type i,
        lon_Offset        type i,
        loa_methods       type typ_method_info_tab,
        loc_Class_Name    type tmdir-classname,
        loc_include_Name  type programm,
        lor_file          type typ_file_info,
        loc_Index(3)      type c.
      field-symbols:
        <lor_method>       type  typ_method_info.
    init &_ precheck
      lor_file-isvalid = ''.
      lor_file-prgtyp =  ''.
      lor_file-lsind  =  sy-lsind + 1.
      modify goa_file[] from lor_file index lor_file-lsind.
      read table goa_file[] index sy-lsind into lor_file.
      if ( 0 ne sy-subrc or 'X' ne lor_File-isValid ).
        exit.
      endif.
      loc_Class_Name = lor_File-PrgNam.
      if ( loc_class_name cs '=' ).
        loc_Class_Name = loc_class_name(sy-fdpos).
      endif.
    get all methods
      select methodname methodindx from tmdir
        into corresponding fields of table loa_methods[]
        where
          classname = loc_class_name AND
          methodname <> ''
        order by
         methodindx.
      if ( 0 ne sy-subrc ).
        write:
          'could not be loaded!'(e04),
          / 'No entry in TMDIR,' , loc_class_name.
        exit.
      endif.
    put em on the list.
      Format: Reset.
      loc_Include_Name = loc_Class_Name.
      concatenate
        loc_Include_Name
        '=================================================='
        into loc_Include_Name.
        loc_Include_Name+30 = 'CM'.
      loop at loa_methods[] assigning <lor_method>.
        loc_Index = '000'.
        lon_Offset =   3.
        lon_Modulo =   <lor_Method>-MethodIndx mod c_Num_Modulo.
        lon_Fraction = <lor_Method>-MethodIndx div c_Num_Modulo.
        while ( ( lon_Fraction > 0 or lon_Modulo > 0 ) and lon_Offset > 0 ).
          lon_Offset = lon_Offset - 1.
          loc_Indexlon_Offset(1) = c_Indexlon_Modulo(1).
          loc_Include_Name+32 = loc_Index.
          lon_Modulo =   lon_Fraction mod c_Num_Modulo.
          lon_Fraction = lon_Fraction div c_Num_Modulo.
        endwhile.
        write: /
          loc_include_name intensified,
           at 40 <lor_method>-methodname(40).
      endloop.
    endform.                    "sub_Dsp_Methods
    form   :  sub_Dsp_Source
    purp.  :  loads source file from database and displays its contents
               with write
    param  :  prc_srcnam   name of source piece to display
    rcode  :  <hide>       name of occasional included files
    hist.  :  #00 -  KZI - created
    form sub_dsp_source
      using
        value(poc_prgnam)  type programm
        value(poc_srcnam)  type programm.
    data declaration
      data:
        lon_error          type i,
        lon_warn           type i,
        loa_source         type standard table of typ_source,
        loa_lines          type typ_line_tab,
        loc_line           type string,
        loc_print          type string,
        lon_tmp            type i,
        lon_tabix          type syst-tabix,
        lor_d010sinf       type d010sinf,
        lor_file           type typ_file_info.
      field-symbols:
        <lof_source>       type typ_source,
        <lof_line>         type typ_line_info.
    init &_ precheck
      format:
        reset.
      if ( gcr_rep-max_modi lt sy-lsind ). " limit modes
        sy-lsind = gcr_rep-max_modi.
      endif.
      lor_file-srcnam =  poc_srcnam.
      lor_file-prgnam =  poc_prgnam.
      lor_file-lsind =   sy-lsind + 1.
      lor_file-r3state = p_state.
    poc_srcnam =       ucase( poc_srcnam ).
    check existance
      if ( 0 eq lon_error ).
        select *
          from d010sinf up to 1 rows
          into lor_d010sinf
          where
            prog = poc_srcnam
          order by
            r3state
            cdat.
          if ( lor_d010sinf-r3state eq p_state ).
            exit. " loop
          endif.
        endselect.
        if ( 0 ne sy-subrc ).
          lon_error = 1.
          write:
            'could not be loaded!'(e04),
            / 'No entry in D010SINF,' , poc_srcnam.
        endif.
      endif.
    get report text
      if ( 0 eq lon_error ).
        read report poc_srcnam into loa_source[] state p_state.
        if ( 0 ne sy-subrc and 'I' eq p_state ).
          read report poc_srcnam into loa_source[] state 'A'.
          lon_warn = 1.
        endif.
        if ( 0 ne sy-subrc ).
          lon_tmp = strlen( poc_srcnam ).
          write: / 'Program'(e01).
          format inverse on. format color col_negative on.
          write at (lon_tmp) poc_srcnam.
          format inverse off.  format color col_negative off.
          write: /
            'Cannot load source info, sy-subrc= '(e02),sy-subrc.
        endif.
      endif.
    create display
      if ( 0 eq lon_error ).
        perform sub_dsp_source_lines
          using
            poc_prgnam
            0
            0
            loa_source[]
          changing
            lon_error.
      endif.
    update internal memory
      if ( 0 eq lon_error ).
        lor_file-isvalid = 'X'.
        if ( 0 eq lon_warn ).
          lor_file-r3state = p_state.
        else.
          lor_file-r3state = 'A'.
        endif.
        lor_file-prgtyp =  lor_d010sinf-subc.
      else.
        lor_file-isvalid = ''.
        lor_file-prgtyp =  ''.
      endif.
      modify goa_file[] from lor_file index lor_file-lsind.
    the end
      if ( 0 ne lon_warn ).
        message s777 with
          'There is no inactive version => no upload possible!'(i01).
      endif.
      exit. " form
    endform.                    "sub_dsp_source
    form   :  sub_dsp_source_lines
    purp.  :  loads source file from database and displays its contents
               with write
    param  :  poc_prgnam   name of source piece to display
               pra_source   source to display
    rcode  :  prn_error    0 success
    hist.  :  #00 -  KZI - created
    form sub_dsp_source_lines
      using
        value(poc_prgnam)  type programm
        value(pon_lwr_ndx) type i
        value(pon_upr_ndx) type i
        pra_source         type typ_source_tab
      changing
        prn_error          type i.
    data declaration
      data:
        lon_Strlen         type i,
        lon_Tabix(5)       type n,
        loa_lines          type typ_line_tab,
        loc_line           type string,
        lon_error          type i,
        lon_tmp            type i,
        lon_lwr_ndx        type syst-tabix,
        lon_upr_ndx        type syst-tabix.
      field-symbols:
        <lof_source>       type typ_source,
        <lof_line>         type typ_line_info.
    init &_ precheck
      format:
        reset.
      lon_error = 0.
      describe table pra_source[] lines lon_tmp.
      if ( 1 gt pon_lwr_ndx or lon_tmp lt pon_lwr_ndx ).
        lon_lwr_ndx = 1.
      else.
        lon_lwr_ndx = pon_lwr_ndx.
      endif.
      if ( 1 gt pon_upr_ndx or lon_tmp lt pon_upr_ndx ).
        lon_upr_ndx = lon_tmp.
      else.
        lon_upr_ndx = pon_upr_ndx.
      endif.
    create display
      if ( 0 eq lon_error ).
        format: reset.
        loop at pra_source[]
          assigning <lof_source>
          from lon_lwr_ndx
          to   lon_upr_ndx.
          lon_tabix = syst-tabix.
          loc_line = <lof_source>.
          perform sub_cut_text_comment
            using
              loc_line
              'X'
            changing
              loa_lines[].
          loop at loa_lines[] assigning <lof_line>.
            if ( 'X' eq <lof_line>-flag_newline ).
              if ( 0 ne lon_tabix ).
                write:
                  /(5) lon_tabix intensified color col_normal.
              else.
                write:
                  /(5) '      .' intensified color col_normal.
              endif.
              write at 6 ''.
              lon_tabix = 0.
            endif.
            lon_Strlen = strlen( <lof_Line>-Text ).
            if ( 'X' eq <lof_line>-flag_comment ).
              write: at (lon_Strlen)
                 <lof_line>-text intensified no-gap.
            else.
              write: at (lon_Strlen)
              <lof_line>-text no-gap.
            endif.
          endloop.
        endloop.
      endif.
    the end
      if ( 0 ne lon_error ).
        prn_error = 1.
      else.
        prn_error = 0.
      endif.
      exit. " form
    endform.                    "sub_dsp_source_lines
    form   :  sub_chk_input
    purp.  :  (en) validate input data
               (de) validieren der eingabewerte
    param  :  ---
    rcode  :  ---
    hist.  :  #00 - initial
    form sub_dsp_help.
    data declaration
      data:
        lon_error        type i,
        loa_tline        type standard table of tline,
        loc_docnam       type syst-repid.
    show help about ?
      if ( 0 eq lon_error ). " Help
        loc_docnam = sy-repid.
        call function 'HELP_OBJECT_SHOW'
          exporting
            dokclass         = 'RE'
            dokname          = loc_docnam
          tables
            links            = loa_tline[]
          exceptions
            object_not_found = 1
            sapscript_error  = 2
            others           = 3.
        if ( 0 ne sy-subrc ).
          lon_error = 1.
          message w777 with 'No Help Available'(w00).
          sy-subrc = 0.
        endif.
      endif.
    endform.                    "sub_dsp_help
    form   :  sub_init
    purp.  :  initializes the selection screen
    param  :  ---
    rcode  :  ---
    hist.  :  #00 -  KZI - created
    form sub_init.
    data declaration
      data:
        loc_memory(256) type c,
        lon_memory      type i.
    memory id logic
      " get prog
      get parameter id gcr_rep-mem_prg  field p_prgnam.
      if ( 0 ne sy-subrc or '' eq p_prgnam ).
        p_prgnam = sy-repid.
      endif.
      set parameter id gcr_rep-mem_prg field p_prgnam.
      " get prog type ( keep in sync with parameters sub_check and
      " sub_get_srcnam )
      get parameter id gcr_rep-mem_typ field loc_memory.
      condense loc_memory.
      loc_memory = loc_memory(4).
      if ( loc_memory co ' 0123456789' ).
        lon_memory = loc_memory.
      else.
        lon_memory = gcr_rep-typ_prg.
      endif.
      clear:
        p_typcla,
        p_typfct,
        p_typifc,
        p_typmod,
        p_typool,
        p_typprg.
      case lon_memory.
        when gcr_rep-typ_prg.
          p_typprg = 'X'.
        when gcr_rep-typ_cla.
          p_typcla = 'X'.
        when gcr_rep-typ_ifc.
          p_typifc = 'X'.
        when gcr_rep-typ_fct.
          p_typfct = 'X'.
        when gcr_rep-typ_mod.
          p_typmod = 'X'.
        when gcr_rep-typ_pool.
          p_typool = 'X'.
        when others.
          " default
          p_typprg = 'X'.
      endcase.
      " get status ( keep in sync with sub check ).
      get parameter id gcr_rep-mem_sta  field p_state.
      if ( 'A' ne p_state ).
        " only 'I' or 'A' is allowed
        p_state = 'I'.
      endif.
      set parameter id gcr_rep-mem_sta field p_state.
    endform.                    "sub_init
    form   :  sub_check
    purp.  :  at the selection screen
    param  :  ---
    rcode  :  ---
    hist.  :  #00 -  KZI - created
    form sub_check.
    data declaration
      data:
        loc_memory(4)    type c,
        lon_rcode        type i.
    memory id handling
      case p_state.
        when 'A' or 'I'.
          " ok
        when others.
          message e777 with
            'Only ''A'' and ''I'' are allowed for state'(se1).
      endcase.
      set parameter id gcr_rep-mem_prg field p_prgnam.
      set parameter id gcr_rep-mem_sta field p_state.
      " multiple choice
      " keep in sync with parameters and sub_check, sub_main
      case 'X'.
        when p_typprg.
          loc_memory = gcr_rep-typ_prg.
        when p_typcla.
          loc_memory = gcr_rep-typ_cla.
        when p_typifc.
          loc_memory = gcr_rep-typ_ifc.
        when p_typfct.
          loc_memory = gcr_rep-typ_fct.
        when p_typmod.
          loc_memory = gcr_rep-typ_mod.
        when p_typool.
          loc_memory = gcr_rep-typ_pool.
        when others.
          " if bugfree this should never happen, sync source if you
          " expierience this source to be executed
          loc_memory = gcr_rep-typ_prg.
      endcase.
      if ( '' ne loc_memory ).
        set parameter id gcr_rep-mem_typ field loc_memory.
      endif.
    endform.                    "sub_check
    form   :  sub_split_comment
    purp.  :  splits a line into a comment and command part.
    param  :  poc_line     to source line
               poc_command  the command part
               poc_comment  the comment part
    rcode  :  <hide>       name of occasional included files
    hist.  :  #00 -  KZI - created
    form sub_split_comment
      using
        value(poc_line)       type typ_source
      changing
        prc_command           type typ_source
        prc_comment           type typ_source.
    data declaration
      data:
        loc_First_Char(1)     type c,
        lon_len_old           type i,
        lon_len_new           type i,
        lon_pos_cmt           type i,
        loc_buf1              type string,
        loc_buf2              type string,
        loc_cmtbuf(240)       type c.
    init & precheck
      clear:
        prc_command,
        prc_comment.
    computation
      loc_First_Char = poc_Line.
      if ( '*' eq loc_First_Char ).
        prc_command = ''.
        prc_comment = poc_line.
      else.
        if ( poc_line ca '"' and poc_line np '''"''' ).
          split poc_line at '"' into loc_buf1 loc_buf2.
          if ( '' eq loc_buf1 ).
            prc_command = ''.
            prc_comment = poc_line.
          else.
            lon_len_old =
              strlen( poc_line ).
            lon_len_new =
              strlen( loc_buf1 ) +
              strlen( loc_buf2 ).
            lon_pos_cmt = lon_len_old - lon_len_new - 2.
            if ( 0 gt lon_pos_cmt or 240 lt lon_pos_cmt ).
              lon_pos_cmt = 0.
            endif.
            loc_cmtbuf+lon_pos_cmt = '"'.
            prc_command = loc_buf1.
            concatenate loc_cmtbuf loc_buf2 into prc_comment.
          endif.
        else.
          prc_command = poc_line.
          prc_comment = ''.
        endif.
      endif.
    the end
      exit. " form
    endform.                    "sub_split_comment
    form   :  sub_cut_text_comment
    purp.  :  splits a line into a comment and command part.
    param  :  poc_line     to source/text line
               poc_cmt      'X' chk for comments
    rcode  :  pra_lines    filled with line info ( reset )
    hist.  :  #00 -  KZI - created
    form sub_cut_text_comment
      using
        value(poc_line)       type string
        value(poc_cmt_check)  type flag
      changing
        pra_lines             type typ_line_tab.
    data declaration
      data:
        loc_buf1              type string,
        loc_buf2              type string,
        loc_comment           type string,
        loc_command           type string.
      data:
        loc_First_Char(1)     type c,
        loc_new_line          type flag,
        lon_cur_pos           type i,
        lon_new_pos           type i.
    init & precheck
      clear:
        pra_lines[],
        loc_command,
        loc_comment.
    computation
      loc_First_Char = poc_Line.
      if ( '' eq poc_cmt_check or '' eq poc_line ).
        loc_command = poc_line.
        loc_comment = ''.
      else.
        if ( '*' eq loc_First_Char ).
          loc_command = ''.
          loc_comment = poc_line.
        else.
          if ( poc_line ca '"' and poc_line np '''"''' ).
            split poc_line at '"' into loc_buf1 loc_buf2.
            if ( '' eq loc_buf1 ).
              loc_command = ''.
              loc_comment = poc_line.
            else.
              loc_command = loc_buf1.
              concatenate '"' loc_buf2 into loc_comment.
            endif.
          else.
            loc_command = poc_line.
            loc_comment = ''.
          endif.
        endif.
      endif.
    cvt text
      lon_cur_pos = 0.
      loc_new_line = 'X'.
      if ( '' ne loc_command ).
        perform sub_cut_text_width
          using
            loc_command
            loc_new_line
            lon_cur_pos
            gcr_rep-max_width
          changing
            pra_lines[]
            lon_new_pos.
        lon_cur_pos =  lon_new_pos.
        loc_new_line = ''.
      endif.
      if ( '' ne loc_comment ).
        perform sub_cut_text_width
          using
            loc_comment
            loc_new_line
            'X'
            lon_cur_pos
            gcr_rep-max_width
          changing
            pra_lines[]
            lon_new_pos.
        lon_cur_pos =  lon_new_pos.
        loc_new_line = ''.
      endif.
      if ( '' ne loc_new_line ).
        perform sub_cut_text_width
          using
            loc_new_line
            lon_cur_pos
            gcr_rep-max_width
          changing
            pra_lines[]
            lon_new_pos.
        lon_cur_pos =  lon_new_pos.
        loc_new_line = ''.
      endif.
    the end
      exit. " form
    endform.                    "sub_cut_text_comment
    form   :  sub_cut_text_width
    purp.  :  splits text info into several lines to make them
               fit to a max-width
    param  :  poc_line     to source/text line
               poc_cmt      'X' chk for comments
    rcode  :  pra_lines    appended ( no reset ) line info.
    hist.  :  #00 -  KZI - created
    form sub_cut_text_width
      using
        value(poc_text)      type string
        value(poc_new_line)  type flag
        value(poc_typ_cmt)   type flag
        value(pon_cur_pos)   type i
        value(pon_max_width) type i
      changing
        pra_lines            type typ_line_tab
        prn_new_pos          type i.
    data declaration
      data:
        lor_text_info         type typ_line_info,
        lon_cnt_loop          type i,
        lon_tmp               type i,
        lon_pos_cur           type i,
        lon_len_cur           type i,
        loc_buf_cur           type string,
        loc_new_line          type flag.
    init & precheck
      loc_buf_cur =  poc_text.
      loc_new_line = poc_new_line.
      lon_pos_cur =  pon_cur_pos.
      do.
        if ( '' eq loc_buf_cur and '' eq loc_new_line or
             1000 lt lon_cnt_loop ).
          exit. " do
        else.
          lon_cnt_loop = lon_cnt_loop + 1.
          clear:
            lor_text_info.
          lor_text_info-flag_comment = poc_typ_cmt.
          if ( '' ne loc_new_line ).
            loc_new_line =               ' '.
            lor_text_info-flag_newline = 'X'.
            lon_pos_cur =                 0.
          endif.
          lon_len_cur = strlen( loc_buf_cur ).
          lon_tmp = lon_pos_cur + lon_len_cur.
          if ( lon_tmp le pon_max_width ).
            " all fits in currentline
            lor_text_info-text = loc_buf_cur.
            loc_buf_cur = ''.
            lon_pos_cur = lon_pos_cur + lon_len_cur.
          else.
            " we need to split
            lon_tmp = pon_max_width - lon_pos_cur.
            if ( 0 gt lon_tmp ).
              " should not happen
              lor_text_info-text = loc_buf_cur.
              loc_buf_cur = ''.
            else.
              lor_text_info-text = loc_buf_cur(lon_tmp).
              loc_buf_cur = loc_buf_cur+lon_tmp.
            endif.
            lon_pos_cur = 0.
            loc_new_line = 'X'.
          endif.
          append lor_text_info to pra_lines[].
        endif.
      enddo.
    the end
      prn_new_pos = lon_pos_cur.
      exit. " form.
    endform.                    "sub_cut_text_width
    [/code]

  • Creating array of objects of class which extends Thread

    getting NullPointerException
    can i not create thread array this way?
    class sample extends Thread
    { int i,id;
      public sample(int c)
       { id=c;
      public void run()
      { for(i=0;i<6;i++)
         System.out.println("Thread "+id+" "+i);
    public class thread extends Frame implements ActionListener
    {  Button b1;
       sample s[];
       thread()
       { for(int i=0;i<2;i++)
              s=new sample(i);
         setLayout(new FlowLayout());
         b1=new Button("OK");
         add(b1);
         b1.addActionListener(this);
         public void actionPerformed(ActionEvent e)
         {   b1.setEnabled(false);
              for(int i=0;i<2;i++)
              { s[i]=new sample(i);
              s[i].start();
         public static void main(String args[])
         { thread t1=new thread(); 
         t1.setVisible(true);
         t1.setSize(150,150);

    You need:
    sample [] s = new sample[2];However
    1) You should get into the habit that class names start with capital letters, variable and field names with lower case.
    2) It's not a good idea to extend Thread, make a class which implements the Runnable interface and hook a standard Thread object to that.

  • Create a new class which extends DataGrid

    Can someone give me a simple example on how to create a new
    class that extends DataGrid. Still having a little trouble
    understanding classes.
    Thanks for any help.
    Jeremy

    import mx.controls.DataGrid
    public class MyGrid extends DataGrid {
    It is pretty much as you would extend a class in Java

  • Recover deleted method from class.

    Hi,
    Is there any way I can recover a method which I deleted from my active class. I haven't activated the new class yet.
    Regards,
    Swadhin

    even  if  you  have saved the deleted Method   just  go to se10  see the Change request   in which you have saved   from there  open the request you can see you class  and in the Method  which you deleted   Double Click on it and  see the method.
    otherwise  go for the Version Management of that Class not for the Method.
    Because  Your class is  like your Function Group so with that the version managemnet of the Class you can get it back ....
    Reward  points if it is usefull...
    Girish

  • Import Method From .Class in A Package

    Hello!
    I have a package name
    com.vibesoft.bots.;*
    With a .class file name print in it and a method name print within that .class that prints text to the command line. The print.class file looks like this:
    package com.vibesoft.bots;
    public class print{
    public static void print(String text){
    System.out.println(text);
    //Call this method with: print.print("What_You_Want_To_Print");When I write a script to call the method like so:
    import com.vibesoft.bots.*;
    public class printit {
    public static void main(String[] args) {
    //Here i'm trying to write print("Text"); , but I'm required to write print.print("Text");
    }I can't just write print("Text"), i need to write print.print("Text")
    Is their anyway I can fix this problem?
    Edited by: Speedster239 on Sep 23, 2007 9:35 PM

    Speedster239 wrote:
    It makes a difference because these classes are part of a scriptable program to control the mouse, keyboard, to search the screen for color and so forth.And they do the scripting using Java? Why not use one of the scripting languages.
    http://java.sun.com/developer/technicalArticles/J2SE/Desktop/scripting/

  • How do I bring array into main method from class?

    Can someone help?
    If I add data to an array in a class. Then how do I bring it into the main method?
    I instantiate the class in the main method.
    Then I am not sure. Can some one comment and maybe show a short example?
    Thanks

    A catch,
    try {
      // Some code
    } catch (Exception e) {
    }...should be where you call a method trowing a particular exception.
    Example:
    try {
      // parseInt(String value) throws NumberFormatException
      int number = Integer.parseInt(string_value);
    } catch (NumberFormatException e) {
    /Andrew                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Simple enough but... calling a method from another class

    Hi all,
    I know it's simple enough, although I can't see where I'm going wrong for some reason. Basically I've got a class which extends JPanel but when I try to call one of its methods from my main class I get an error. The relevant code (I hope) is:
    Main.java
    import java.awt.BorderLayout;
    import javax.swing.UIManager;
    public class Main extends JFrame implements ActionListener {
         JFrame frame;
         public static JPanel statusBar;
         public Main() {
              // Add a status bar
              statusBar = new StatusBar();
              mainPanel.add( statusBar, BorderLayout.SOUTH );
              setContentPane( mainPanel );
         public static void setStatusBarText( String s ) {
              statusBar.setStatusText("Test");
    StatusBar.java
    import java.awt.Color;
    import javax.swing.SwingConstants;
    public class StatusBar extends JPanel {
         private int barWidth;
         private static JLabel status;
         public StatusBar() {
              super();
              //barWidth = Main.getProgramWidth();
              //setPreferredSize( new Dimension(barWidth,22) );
              setLayout( new FlowLayout( FlowLayout.LEADING ) );
              setBorder( BorderFactory.createMatteBorder(1, 0, 0, 0, new Color(160,160,160) ) );
              status = new JLabel("Test", SwingConstants.LEFT);
              //status.setVerticalAlignment( SwingConstants.CENTER );
              add( status );
         protected void setStatusText( String s ) {
              status.setText( s );
              revalidate();
    }The "statusBar.setStatusText("Test");" call in the main class file doesn't work and I get the error:
    >
    cannot find symbol
    symbol : method setStatusText(java.lang.String)
    location: class javax.swing.JPanel
    statusBar.setStatusText("Test");
    >
    Any ideas what I'm doing wrong? I created an instance of the StatusBar class called statusBar, then I use this to call the setStatusText() method (via statusBar.setStatusText()) which I thought was all correct, then it doesn't work? Even if there's an easier way to do what I want to achieve (i.e. update a JLabel from the 'central' main class file instead of setting the JLabel to static and having every class call it directly), I'd appreciate knowing where I'm going wrong here nonetheless.
    Many thanks,
    Tristan

         public static JPanel statusBar;
         public static void setStatusBarText( String s ) {
              statusBar.setStatusText("Test");
    >
    cannot find symbol
    symbol : method setStatusText(java.lang.String)
    location: class javax.swing.JPanel
    statusBar.setStatusText("Test");
    >The type of variable statusBar is JPanel. That's all the compiler takes into account. It's irrelevant that at some point in the program the type of the object pointed to by this variable is a subclass of JPanel (because at another point it might be an instance of another subclass, or of JPanel itself.

Maybe you are looking for

  • USB 2.0 port no longer recognizes ext. HD; USB 3.0 seems fine W510

    Have had several BSODs in last few days. Two of most recent referred to nusb3xhc.sys Other symptoms: I have 3 WesternDigital 500GB ext. USB 2.0 HDs none of which are being recognized even when plugging directly in to laptop USB port rather than USB h

  • Questions in Lync 2013 Pool failover behaviour

    Hello Team, Please let us know answers for the below questions: If Pool A fails over to Pool B in disaster mode. Then the original front ends for Pool A are recovered successfully, and services start. Is it expected that  User Services, Conference se

  • My pictures are not shown in my I photo library.

    I can't see the photos, it's like they all vanished. I still can see the pictures in the files but I had a lot more than those.

  • Check this code once, Is therea any remedy to this Script?

    1 declare 2 i number(2):=1; 3 id number(2); 4 name varchar2(25); 5 begin 6 loop 7 id:=&id; 8 name:='&name'; 9 insert into emp_ramu values(id,name); 10 i:=i+1; 11 exit when i>=5; 12 end loop; 13* end; SQL> / Enter value for id: 10 old 7: id:=&id; new

  • HP Photosmart 7525 error 0x6100004c

    I have a new HP Photosmart 7525 printer that is less than 4 months old. All of a sudden I started to see General printing error 0x6100004c on my product screen. I looked at the solution suggested in the previous posts to remove the cartridges but whe