Different applications same  code

Hi!
I just made a tiny litte programm.
It's a JPanel, with JLabels an one JButton on it. The JLabels are instances of some other class.
The weird thing is, that starting the application, the same way!!! ... run as ..., the count of the Labels differ. Actually I added 4 JLabels and one button:
there are sometimes:
4 labels 1 button
1 label
2 labels
showing up.
WHY?

Well, it works, because, I initialize Kasten-objects
in the text-class.
Don't it?I don't know but when I run the following
package me.sabre150.research.scratch;
import java.util.*;
import javax.swing.*;
import java.awt.*;
public class test extends JPanel
    public Kasten [] ak;
    ArrayList<Kasten> a;// = new ArrayList<Kasten>();
    public test()
        super();
    public static void main(String[] args)
        JFrame f = new JFrame("test");
        f.setPreferredSize(new Dimension(300,400));
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        test myTest = new test();
        f.setContentPane(myTest);
        f.pack();
        f.setVisible(true);
        myTest.setLayout(new FlowLayout());
        Kasten k1 = new Kasten(9999, Color.yellow);
        myTest.addItem(k1);
        Kasten k2 = new Kasten(2);
        myTest.addItem(k2);
        JButton b = new JButton("button");
        myTest.addItem(b);
        Kasten kasten = new Kasten(123, Color.red);
        myTest.addItem(kasten);
        Kasten kasten1 = new Kasten(1, Color.green);
        myTest.addItem(kasten1);
        myTest.setVisible(true);
    public void addItem(JButton b)
        b.setText("in addItem");
        b.setOpaque(true);
        this.add(b);
    public boolean addItem(Kasten arg0)
        System.out.println(arg0.i); // add JLabel to
        arg0.setBorder(BorderFactory.createEtchedBorder());
        arg0.setOpaque(true);
        this.add(arg0);
        return a.add(arg0);
class Kasten extends JLabel
    int i;
    java.util.List<Kasten> a = new ArrayList<Kasten>();
    public Kasten(int in)
        this.setBackground(Color.blue);
        this.setForeground(Color.black);
        this.setBorder(BorderFactory.createBevelBorder(5));
        this.setBounds(20,100, 20,50);
        i = in;
        this.setText(""+i);
        setOpaque(true);
    public Kasten(int in, Color color)
        this.setBackground(color);
        this.setForeground(Color.black);
        this.setBorder(BorderFactory.createBevelBorder(5));
        this.setBounds(20,100, 50,50);
        i = in;
        this.setText(""+i);
        setOpaque(true);
}I get as output 9999
Exception in thread "main" java.lang.NullPointerException
        at me.sabre150.research.scratch.test.addItem(test.java:85)
        at me.sabre150.research.scratch.test.main(test.java:54)with the screen showing a frame with just one component BUT when I change the line    ArrayList<Kasten> a;// = new ArrayList<Kasten>();to    ArrayList<Kasten> a = new ArrayList<Kasten>();I get no exception and I see all the components.
So - who is right?

Similar Messages

  • Different application, Same F4 - Searhc help not showing

    Hi Everyone
    I am using F4 Application for Product Search CRMM_PRD_SALES_F4
    When i open this application directly i can see F4 help for category field
    However when i open F4 help in product of sales order, i cannot see F4 help in categry.
    I have checked the view and F4 help mentioned in the field group, everything is correct.
    Is there some restriction as to number of views we can open inside a view
    Could somebody tell me as to what the problem could be.
    TIA
    Asad

    There is a limitation in that. You cannot see F4 in the application ( here -CRMM_PRD_SALES_F4) opened as a F4 for another application(Products)

  • Same code gives different results in Matlab Script in Labview and Matlab

    I am implemeting a Matlab code into a LabVIEW application using Matlab script. When I import the exactly same code to the Matlab Script in LabVIEW it gives a different result than it is in Matlab. This code is a simulation code including first kind bessel functions. Using LabVIEW 7.1 and Matlab R14 service pack 3.

    Labview 8.5
    Matlab R2009b
    Attached are the graphs produced by matlab script in labview and in matlab.
    The minimum of graph produced by matlab code is below 1 and that in labview is above 1.
    Thanks a lot for your reply.
    Sorry, I haven't quantified the "sometimes" yet. 
    Attachments:
    matlabsResult.jpg ‏29 KB
    LV.png ‏84 KB

  • Why differences in the way different machines handle the same code??

    OK, I've posted some other threads re some difficulties in getting the same code to function identically on, not only different platforms, but even on different machines running Windows!
    Here's another, and I would really appreciate an explanation:
    I have a tree control. Per the user's request, I made the right button function the same way it does on MS File Explorer: When they right click, the currently selected nodes are compared to the node they clicked over. If they clicked over a selected node, then the context menu for the nodes selected is displayed. If they clicked over a different node, then the selection is changed to the new node and the context menu displayed. If they right click over the tree control, but not a node in the tree, then the selection is cleared and no context menu is displayed.
    Works great on my machine.
    However, on some machines, no context menu is displayed, nor is the node selected... UNLESS THEY ALREADY HAVE A NODE SELECTED. I.e., if they have no nodes in the tree selected, they cannot display the context menu by right clicking on a node, nor does the selection change to the node they right click over. It only works if they already have something selected.
    My app is distributed as an executable jar file and I am distributing the JRE with it, so there are no class path issues or differences in the JDK. Basically, my problem can be paraphrased as: Why doesnt' Swing behave the same way on different machines...? At least why not the same on the eame machine.
    It's driving me nuts to think that I've resolved some UI glitch only to find out that, no, it's only fixed on some machines, not others.
    Thanks.

    Well, I normally develop on OSX and then deploy to Windows. But, this last build I have switched to Windows XP. The kinds of differences I am seeing are subtle: what triggers a repaint of the UI and now, it seems, what events are getting triggered by mouse clicks.
    My deployment is an executable jar file, therefore it uses the manifest in the jar, not any classpath variables. I deploy an entire JRE along with the app, and the bat file that launches the app ensures that is the JAVA_HOME I'm using.
    I can only guess that it's some underlying difference in versions of the platform and OS that causes this.
    Here's the entire code for this latest issue re the popups:
            private void maybeShowPopup(NodeInfoTree tree, MouseEvent e) {
                if (e.isPopupTrigger()) {
                    //  They clicked the platform dependent popup trigger...
                    int x = e.getX();
                    int y = e.getY();
                    TreePath[] selectedPaths = tree.getSelectionPaths();
                    if (selectedPaths == null) {
                        selectedPaths = new TreePath[0];
                    TreePath clickedPath = tree.getPathForLocation(x,y);
                    if (clickedPath == null) {
                        //  they right clicked, but not on a node, so clear the selection and return
                        tree.clearSelection();
                        return;
                    } else {
                        // They clicked on a path, so let's see if it is a selected
                        // node.  Search the selected array of paths, short circuiting
                        // out if it is found...
                        boolean foundInSelection = false;
                        for (int i=0; (!foundInSelection && (i < selectedPaths.length)); i++) {
                            foundInSelection = clickedPath.equals(selectedPaths);
    if (!foundInSelection) {
    // They right clicked elsewhere than the selection, so
    // reset the selection to the new path...
    tree.setSelectionPath(clickedPath);
    final TreePath menuPath;
    selectedPaths = tree.getSelectionPaths();
    if (selectedPaths == null) {
    return;
    } else {
    menuPath = selectedPaths[selectedPaths.length-1];
    // Since they did click on a node, now we need to determine
    // what popup menu should be displayed...
    tree.scrollPathToVisible(menuPath);
    NodeInfo ni = (NodeInfo) menuPath.getLastPathComponent();
    // If the last path component is null, then they don't have
    // anything selected, so we do nothing
    if (ni == null) return;
    // See if the Node is overriding our default popup menu...
    com.harcourt.applications.tgen.browser.nodes.NodeMenu nodeMenu = ni.getMenu();
    nodeMenu.activate(tree.getView(),ni);
    JPopupMenu popup = (JPopupMenu) nodeMenu;
    if (popup != null) {
    popup.show(e.getComponent(),
    e.getX(), e.getY());
    The nodeMenu.activate call is just used to check whether or not certain menu options need to be enabled or disabled before displaying the menu. My theory right now is that, on some of these machines (all windows), a right click of the mouse is not generating a mouse event unless they have already something selected. I don't think it's a focus issue, because if they left click to select a node, and then ctrl-left click to de-select it, the right button then no longer generates a popup menu. They must select a node, then right click. Maybe there's no mouse event generated, or maybe this line is failing on some machines?:
    TreePath clickedPath = tree.getPathForLocation(x,y);

  • Access to different application in same server

    Any know an easy way to access the JNDI/EJB of a different application
    running in the same server?
    Perry Hoekstra, MS
    E-Commerce Architect
    Talent Software Services

    Only the classfiles of any user-defined classes/interfaces that are possibly used
    as parameters or return values from the methods in the home/remote interfaces. If
    you aren't doing that, then the home and remote interfaces is all you need.
    Bill
    Perry Hoekstra wrote:
    [email protected] wrote:
    Hrm. It's no different from accessing EJB's deployed in the same application
    (EAR) except that local calls are no longer possible.
    Perry Hoekstra <[email protected]> wrote:
    Any know an easy way to access the JNDI/EJB of a different application
    running in the same server?
    Perry Hoekstra, MS
    E-Commerce Architect
    Talent Software Services--
    DimitriI should have explained myself better. I was thinking more from a
    packaging point of view. Beside the remote and home interfaces of the
    called bean, are there any other files necessary to be packaged with the
    calling bean ejb.jar?
    Perry Hoekstra, MS
    E-Commerce Architect
    Talent Software Services
    [email protected]

  • How to use the same component in different applications

    Hi All,
    I need to use the same component in different applications. i.e In opportunity, Quotation & Promotion.
    The Search help view in the component PRD01QR should be used in all these components but with different search criteria.
    With help of the DO_determine_configuration, different view configurations are possible but Different search criteria is not possible.
    for Eg. search parameter without DDLB, F4 options in another components.
    How can I control the behavior of the search view in different applications with restricting the field properties?
    Is it possible to find out where and in which component these search_help_search component is used?

    Hi Harry,
    Is it possible to find out where and in which component these search_help_search component is used?
    ans: I am giving an Example for your question go through that u might get clear about this.
    Ex: BT115IT_SLSO  sales order component
    below screen they component usage using for populate the product search component.
    please let me know any help required .
    Regards,
    vishwa.

  • How to set Different applications running on the same computer to use different Gateways?

    Dear All,
    I would like to have different applications running on the same computer to use different Gateways (both gateways are in the same subnet).
    Is it possible in Windows7 with / without a third-party utility?
    Current scenario & requirements:
    I have two internet connections. Both are in the same subnet (192.168.1.0/24) and connected to the same LAN switch
    Gateway for the first connection is 192.168.1.1
    Gateway for the second connection is 192.168.1.2
    I need to set my chrome browser & google talk to use the gateway 192.168.1.1
    I need to set my IE & skype to use the gateway 192.168.1.2
    Is it possible? Answers are appreciated!!
    Regards,
    Anees

    Hi,
    I agree with Bill. Gateway is essentially an IP address for one network to other networks. For example, you have two networks: network A and network B, to make the two networks communicate with each other, you must go through Gateway. That is, as long
    as you set Gateway, then you can make the two networks communicate with each other. The ip address for Gateway is the ip of device with routing enabled. One host machine can own multiple gateways. 
    Andy Altmann
    TechNet Community Support

  • Pass Username & Password to a Different Application in the Same Workspace

    Can I pass the username and password from a main menu to open a different application in the same workspace. I'm trying to prevent the user from having to logon again. My main menu has links to different applications within the same work space.
    Thank you

    Anonymous - One way to do it (if you are using HTML DB's built-in session management) is to edit each application's authentication scheme and type in the same cookie name in the cookie name field (use any name you like). Another way is to use Single Sign-On.
    Scott

  • Two different vendor supplier for the same code

    Hi,
    We have the two different suppliers supply the material with same code with different values,
    since they are customized products as per customer requirement,we are stuck up with how could it map into the BOM,
    PPC persons always try it with change BOM or change in order,
    How could be simplified?
    With Regards,
    Devendra

    Hello Devendra
    On the standard ERP, there is no way to map this scenario, however, using the DIMP industry solution there is a functionality called Parts Interchangeability.
    Take a look on the following links where this functionality is described:
    A&amp;amp;D Manufacturer Part Number - Discrete Industries and Mill Products - SAP Library
    Interchangeable Manufacturer Parts in MRP - Parts Interchangeability - SAP Library
    BR
    Caetano

  • Deploying EJBs with same name in different application jars on JBOSS

    Hi,
    We are attempting to deploy entity beans with the same name in 2 different EJB application jars on jboss 3.2.5. One bean is an extension of the other, so some of the DB columns they refer to are the same (they access different DB tables in different tablespaces). However, the field names corresponding to these DB columns in the beans themselves are different (i.e. DB column serviceid is associated with the field serviceid in one bean and service_id in the other).
    We have altered jboss.xml for one of the EJB applications so that the jndi-name used to access that application's bean is different to the jndi-name used to access the entity bean in the other EJB jar.
    However, when we attempt to deploy both jar files on the same jboss server, one of the applications deploys successfully and when we deploy the other, we get EJB spec violation errors, such as the following:
    14:18:34,631 WARN [verifier] EJB spec violation:
    Bean : CommunityAddress
    Section: 10.6.2
    Warning: The entity bean class must define a get accessor for each CMP field.
    Info : Field: service_id
    I'm presuming that this is because the bean which references the serviceid DB column with a field called serviceid is being mixed up with the other bean, which has a service_id field.
    Can anyone tell me if there is anything else that is required to get entity beans/EJBs in different applications but with the same names (and some overlapping fields, etc) deployed successfully on the same jboss server apart from editing jboss.xml for one of the applications?
    Is this a jbosscmp-jdbc.xml issue?
    Any help much appreciated,
    Maurice

    Hi Srinath
    Thanks for your response. Its not cloning, its like check-in file first, then check-out the file and do some editing and then again upload the same file with different revision number using RIDC. I got the solution now.
    Regards
    Raj

  • The same code behaving different in two files.

    The same code behaving different in two files.
    in pro*c file it is returning rows
    in sql file it is not returning any rows.
    please suggest me.
    regards,
    prasad.

    please find the code.
    sql_stmt := 'SELECT rNum, dpcCode, sID, hDate, fBlock, '||
    'lBlock, recQty, fID, fName, ' ||
    'tSeqNo, sType, tDate, fStatCode, pDate, recCount, r ' ||
    'FROM (SELECT rownum rNum, DPC_CODE_ORIG dpcCode, ' ||
    'SENSOR_ID sID, ' ||
    'to_char(HEADER_DATE, ''YYYYMMDDHH24MISS'') hDate, ' ||
    'FIRST_BLOCK_NUMBER fBlock, ' ||
    'LAST_BLOCK_NUMBER lBlock, ' ||
    'RECORD_QUANTITY recQty, ' ||
    'FILE_ID fID, ' ||
    'substr(FILE_NAME,1,30) fName, ' ||
    'TRACE_SEQUENCE_NO tSeqNo, ' ||
    'SENSOR_TYPE sType, ' ||
    'to_char(TRAILER_DATE, ''YYYYMMDDHH24MISS'') tdate, ' ||
    'NVL(FILE_STATUS_CODE, ''NL'') fStatCode, ' ||
    'to_char(PROCESSED_DATE, ''YYYYMMDDHH24MISS'') pDate, '||
    'NVL(RECIRCULATE_COUNT,0) recCount, ' ||
    'ROW_NUMBER() ' ||
    'OVER(ORDER BY TRAILER_DATE DESC, LAST_BLOCK_NUMBER DESC) r ' ||
    'FROM logfc10t ' ||
    'WHERE DPC_CODE_ORIG = :IN_DPC_CODE ' ||
    'AND SENSOR_ID = :IN_SENSOR_ID ' ||
    'AND (((TRAILER_DATE <= TO_DATE(:IN_TRAILER_DATE, ''YYYYMMDDHH24MISS''))' ||
    ' AND (LAST_BLOCK_NUMBER < :IN_BLOCK_NUMBER)) ' ||
    ' OR (TRAILER_DATE < TO_DATE(:IN_TRAILER_DATE, ''YYYYMMDDHH24MISS'')))) ' ||
    'WHERE r = 1 ';

  • Same code, different positioning

    Hello,
    I am a fairly new person to web design. I was working on a project for my uncle, and for some reason with the same code I got different results on different browsers.
    Here's what I mean:
    1) Chrome
    2) Mozilla
    #1 "read more..." is positioned higher than #2 "read more..."
    I used relative positioning on the parent ( banner ) and absolute positioning on the child ( text ). Does anyone know what could be the problem here? Thank you!

    To add to what John said, are you sure this isn't just browser variation?   You're never going to get pixel perfect precision across all browsers, web devices or even different versions of the same browsers.  If you look hard enough you will invariably see some differences.  That's what makes web development so challenging.
    If things go terribly wrong, check your code for errors and fix them. 
    CSS - http://jigsaw.w3.org/css-validator/
    HTML - http://validator.w3.org/
    Nancy O.

  • Drawing images gives 2 different results with the same code.

    Im adding my code on here, and its sort of long but ill try to explain it. Most of it you can ignore.
    Anyway i'm making a tree menu with only 1 level of expansion. So you have a TreeMenu object, and this object has some Branch classes. These Branch classes have Leaf classes. That is all. On the menu there is also a little box where you can click to expand and collapse each branch. if a branch is expanded, all of its leaves are shown. if it is collapsed only the branch name is shown.
    So far what I've described above works, there is a small scale compilable working program, that is alright. Theres just a few bugs to fix.
    A little feature of the tree is if a branch or a leaf is selected (has been clicked on in the past) it has a blue background. This sort of works. The branch names seem to work alright, and some of the leaves. However other if you run the example i provided you can click on Leaf 1, and it will be ok, but if you click on Leaf 2 then there blue background is twice as big as it should be. But for the rest, it works ok.
    This is weird to me because the same code handles any of these same situations. So it seems that i get 2 diferent results with the same code. If anyone would like to help heres some stuff you should know:
    You can ignore Leaf class, i dont think theres any errors in there.
    You can ignore just about all of Branch class except the update() method.
    You can ignore all of TreeMenu class except the inner MouseListener class might be useful.
    You can ignore TreeTester. Just the JFrame tester class.
    to run the code:
    javac TreeMenu.java
    java TreeMenu
    http://cs.ucsb.edu/~jsterling/treemenu.zip
    thanks.

    You make a good point Stefan but unfortunately I already checked that.  I have even copied the mapping (right click copy) and pasted it from the working Mapping to the bad Map (Paste) to make sure the context values were all the same.
    I also opened all the queues and compared the values in each.  All values match exactly except for the result(out) queue.
    In both tests I am using the same IDOC XML file. 
    These are the only differences I see.
    1.  The IDOC is exactly the same as far as I can tell but they come from two different source SWCV.  SAP APPL 4.7 and Steelcase_Procurement (ECC 6.0). 
    2.  The working map uses a local UDF.  The bad map calls the UDF from a Function Group.  Is there a Java version difference between the two?
    A better sample of the result queues look like this:
    Correct Result:
    Thickness of Glass: 20
    Height: 10
    Width: 5
    Length: 18
    Thickness of Glass: 10
    Height: 15
    Width: 8
    Length: 14
    Bad Result:
    Thickness of Glass: 20
    <null>
    <null>
    <null>
    Width: 5
    <null>
    <null>
    <null>
    I took this chance to redesign my Variant Config output to separate the characteristics/values, but I'm still bothered that I was unable to determine what would cause the differing values.
    Any ideas?
    Thanks,
    Matt

  • How to execute 2 different application from same Application Server

    Hi,
    I would like to know that how to execute two different applications from the same Application Server with different databases?
    We are using
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0
    Oracle Application Server 10g 10.1.2.0.2
    Regards,
    Hassan

    what type of applications you want to run from the same application server, Hassan?
    What other DB are you using to launch it beside the one you quoted? Is it the MRep DB of infra?

  • Running the same code multiple times with different paramters automatica​lly

    Hi guys,
    I want to run the same code multiple times with different paramters automatically. Actually, I am doing some sample scans which takes around 2 hours n then I have to be there to change the paramters and run it again. Mostly I do use folowing paramters only
    X_Intial, X_Final, X-StepSize
    Y_Intial, Y_Final, Y-StepSize
       Thanks,
    Dushyant

    All you have to di is put all of the parameters for each run into a cluster array. Surround your main program with a for loop and wire the cluster array through the for loop. A for loop will autoindex an input array so inside the for loop you just have to unbundle the cluster to get the parameters for each run.
    Message Edited by Dennis Knutson on 07-13-2006 07:50 AM
    Attachments:
    Cluster Array.JPG ‏9 KB

Maybe you are looking for

  • Expired Scheduling Agreements still in Credit Check / Rescheduling

    Hello everyone, I am running into an issue with expired Scheduling Agreements on the SD side (VA31,VA32, etc.).  There are many Scheduling Agreements that expired on a range of dates from 2005 to 2009, SA's that customers will not send JIT delivery s

  • Track locked! Help!!!

    I can't get a chunk of a guitar solo unlocked. It says the track is locked but the "protect button" is not engaged. I can hear the sample play when I open it in the "sample editor window" but it is greyed out in the "Arrange window". What can I do? M

  • Under line in Sap Script

    Hi Experts, can body let me know how can we underline for word or sentence in sap script out put? Regards

  • 'iTunes has stopped working' during music sync!

    Hi, I've had this issue for months now, and it occurs with both my iPod nano and my iPhone. The sync goes fine, until it comes to copying new tracks over, then it crashes! Does anyone have any ideas? I haven't been able to sync my devices for months

  • Why does the installer keep getting stuck but no error messages appear in the log?

    So as of I think recently, I've been having problems installing things. I'm using installer version 2.1. I found myself having to re-install a driver for my tablet awhile ago, and every time I tried to install it the installer got stuck in the 90%s s