Initializing GUI Objects

I'm new to java and am writing my first GUI. I am wondering what the advantages and disadvantages are between initializing GUI objects at the global(up at the top of a class) or local(within a method/constructor) level. Thank you in advance for anyone willing to help me out.

Well, it depends. I prefer global initialization for GUI client application with GUI masks. But smaller dialogs/requesters can be created locally. WHat's more important: be very sure to close resources when you close you dialog/frame/etc. A common mistake is just to hide a frame and it stays in memory. If you have some listeneres that are not registered via weak references, this could be a perfect memory leak ...

Similar Messages

  • Is there Inventory initial quantity Object exists in DI-API?

    Anyone know if there is exists an inventory initial quantity Object in DI-API or not?
    Thanks

    Hi MLRT,
    You can use the Goods Issue and/or Goods Receipt to post your inventory initial quantities.
    Goods issue: instantiate a new Document object of type oInvetoryGenExit;
    Goods receipt: instantiate a new Document object of type oInvetoryGenEntry;
    Make sure you defined the Item Cost (in the Inventory folder of the Item Master Data form) before you create these postings.
    Regards,
    Vítor Vieira

  • Hi,i am trying to edit a BP and i get this error;An attempt was made to execute a dynamic method callon an initial(NULL-) object reference. The reference must refer to an object. what could be missing?

    BP_....AccountActivitiesOV.htm....application BPBT.
    what could be wrong? An attempt was made to execute a dynamic method callon an initial(NULL-) object reference. The reference must refer to an object???

    Hi Dunamis,
    Please check if below links can help you;
    Error on execution of Web Interface
    Help! I meet this Business Server Page (BSP) error CX_SY_REF_IS_INITIAL
    Strange Error in Transformation of 2LiS_03_BF with 0IC_C03
    Regards,
    Kamfrk.

  • Reusing the Initial Context Object

    Hi all
    Environment: Weblogic 452
    JNDI implementation of Weblogic 452 is based on Javasoft JNDI 1.1 and
    SPI specifications.(refer: Developer docs for 452).Javadoc of
    InitialContext for JNDI 1.1 says (refer -
    http://java.sun.com/products/jndi/javadoc/index.html)
    An InitialContext instance is not synchronized against concurrent access
    by multiple threads. Multiple threads each manipulating their own
    InitialContext
    instances need not synchronize. Threads that need to access a single
    InitialContext instance concurrently should synchronize amongst
    themselves
    and provide the necessary locking
    1. Does reusing the InitialContext object accross threads for lookup and
    then execution of remote methods cause any problems? or should we
    synchronize access?
    How weblogic 452 handles this.
    2. Let say i do this
    a. get InitialContext
    b. do lookup
    c. get remote reference
    d. close context
    e. execute methods on the remote reference got in step c.
    does doing d ie..closing context cause problems in step e or later
    on....
    3. What happens if we dont close the intial context...
    Does WLS 452 intelligently garbage collect them and release any
    resources held internally by the initial context object?
    How much is the overhead?
    Is Initial Context heavy ie.. holds resources like sockets/etc...?
    thanks in advance

    I do not have an exact answer for most of your questions. From my
    experience and from research, I would suggest that the following is safe:
    Within an HTTP request, instantiate an InitialContext and using it for the
    duration of the request only (i.e. same auth info, same thread). I believe
    the same holds true for home interfaces. That is within the "web
    container", though. The choice of "caching" the context in the "ejb
    container" is a even easier for threads (ejb guarantee -- only one thread
    with access to your ejb at a time), but harder due to lack of clear spec on
    auth issues.
    Cameron Purdy, LiveWater
    "S Rajesh" <[email protected]> wrote in message
    news:[email protected]...
    Hi all
    Environment: Weblogic 452
    JNDI implementation of Weblogic 452 is based on Javasoft JNDI 1.1 and
    SPI specifications.(refer: Developer docs for 452).Javadoc of
    InitialContext for JNDI 1.1 says (refer -
    http://java.sun.com/products/jndi/javadoc/index.html)
    An InitialContext instance is not synchronized against concurrent access
    by multiple threads. Multiple threads each manipulating their own
    InitialContext
    instances need not synchronize. Threads that need to access a single
    InitialContext instance concurrently should synchronize amongst
    themselves
    and provide the necessary locking
    1. Does reusing the InitialContext object accross threads for lookup and
    then execution of remote methods cause any problems? or should we
    synchronize access?
    How weblogic 452 handles this.
    2. Let say i do this
    a. get InitialContext
    b. do lookup
    c. get remote reference
    d. close context
    e. execute methods on the remote reference got in step c.
    does doing d ie..closing context cause problems in step e or later
    on....
    3. What happens if we dont close the intial context...
    Does WLS 452 intelligently garbage collect them and release any
    resources held internally by the initial context object?
    How much is the overhead?
    Is Initial Context heavy ie.. holds resources like sockets/etc...?
    thanks in advance

  • Gui object dead in permanet memory

    Hi!
    I created a gui in java for monitoring some applications and this gui update its content each 15 seconds.
    The strange thing I notice is that at each refresh the memory allocated by this gui groves and is never relased! I investigated and using tools like jconsole and jmap I discovered that the problem is in the permanet generation handled by the garbage collector.
    I tried with all the possible existing carbage colletion and I did't find any improvements.
    I am wondering why in the output of jmap I found always a lot of sun/reflect/DelegatingClassLoader marked as dead, and even if I manually perform a garbage collection with jconsole, the gc never clean them!
    Can anyone help me? Can anyone give me any suggestion? Thanks!!!

    the application is a package with a lot of classes. The class that has this problem is this one:
    It use an object called Tupla which is an object with some Strings and two vector, on of which contains others tuplas objects.
    public class SMSTree extends JPanel implements TreeSelectionListener, TreeModelListener, TreeExpansionListener {
         private JPanel nodePane;
         private JTable tableInfo;
         private JTable tableData;
         private SimpleTableModel stmI;
         private SimpleTableModel stmD;
         private JScrollPane infoScroll;
         private JScrollPane dataPanel;
         private JLabel currTime;
        private JTree tree;
        private TreePath treePath = null;
        private String[] path;
        private static boolean playWithLineStyle = false;
        private static String lineStyle = "Horizontal";
        private Vector tp = new Vector();
        DefaultMutableTreeNode top ;
        DefaultTreeModel treeModel;
        public SMSTree(Vector c) {
            super(new GridLayout(1,0));
            Dimension minimumSize = new Dimension(100, 50);
            //Create the nodes.
            top = new DefaultMutableTreeNode("SMS Processes Tree");
            treeModel = new DefaultTreeModel(top);
            treeModel.addTreeModelListener(this);
            createNodes(top, c);
            //Create a tree that allows one selection at a time.
            tree = new JTree(treeModel);
            tree.setPreferredSize(new Dimension(250,700));
            tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
            tree.setShowsRootHandles(true);
            //Listen for when the selection changes.
            tree.addTreeSelectionListener(this);
            tree.addTreeExpansionListener(this);
             tree.setCellRenderer(new SMSTreeRenderer());
             tree.setLargeModel(true);
             tree.setRowHeight( 20 );
             tree.repaint();
            if (playWithLineStyle) {
                System.out.println("line style = " + lineStyle);
                tree.putClientProperty("JTree.lineStyle", lineStyle);
            nodePane = new JPanel();
            nodePane.setVisible(true);
            tableInfo = new JTable();
            tableData = new JTable();
            infoScroll = new JScrollPane(tableInfo);
            JPanel datePanel = new JPanel();
            dataPanel = new JScrollPane(tableData);
            infoScroll.setPreferredSize(new Dimension(650,200));
            infoScroll.setMinimumSize(minimumSize);
            infoScroll.setBackground(new Color(255,223,203));
            tableInfo.setBackground(new Color(255,223,203));
            tableData.setPreferredScrollableViewportSize(new Dimension(650,420));
            tableInfo.setPreferredScrollableViewportSize(new Dimension(680,192));
            tableInfo.setPreferredSize(new Dimension(680,192));
            tableInfo.setMinimumSize(new Dimension(680,192));
            tableInfo.setMaximumSize(new Dimension(10000,192));
            tableData.setPreferredSize(new Dimension(680,413));
            tableData.setMinimumSize(new Dimension(680,413));
            dataPanel.setPreferredSize(new Dimension(650,420));
            dataPanel.setMinimumSize(minimumSize);
            dataPanel.setBackground(new Color(240,255,3));
            tableData.setBackground(new Color(240,255,3));
            datePanel.setPreferredSize(new Dimension(650,25));
            datePanel.setSize(new Dimension(650,25));
            datePanel.setMinimumSize(minimumSize);
            datePanel.setBackground(new Color(255,157,3));
            infoScroll.setBorder(BorderFactory.createTitledBorder(
                      BorderFactory.createCompoundBorder(
                              BorderFactory.createRaisedBevelBorder(),
                              BorderFactory.createLoweredBevelBorder()), "Info Table",
                     TitledBorder.CENTER,
                     TitledBorder.ABOVE_TOP, new Font("Serif", Font.BOLD, 16))
            datePanel.setBorder(BorderFactory.createTitledBorder(
                        BorderFactory.createEtchedBorder(EtchedBorder.LOWERED), "Last Refresh",
                        TitledBorder.LEFT,
                        TitledBorder.TOP, new Font("Serif", Font.BOLD, 12))
            dataPanel.setBorder(BorderFactory.createTitledBorder(
                      BorderFactory.createCompoundBorder(
                              BorderFactory.createRaisedBevelBorder(),
                              BorderFactory.createLoweredBevelBorder()), "Data Table",
                     TitledBorder.CENTER,
                     TitledBorder.ABOVE_TOP, new Font("Serif", Font.BOLD, 16))
            Date d = new Date();
            currTime = new JLabel(d.toString());
            currTime.setForeground(new Color(3,15,255));
            currTime.setFont(new Font("Serif", Font.BOLD, 14));
            datePanel.add(currTime);
            nodePane.setLayout(new SpringLayout());
            nodePane.add(infoScroll);
            nodePane.add(datePanel);
            nodePane.add(dataPanel);
            nodePane.setBackground(new Color(255,242,234));
            SpringUtilities.makeCompactGrid(nodePane,
                    3 , 1,       //rows, cols
                    6, 6,        //initX, initY
                    6, 6);       //xPad, yPad
            initNodePane();
            tree.setBackground(new Color(255,242,234));
            //Create the scroll pane and add the tree to it.
            JScrollPane treeView = new JScrollPane(tree);
            JScrollPane nodeView = new JScrollPane(nodePane);
            tree.setPreferredSize(new Dimension(300,700));
            treeView.setMinimumSize(minimumSize);
            nodeView.setMinimumSize(minimumSize);
            treeView.setPreferredSize(new Dimension(300,700));
            nodeView.setPreferredSize(new Dimension(724,700));
            nodeView.setBackground(Color.white);
            //Add the scroll panes to a split pane.
            JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
            splitPane.setLeftComponent(treeView);
            splitPane.setRightComponent(nodeView);
            splitPane.setDividerLocation(300 + splitPane.getInsets().left);
            splitPane.setContinuousLayout(true);
            splitPane.setResizeWeight(1.0);
            splitPane.setBackground(new Color(255,242,234));
            splitPane.setPreferredSize(new Dimension(1024, 768));
            //Add the split pane to this panel.
            add(splitPane);
        /** Required by TreeSelectionListener interface. */
        public void valueChanged(TreeSelectionEvent e) {
            DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
            if (node == null) return;
            treePath = new TreePath(node.getPath());
            Object nodeInfo = node.getUserObject();
            if (nodeInfo instanceof Tupla) {
                 Tupla t = (Tupla)nodeInfo;
                 displayNode(t);
        private void initNodePane() {
            displayNode(null);
        private void displayNode(Tupla node) {
            try {
                if (node != null) {
                     String[] data = node.getContent(true).split(",");
                     Vector colNamesInfo = new Vector();
                     Vector colValuesInfo = new Vector();
                     Vector colNamesData = new Vector();
                     Vector colValuesData = new Vector();
                     for (int i=0; i<data.length; i++){
                          String titleTmp = data.substring(0, data[i].indexOf("=")).trim();
              String value = data[i].substring(data[i].indexOf("=")+1, data[i].length()).trim();
              String title = titleTmp.split(Configuration.typeSep)[0];
              String type = titleTmp.split(Configuration.typeSep)[1];
              if (type.compareTo("info")==0) {
                   colNamesInfo.add(title);
              colValuesInfo.add(value);
              else {
                   colNamesData.add(title);
              colValuesData.add(value);
         if (node.getChildrenContent().size() >0 ){
              Vector c = node.getChildrenContent();
              for (int i=0; i<c.size(); i++){
                   String[] data1 = ((String)c.elementAt(i)).split(",");
         for (int j=0; j<data1.length; j++){
              String titleTmp = data1[j].substring(0, data1[j].indexOf("=")).trim();
              String value = data1[j].substring(data1[j].indexOf("=")+1, data1[j].length()).trim();
              String title = titleTmp.split(Configuration.typeSep)[0];
              String type = titleTmp.split(Configuration.typeSep)[1];
              if (type.compareTo("info")==0) {
                   colNamesInfo.add(title);
              colValuesInfo.add(value);
              else {
                   colNamesData.add(title);
              colValuesData.add(value);
         Vector v = new Vector();
         v.add(colNamesInfo);
         v.add(colValuesInfo);
         stmI = new SimpleTableModel(v, false);
         synchronized (tableInfo){
              EventQueue.invokeLater(new Runnable(){
                   public void run(){
                        int max = tableInfo.getColumnCount();
              for (int i=0; i<max; i++)
                   removeColumnAndData(tableInfo, 0);
              tableInfo.setAutoCreateColumnsFromModel(false);
              tableInfo.setModel(stmI);
              for (int i=0; i<stmI.getColumnCount(); i++){
                   DefaultTableCellRenderer renderer = new ColoredTableCellRenderer();
                   renderer.setHorizontalAlignment(JLabel.LEFT);
                   TableColumn column = new TableColumn(i,200, renderer, null);
                   column.setResizable(true);
                   tableInfo.addColumn(column);
         infoScroll.repaint();
         v = new Vector();
         v.add(colNamesData);
         v.add(colValuesData);
         stmD = new SimpleTableModel(v, false);
         synchronized (tableData) {
              EventQueue.invokeLater(new Runnable(){
                   public void run(){
                        int max = tableData.getColumnCount();
              for (int i=0; i<max; i++)
                   removeColumnAndData(tableData, 0);
              tableData.setAutoCreateColumnsFromModel(false);
              tableData.setModel(stmD);
              for (int i=0; i<stmD.getColumnCount(); i++){
                   DefaultTableCellRenderer renderer = new ColoredTableCellRenderer();
                   renderer.setHorizontalAlignment(JLabel.LEFT);
                   TableColumn column = new TableColumn(i,200, renderer, null);
                   tableData.addColumn(column);
         dataPanel.repaint();
         tableInfo.repaint();
         tableData.repaint();
         nodePane.repaint();
    } else {
         SimpleTableModel stm = new SimpleTableModel(new Vector(), false);
         tableInfo.setAutoCreateColumnsFromModel(true);
         tableInfo.setModel(stm);
         tableData.setAutoCreateColumnsFromModel(true);
         tableData.setModel(stm);
    if (Brain.c.debug > 0) {
    System.out.println("Attempted to display a null Node.");
    } catch (Exception e) {
         e.printStackTrace();
    System.err.println("Attempted to read a bad Node: " + node);
    private void createNodes(DefaultMutableTreeNode top, Vector c) {
    DefaultMutableTreeNode node = null;
    for (int i=0; i<c.size(); i++){
         Tupla t=((Tupla)c.elementAt(i));
              node=new DefaultMutableTreeNode(t);
         if (t.getMyChildren().size()>0){
              if (((Tupla)(t.getMyChildren().elementAt(0))).getMyChildren().size()==0){
                   try {
                        t.setChildrenContent();
                   catch (Exception ex){
                        ex.printStackTrace();
              else {
              createNodes(node, t.getMyChildren());
         top.add(node);
         if (treePath != null) {
              DefaultMutableTreeNode nodeTmp = (DefaultMutableTreeNode)treePath.getLastPathComponent();
              Object nodeInfo = nodeTmp.getUserObject();
              if (nodeInfo instanceof Tupla ){
                   Tupla tTmp = (Tupla)nodeInfo;
                   if (tTmp.getName().compareTo(t.getName())==0){
              String[] tmpList = treePath.toString().split(",");
              for (int j=0; j<tmpList.length; j++){
                   tmpList[j] = tmpList[j].trim();
                   if (tmpList[j].startsWith("[")) tmpList[j]=tmpList[j].substring(1,tmpList[j].length());
                   if (tmpList[j].endsWith("]")) tmpList[j]=tmpList[j].substring(0,tmpList[j].length()-1);
              path = tmpList;
    public void loadData(Vector c){
         top.removeAllChildren();
         treeModel.reload();
         tree.setLargeModel(true);
         tree.setRowHeight( 20 );
         createNodes(top,c);
         if ((treePath != null) && (path != null) && (path.length > 0)) {
              treePath=findByName(tree, path);
              tree.expandPath(treePath);
              tree.setSelectionPath(treePath);
         if (tp!=null){
              for (int i=0; i<tp.size(); i++){
                   //System.err.println("TP "+tp.elementAt(i));
                   String[] tmpList = ((TreePath)tp.elementAt(i)).toString().split(",");
                   for (int j=0; j<tmpList.length; j++){
                   tmpList[j] = tmpList[j].trim();
                   if (tmpList[j].startsWith("[")) tmpList[j]=tmpList[j].substring(1,tmpList[j].length());
                   if (tmpList[j].endsWith("]")) tmpList[j]=tmpList[j].substring(0,tmpList[j].length()-1);
                   TreePath tpT = findByName(tree, tmpList);
                   tree.expandPath(tpT);
         tree.setCellRenderer(new SMSTreeRenderer());
         tree.repaint();
         //treeModel.reload();
         currTime.setText(new Date().toString());
    // Finds the path in tree as specified by the array of names. The names array is a
    // sequence of names where names[0] is the root and names[i] is a child of names[i-1].
    // Comparison is done using String.equals(). Returns null if not found.
    public TreePath findByName(JTree tree, String[] names) {
    TreeNode root = (TreeNode)tree.getModel().getRoot();
    return find2(new TreePath(root), names, 0, true);
    private TreePath find2(TreePath parent, Object[] nodes, int depth, boolean byName) {
    TreeNode node = (TreeNode)parent.getLastPathComponent();
    Object o = node;
    // If by name, convert node to a string
    if (byName) {
    o = o.toString();
    // If equal, go down the branch
    if (((String)o).compareTo((String)nodes[depth])==0) {
         // If at end, return match
    if (depth == nodes.length-1) {
    return parent;
    // Traverse children
    if (node.getChildCount() >= 0) {
         for (Enumeration e=node.children(); e.hasMoreElements(); ) {
    TreeNode n = (TreeNode)e.nextElement();
    TreePath path = parent.pathByAddingChild(n);
    TreePath result = find2(path, nodes, depth+1, byName);
    // Found a match
    if (result != null) {
    return result;
    // No match at this branch
    return null;
    // Removes the specified column from the table and the associated
    // call data from the table model.
    public void removeColumnAndData(JTable table, int vColIndex) {
    SimpleTableModel model = (SimpleTableModel)table.getModel();
    TableColumn col = table.getColumnModel().getColumn(vColIndex);
    int columnModelIndex = col.getModelIndex();
    Vector data = model.getDataVector();
    // Remove the column from the table
    table.removeColumn(col);
    // Remove the column header from the table model
    // colIds.removeElementAt(columnModelIndex);
    // Remove the column data
    for (int r=0; r<data.size(); r++) {
    Vector row = (Vector)data.get(r);
    if (row.size()>columnModelIndex) {
         row.removeElementAt(columnModelIndex);
    model.setDataVector(data);
    // Correct the model indices in the TableColumn objects
    // by decrementing those indices that follow the deleted column
    Enumeration en = table.getColumnModel().getColumns();
    for (; en.hasMoreElements(); ) {
    TableColumn c = (TableColumn)en.nextElement();
    if (c.getModelIndex() >= columnModelIndex) {
    c.setModelIndex(c.getModelIndex()-1);
    model.fireTableDataChanged();
    model.fireTableStructureChanged();
    public void treeNodesChanged(TreeModelEvent e){
    public void treeNodesInserted(TreeModelEvent e){
    public void treeNodesRemoved(TreeModelEvent e){
    public void treeStructureChanged(TreeModelEvent e){
    // Required by TreeExpansionListener interface.
    public void treeExpanded(TreeExpansionEvent e) {
    //System.err.println("Tree-expanded event detected "+e);
    TreePath tpT = e.getPath();
    if (!tp.contains(tpT)) tp.add(tpT);
    // Required by TreeExpansionListener interface.
    public void treeCollapsed(TreeExpansionEvent e) {
         //System.err.println("Tree-collapsed event detected "+e);
         TreePath tpT = e.getPath();
         if (tp.contains(tpT)) tp.remove(tpT);

  • Abort Status in Monitoring Initial Load Object - SERNR_CONFIG From R/3

    Hi Experts,
    Currently we are replicating Equipement from R/3 to CRM. Now we want to replicate only Serial Number withoutEquipment View. For this I Activated the Object Sernr_config and started for Initial download. When i monitored the replication it is showing the status as "ABORT".
    As we are already replicating Equipment from R/3 to CRM, when we want to replicate only serial numbers how will they appear in CRM?
    When we repllicate Equipment  , it will create a Component & IBase ID for it. What will be created if we replicate only Serial Number?
    I am currently workin on SAP CRM 6.O version.
    Can u please guide me how to replicate.
    best regards,
    Sarangamath

    Hi Srangamath,
    Nomrally status Abort should ony occur if the load was maually cancelled.
    However, the sytmoms you descibre have occurred in th past with equipment downloads.
    If you're using fliters, notes  1230307 and 1224016 may help.
    Otherwise, please check the precondition for "Replication of Equipment Between
    SAP CRM and SAP ECC" in the attached Link:
    [http://help.sap.com/saphelp_crm700_ehp01/helpdata/EN/46/cc79505ec61525e10000000a114a6b/frameset.htm]
    Best regards,
    Brian.

  • How can I hide scrollbars in gui objects?

    Hello,
    I want to hide the scrollbars of a gui container but I can not find a way to do it.
    If you know how to do it in gui container or other objects please let me know.
    Thanks in advanced,
    Udi dekel.

    hi udi,
    go to your screen layout,
    on the attributes screen disable check boxes for vertical and hoizantal scrolls,
    then u dont get the scroll bars on the screen.
    reward points if helpful.
    regards,
    seshu.

  • Initial Download: object(s) status RUNNING in R3AM1

    Hi,
    I am trying to download materials from R/3 to CRM for which I am following building blocks B09 and C03. I started downloading customizing objects, initial download for object DNL_CUST_ACGRPB. The status in R3AM1 stays as RUNNING and it's been a while.
    All other objects also stay in the same status without any change in block size.
    Please let me know any possible reasons and solution to fix this problem. Thank you.
    BR.

    Hi,
    As requested by all, the Basis consultant has tested the RFC settings and they are working fine.
    - In SMQ1 (CRM) I can see SYSFAIL for the object DNL_CUST_ACGRPB -  on double-click it says there has been a short dump but no dumps can be found in ST22.
    - In R3AM1 the queue cannot be found.
    - In R3AS - When I execute the download of the object, sys. msg is: Please read the OSS Note no. 212666  (Outbound Queue already exists in CRM:R3AI_DNL_CU
    Further details show the error occured in Function module: CRS_FIRST_DOWNLOAD_TRIGGER for the program: SMOF_MONITOR_SMOFDSTAT.
    Help plz !
    BR.

  • Re-Initializing Date object in a Thread

    Hi ppl,
    I am actually using a Thread, in which i check the current system time, to perform an operation.
    I use a GreagorianCalendar Object to get the Current Time.
    Calendar d = new GregorianCalendar();The time value stored in the object remains the same throughout the process. Therefore, i reinitialize the object every Millisecond to update the object with the current time.
    d = new GregorianCalendar();Is there any other optimal way to perform this ?
    If this is the only way possible, does it, in any way, affect the Memory, since Object is reinitialized every millisecond. If so, what could be the best possible solution ?
    Code :
    To perform a particular operation at 09:00:00:000
    import java.util.Calendar;
    import java.util.GregorianCalendar;
    public class SampleThread implements Runnable{
         public void run() {
              try
                   Calendar d = new GregorianCalendar();
                   while(d.get(Calendar.HOUR)!= 9 ||
                             d.get(Calendar.MINUTE)!=0 ||
                             d.get(Calendar.SECOND) != 0 ||
                             d.get(Calendar.MILLISECOND) != 0 )
                        Thread.currentThread().sleep(1);
                        d = new GregorianCalendar();
                   System.out.println("Operation Executed at : "+d.getTime());
                   Thread.currentThread().sleep(1000);
                   d = new GregorianCalendar();
                   Thread.currentThread().run();
              catch (InterruptedException e)
                   e.printStackTrace();
         public static void main(String a[])
              SampleThread st = new SampleThread();
              Thread t = new Thread(st);
              t.start();
    }can the above code be optimized in any way ?

    Hi,
    Your problem is not the TimerTask, but the way you compute a specific time. Run the following program and you will see what is wrong:
    import java.text.DateFormat;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.GregorianCalendar;
    public class Tomorrow {
        public static void main(String[] args) {
         DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG,
              DateFormat.LONG);
         System.out.println("Your start time is today:       "
              + dateFormat.format(getTomorrowMorning4am()));
         System.out.println("Correct start time is tomorrow: "
              + dateFormat.format(tomorrow9am()));
        private static Date getTomorrowMorning4am() {
         Calendar tomorrow = new GregorianCalendar();
         Calendar result = new GregorianCalendar(tomorrow.get(Calendar.YEAR),
              tomorrow.get(Calendar.MONTH), tomorrow.get(Calendar.DATE), 9, 0);
         return result.getTime();
        private static Date tomorrow9am() {
         Calendar calendar = Calendar.getInstance();
         calendar.add(Calendar.DAY_OF_YEAR, 1);
         calendar.set(Calendar.HOUR_OF_DAY, 9);
         calendar.set(Calendar.MINUTE, 0);
         calendar.set(Calendar.SECOND, 0);
         calendar.set(Calendar.MILLISECOND, 0);
         return calendar.getTime();
    }The start time you supply has already been expired when you invoke scheduleAtFixedRate.
    There is a second problem: the interval. What will happen when daylight saving time comes into effect?
    In your case, scheduling at a specific time of the day, you may consider canceling the timertask after completion and schedule a new timertask.
    Piet

  • How should I do when I want initial some object before show a page?

    which method I should override when I want to display a page in adf 10.1.2?
    I am working with adf 10.1.2 including struts and UIX.
    the execute method can not be override,which method should I override?
    I want to change the where clause of a view object before display a page.
    for example : a customer can only see the infomation of himself.so I want to set the where clause to customer_name = 'abc' in the action of the page.

    I came across this issue on my iPad and iPhone today. I did some research and it was suggested that you need to change your region to wherever in the world you originally purchased the app.
    This worked for me.
    I had tried signing in and out, deleting apps and resetting my devices; because I had never used any Apple ID except for my own personal one, I thought that those options would sort it. I changed my region to the uk (where the apps were purchased) and now they have updated with no other issues.
    I hope this helps

  • Looking for GUI objects

    Hello!
    Could somebdy advise the place to download additional GUI elements. I'm looking for numeric LED-like indicator.
    Thanks.

    Here are a few links
    http://digital.ni.com/public.nsf/websearch/5DCD38A1D020155386256DA9007DF506?OpenDocument
    http://community.ni.com/examples/scrolling-led-xcontrol
    Matthew Fitzsimons
    Certified LabVIEW Architect
    LabVIEW 6.1 ... 2013, LVOOP, GOOP, TestStand, DAQ, and Vison

  • Best practice for initializing objects in a JSF backing bean?

    Hi,
    What is the best practice for initializing some objects in the JSF to-page backing bean before the to-page is displayed for the first time? The initialization would vary and depend upon a command link in the from-page.
    Regards,
    Al Malin

    f:view has two new attributes in 1.2: beforePhase and afterPhase
    which allows you to specify a phase listener method
    which will be called before and after the view is processed.

  • Problem with IO objects...variable might not have been initialized?

    I dont get why its wrong, i've initialized both objects and variables, i dont know why it gives me that error T__T.
    Program is supposed to compare both text archives and see if they are equal in a byte per byte way.
    import java.io.*;
    public class TestIO
         public static void main(String[] args)
         throws IOException{
         int i = 0, j = 0;
            FileInputStream data1;
         FileInputStream data2;
         try{
               try
               data1 = new FileInputStream(args[0]);
               }catch(FileNotFoundException exc){
               System.out.println(args[0] + " File Not Found!");
               return;
               try
               data2 = new FileInputStream(args[1]);
               }catch(FileNotFoundException exc){
               System.out.println(args[1] + " File Not Found!");
               return;
         }catch(ArrayIndexOutOfBoundsException exc){
         System.out.println("Usage: java TestIO File1.java File2.java");
             try{
              do{
              i = data1.read();
              j = data2.read();
              if(i != j) break;
              }while(i != -1 && j != -1);
         }catch(IOException exc){
         System.out.println("File Error!");
         if (i != j)
                   System.out.println("Files Differ");
         else
                   System.out.println("Files are the same");
         data1.close();
         data2.close();
         }Help is appreciated, thanks in advance ^____^ .

    import java.io.*;
    public class FileDiff {
        public static boolean diff(File file1, File file2) throws IOException {
            BufferedInputStream in1 = new BufferedInputStream(new FileInputStream(file1));
            try {
                return diff(in1, file2);
            } finally {
                in1.close();
        public static boolean diff(InputStream in1, File file2) throws IOException {
            BufferedInputStream in2 = new BufferedInputStream(new FileInputStream(file2));
            try {
                return diff(in1, in2);
            } finally {
                in1.close();
        public static boolean diff(InputStream in1, InputStream in2) throws IOException {
            int b1, b2;
            while ((b1 = in1.read()) != -1 & (b2 = in2.read()) != -1 ) {
                if (b1 != b2)
                    return true;
            return b1 != b2;
        public static void main(String[] args) {
            if (args.length != 2) {
                System.err.println("Usage: java FileDiff file1 file2");
            } else {
                try {
                    System.out.println(diff(new File(args[0]), new File(args[1])));
                } catch(IOException e) {
                    System.out.println(e.getMessage());
    }

  • SAP GUI 7.10 - What are your experiences?

    Hi All,
    We are considering updating our GUI from 6.20 to 7.10.  Has anyone out there done this?  If so, did you come across any problems i.e. versions of Windows that it does not work on?
    Has anyone used the GUI in a Citrix environment?  If so, was there a greater overhead on the servers?
    Does the GUI have any compatibility issues with older versions of MS Office?
    Any comments will be gratefully received.
    Thanks,
    Dan

    Hi
    There are some points that are defined and you must have read these in the documents:
    a) *SAP web dynpro Active Component Framework (ACF)* - framework to integrate Active Components (ActiveX / Java Applets) into the Web dynpro.
        At the present there are two supported Components:
              Office Integration
              Adobe Integration
    b)  BI pre calculation service for MS Excel u2013 you can install BI frontend as a standalone.
         SAPSprint u2013 server-based printing on Windows (formerly SAPLPD)
         SAP GUI Screen Reader Extension u2013 an interface allows a screen reader to access the SAP GUI object model at runtime and select the required information for speech and Braille output. It is based on SAP GUI Scripting API.
    c) In case GUI was installed from an installation server users have the possibility to enable automatic update from this server.
    d) System tabstrip of SAP Logon pad has a new popup window with tabstrips
    e) New frontend editor u2013  for ABAP programming. Is integrated to ABAP workbench (TA: SE*), SE38, SE37, SE24). Its new user interfaces and is completely customizable. Frontend editor integrates all modern code editing features like: code hints, code completion, .
    f) New debugger u2013 has a high volume of new and known functions that can be called using menus or icons. It requires an additional external session where it runs.
    But there are some problems that we faced:
    a) Sometimes it happens that after installing this gui the Internet Explorer corrupts.
    b) Users faced some initial trouble to add the new systems in SAPGui as it is little bit complex.
    c) Some performance issues when used on low end desktops.
    d) But make sure to make a copy of *.xla file. It may give you problems.
    But strangly when we installed for Citrix we were happy that we were out or any big problems.
    Here are some notes for your reference
    Note 1144671 - New SAP Installer for SAPGUI for Windows 7.10
    Note 138869 - SAP GUI on Windows Terminal Server (WTS)
    See this for prerequisite
    https://fortress.wa.gov/dop/hrms/TechInfo/DesktopReq.htm
    This for Citrix Best Practise guide
    http://support.citrix.com/article/CTX116576?print

  • ABAP Objects - Instance of a method

    Goodmorning to you all,
    Can anyone explain the process in :
    IF cl_gui_alv_grid=>offline( ) IS INITIAL.
    The method OFFLINE has a returning parameter E_OFFLINE.
    Questions :
    - how does the system recognise this parameter.
    - can i check this variable in the debugger.
    - general explanation of the working of this.
    TIA,
    Rob Makelaar
    The Netherlands

    Hi Rob
    For the functionality of this method:
    This method is used to determine if the ALV Grid Control runs without frontend handling.
    The ALV Grid Control runs without frontend handling in batch mode ( sy-batch has the value ' X '), in print mode, in combination with CATT and during Web Reporting.
    In these cases, you should not create frontend (GUI)  objects (e.g. custom containers, etc...) .
    Since this method has a 'RETURNING' type parameter, you can call and directly assign its output to a variable.
    e.g.
    DATA lv_offline TYPE i .
    lv_offline = cl_gui_alv_grid=>offline( ) .
    You can also call this method in usual way as:
    DATA lv_offline TYPE i .
    CALL METHOD CL_GUI_ALV_GRID=>offline
       RECEIVING
          E_OFFLINE  = lv_offline .
    By the way, you can assign points to posts you find helpful using the scala on the left of each post. By assigning a 10-point or checkin "Solved my own" at left of your original post, you can close your thread.
    Regards
    *--Serdar <a href="https://www.sdn.sap.com:443http://www.sdn.sap.comhttp://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.sdn.businesscard.sdnbusinesscard?u=qbk%2bsag%2bjiw%3d">[ BC ]</a>

Maybe you are looking for