Strange NullPointerException in array

Read bellow. Why this NullPointerException exception?
class YYY{
     public String a1str = new String();
     public String a2str = new String();
     public String a3str = new String();
     public String a4str = new String();
class XXX
     public YYY myNonArray= new YYY();
     public YYY myArray[]= new YYY[20];
     public void SomeFunction(){
          myNonArray.a1str = "Some string"; //works OK
          myArray[0].a1str = "Some string"; //NullPointerException !!! Why?!
}

you have created (and initialized) the array, but you have not "filled" the array (ie created its items) - so all items of the array are null
class XXX
public YYY myNonArray= new YYY();
public YYY myArray[]= new YYY[20];for (int j=0;j<20;j++) {
myArray[j] = new YYY();
>
public void SomeFunction(){

Similar Messages

  • How to avoid NullPointerException---String array created from JTextArea

    Hi,
    I use the method getText() to put the contents of a JTextArea into a String object. Then I use split("\\s+") on that String object to get a String array. Before the contents of the String array are output, I get a NullPointerException. How do I avoid this exception? My code is below.
    //: net/mindview/util/SwingConsole.java
    package net.mindview.util;
    import javax.swing.*;
    public class SwingConsole {
      public static void
      run(final JFrame f, final int width, final int height) {
        SwingUtilities.invokeLater(new Runnable() {
          public void run() {
            f.setTitle(f.getClass().getSimpleName());
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setSize(width, height);
            f.setVisible(true);
    } ///:~
    //: gui/Charts.java
    package gui;
    import javax.swing.*;
    import javax.swing.event.*;
    import java.awt.*;
    import java.awt.event.*;
    import net.mindview.util.SwingConsole;
    public class Charts extends JFrame {
        private int[] numbers;
        private JTextArea input = new JTextArea();
        private JScrollPane areaScrollPane = new JScrollPane(input);
        private JButton b1 = new JButton("Submit");
        private JButton b2 = new JButton("Clear");
        public Charts() {
            add(areaScrollPane);
            areaScrollPane.setPreferredSize(new Dimension(250, 250));
            b1.addActionListener(a1);
            b2.addActionListener(a2);
            add(b1);
            add(b2);
        private ActionListener a1 = new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                String data = input.getText();
                String[] stringArray = data.split("\\s+");
                for (String s:stringArray)
                    System.out.print(s + " ");
                int i = 0;
                for (String s:stringArray)
                    numbers=Integer.parseInt(s);
    i++;
    private ActionListener a2 = new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    input.setText("");
    * @param args the command line arguments
    public static void main(String[] args) {
    // TODO code application logic here
    SwingConsole.run(new Charts(), 400, 400);
    Edited by: gluedtothecomputer on Feb 1, 2009 7:59 PM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    don't forget to init your int array:
          String[] stringArray = data.split("\\s+");
          numbers = new int[stringArray.length];

  • Runtime.exec: strange NullPointerException

    Hi there!
    Since I'm using Runtime 1.4.1-b21 (Windows) it seems that I can't use Runtime.exec any more. The following example code doesn't work:
    public class Test
         public static void main(String[] args) throws Exception
              Runtime lRuntime = Runtime.getRuntime();
              Process lProcess = lRuntime.exec("last.exe");
    I get the following null pointer exception:
    D:\test>java Test
    Exception in thread "main" java.lang.NullPointerException
    at java.lang.Runtime.exec(Runtime.java:551)
    at java.lang.Runtime.exec(Runtime.java:491)
    at java.lang.Runtime.exec(Runtime.java:457)
    at Test.main(Test.java:23)
    I don't know why this happens. 'last.exe' is a simple command line tool. I can use any other program - same error!
    Greeting,
    Markus

    Hi,
    I am getting the same exception on Solaris on doing :
    rt.exec(command); //rt - Runtime object ; command - String[]
    java.lang.NullPointerException
    at java.lang.Runtime.exec(Runtime.java:551)
    at java.lang.Runtime.exec(Runtime.java:491)
    at java.lang.Runtime.exec(Runtime.java:457)
    I read through the article mentioned but could not figure out what could be causing the Null Pointer exception in the exec() method of Runtime.
    Any pointers/advice would be really helpful.
    Thanx

  • Strange NullPointerException in "getLastPartOfName()"

    I get a strange exception on creating a new row for a View.
    The strange thing here is, that the exception is just thrown on one special view object in a special use case. There are six more viewobjects which have exactly the same structure and are, except from their names identical. These are working fine in the same use case.
    I've no clue, what is happening here, so maybe someone, who has access to the BC4J-Sources, can give me a hint, what exactly is happening when this exception is thrown.
    Even if you can't tell me the solution, please tell me, what the BC4J Framework is trying to do, when the exception is thrown. So this might help me to track this down.
    continued...

    oracle.jbo.Row oracle.jbo.server.ViewRowSetImpl.createRowWithEntities(int[], oracle.jbo.server.EntityImpl[], oracle.jbo.AttributeList)
         ViewRowSetImpl.java:1384
    oracle.jbo.Row oracle.jbo.server.ViewRowSetImpl.doCreateAndInitRow(oracle.jbo.AttributeList)
         ViewRowSetImpl.java:1430
    oracle.jbo.Row oracle.jbo.server.ViewRowSetImpl.createRow()
         ViewRowSetImpl.java:1406
    oracle.jbo.Row oracle.jbo.server.ViewObjectImpl.createRow()
         ViewObjectImpl.java:5133
    void oracle.jbo.html.jsp.datatags.RowTag.handleAction()
         RowTag.java:153
    int oracle.jbo.html.jsp.datatags.RowTag.doStartTag()
         RowTag.java:121
    void common.tags._zzTableRights._jspService(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
    [admin/rights/userareas/../../../common/tags/zzTableRights.jsp]
         zzTableRights.jsp:50
    void oracle.jsp.runtime.HttpJsp.service(javax.servlet.ServletRequest, javax.servlet.ServletResponse)
         HttpJsp.java:139
         [SRC:/admin/rights/userareas/../../../common/tags/zzTableRights.jsp]
    void oracle.jsp.runtimev2.JspPageTable.service(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, java.lang.String)
         JspPageTable.java:317
    void oracle.jsp.runtimev2.JspServlet.internalService(javax.servlet.http.Http[i]Long postings are being truncated to ~1 kB at this time.

  • Strange NullPointerException

    Hi,
    I am using Kodo 4.0.1 and sql server. I have the following Folder like
    structure. In the UI you can move Folders around, and at certain moments I
    get a nullpointer exception
    public abstract class Folder extends AbstractFolderEntry{
    private List<AbstractFolderEntry> children = null;
    public Folder(){
    super();
    children = new ArrayList<AbstractFolderEntry>(); //contains both
    (sub)Folders and DataElements
    public List<AbstractFolderEntry> getChildren() {
    Collections.unmodifiableList(children);
    Caused by: java.lang.NullPointerException
         at java.util.Collections$UnmodifiableCollection.<init>(Unknown Source)
         at java.util.Collections$UnmodifiableList.<init>(Unknown Source)
         at java.util.Collections.unmodifiableList(Unknown Source)
         at com.ces.core.domain.Folder.getChildren(Folder.java:150)
         at com.ces.core.application.task.MoveAbstractFolderEntryTask.body
    My .jdo:
    <class name="Folder">
    <field name="children">
    <collection element-type="AbstractFolderEntry" />
    <extension vendor-name="kodo" key="inverse-logical" value="parent"/>
    </field>
    </class>
    The specified method does a check for null and throws a
    NullPointerException. I never set the collection to null. Adding the
    following check to getChildren() seems to solve te problem:
    if(children == null) {
    //This should not happen, but it does and seems
    //to be a bug in Kodo 4.0.1
    //to init children, call size, otherwise it will
    //cause a Nullpointer later on
    children.size();
    kind regards,
    Christiaan

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML><HEAD>
    <META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
    <META content="MSHTML 6.00.2900.2963" name=GENERATOR>
    <STYLE></STYLE>
    </HEAD>
    <BODY>
    <DIV><FONT face=Arial size=2>Hi David,</FONT></DIV>
    <DIV><FONT face=Arial size=2>actually the "children == null" doesnt trigger Kodo
    to load the children fields. The same check is used within
    Collections.unmodifiableList(List l) method where this code throws the
    nullpointer</FONT></DIV>
    <DIV><FONT face=Arial size=2>if(l == null) {</FONT></DIV>
    <DIV><FONT face=Arial size=2>   throw new
    NullpointerExcpetion()</FONT></DIV>
    <DIV><FONT face=Arial size=2>}</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT> </DIV>
    <DIV><FONT face=Arial size=2>I suspect that the problem is caused due to the
    fact that I have two threads working on the objects at the same time (though
    javax.jdo.option.Multithreaded is set to true). One thread evicts the objects
    from cache at certain intervals, the other thread performs certain operations on
    the Folder object. I haven't had a chance to build a testcase for this (will do
    asap), but in my unittest, which doesnt have the situation of the two thrreads,
    it never occurs.</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT> </DIV>
    <DIV><FONT face=Arial size=2><David Ezzio> wrote in message </FONT><A
    href="news:[email protected]"><FONT face=Arial
    size=2>news:[email protected]</FONT></A><FONT face=Arial
    size=2>...</FONT></DIV><FONT face=Arial size=2>> Hi Christiaan,<BR>>
    <BR>> You said that if you add the code,<BR>> <BR>> if (children ==
    null)<BR>> {<BR>> children.size();<BR>> }<BR>> <BR>> to the
    method that returns <BR>> <BR>>
    Collections.unmodifiableList(children);<BR>> <BR>> that it avoids a
    NPE.  Correct?<BR>> <BR>> If so, it would indicate that enhancement
    has a bug.  This behavior indicates that the first code is triggering
    Kodo's field loading while the second is not.  What is very curious is that
    sometimes the field loads and sometimes not, as the NPE is not always
    happening.  <BR>> <BR>> Do you have other constructors for Folder
    that might not initialize the children list?  Have you tried removing the
    instance initialization "... children = null"?  This might be confusing the
    enhancer.  Decompiling the enhanced class and taking a look at what's
    happening in the constructors and the getChildren method would probably tell us
    whether this is an enhancement bug.  Can you do that and post the relevant
    sections?  I find that DJDecompiler works very nicely.<BR>> <BR>> Let
    us know how you make out.<BR>> <BR>> Thanks,<BR>> <BR>> David
    Ezzio</FONT></BODY></HTML>

  • What does this strange NullPointerException mean?

    java.lang.NullPointerException
            at javax.swing.text.FlowView$FlowStrategy.layoutRow(FlowView.java:538)
            at javax.swing.text.FlowView$FlowStrategy.layout(FlowView.java:452)
            at javax.swing.text.FlowView.layout(FlowView.java:184)
            at javax.swing.text.BoxView.setSize(BoxView.java:380)
            at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
            at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:317)
            at javax.swing.text.BoxView.layout(BoxView.java:684)
            at javax.swing.text.BoxView.setSize(BoxView.java:380)
            at javax.swing.text.BoxView.updateChildSizes(BoxView.java:349)
            at javax.swing.text.BoxView.setSpanOnAxis(BoxView.java:331)
            at javax.swing.text.BoxView.layout(BoxView.java:683)
            at javax.swing.text.BoxView.setSize(BoxView.java:380)
            at javax.swing.plaf.basic.BasicTextUI$RootView.setSize(BasicTextUI.java:1701)
            at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1420)
            at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:725)
            at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:868)
            at javax.swing.plaf.basic.BasicTextUI.update(BasicTextUI.java:847)
            at javax.swing.JComponent.paintComponent(JComponent.java:758)
            at javax.swing.JComponent.paint(JComponent.java:1022)
            at javax.swing.JComponent.paintToOffscreen(JComponent.java:5104)
            at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(RepaintManager.java:1386)
            at javax.swing.RepaintManager$PaintManager.paint(RepaintManager.java:1317)
            at javax.swing.RepaintManager.paint(RepaintManager.java:1132)
            at javax.swing.JComponent.paintForceDoubleBuffered(JComponent.java:1058)
            at javax.swing.JViewport.blitDoubleBuffered(JViewport.java:1612)
            at javax.swing.JViewport.windowBlitPaint(JViewport.java:1573)
            at javax.swing.JViewport.setViewPosition(JViewport.java:1118)
            at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.vsbStateChanged(BasicScrollPaneUI.java:1027)
            at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.stateChanged(BasicScrollPaneUI.java:1016)        at javax.swing.DefaultBoundedRangeModel.fireStateChanged(DefaultBoundedRangeModel.java:348)
            at javax.swing.DefaultBoundedRangeModel.setRangeProperties(DefaultBoundedRangeModel.java:285)        at javax.swing.DefaultBoundedRangeModel.setValue(DefaultBoundedRangeModel.java:151)
            at javax.swing.JScrollBar.setValue(JScrollBar.java:446)when invoking verticalScrollBar.setValue(max);
    could somebody tell me how to avoid it?
    Thank you in advance

    Swing components should be updated in the GUI Event Dispatch Thread. Maybe use a SwingUtilities.invokeLater(...) to change the scrollbar value.
    Read the Swing tutorial on Concurrency for more information.

  • Strange NULLPOINTEREXCEPTION while putting code in GUI

    Hi,
    I've created a GUI that handles a XML file. I call a method from out the GUI and pass the TextArea where the output has to be written. When I write something to the TextArea in the go-method then there is no problem, but when I write something to the TextArea from for instance the emit method then I get a NULLPOINTEREXCEPTION in the XML parsers code
    CODE:
    import javax.xml.parsers.SAXParserFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import java.io.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    This class parses any XML documents and echo's it to a new file
    public class XMLPars extends DefaultHandler
    private Writer out;
    public TextArea aTextArea;
    The gomethod accepts two arguments: the xml file and the TextArea to where the output is written
    public void go(String fileName,TextArea attrTextArea)
    attrTextArea.append("TEST1"); //this works
    this.aTextArea = attrTextArea;
    aTextArea.append("TEST2") //this works too;
    //make an instance of ourselves as defaulthandler
    DefaultHandler handler = new XMLPars();
    //use the default (non-validating) parser
    SAXParserFactory factory = SAXParserFactory.newInstance();
    try
    //get the output stream
    File file = new File("debug.txt");
    out = new FileWriter(file);
    //parse the input
    SAXParser saxParser = factory.newSAXParser();
    saxParser.parse(new File (fileName), handler);
    out.close();
    catch (Throwable t)
    t.printStackTrace();
    public void startDocument() throws SAXException
    aTextArea.append("TEST3"); //this causes an NULLPOINTEREXCEPTION
    emit("<?xml version='1.0' encoding='UTF-8'>");
    nl();
    public void endDocument() throws SAXException
    try
    nl();
    out.flush();
    catch (IOException io)
    throw new SAXException("I/O Error",io);
    //writes to the output and flushes
    private void emit(String s) throws SAXException
    try
    out.write(s);
    out.flush();
    aTextArea.append(s); //this doesn't work either
    catch (IOException io)
    throw new SAXException ("I/O error",io);
    //prints a line feed, depending on system type
    private void nl () throws SAXException
    String lineEnd = System.getProperty("line.separator");
    try
    out.write(lineEnd);
    catch (IOException io)
    throw new SAXException ("I/O error",io);
    Please help me out THX a LOT!!!!!!!!!!!!!!!!!!

    THX for reply,
    I tried to instantiate but doesn't seem to work
    public ColorXNS(AttributedTextArea attrTextArea)
    this.aTextArea = attrTextArea;
    public void go(String fileName,AttributedTextArea attrTextArea)
    attrTextArea.append("TEST1\n"); //works fine
    //make an instance of ourselves as defaulthandler
    DefaultHandler handler = new ColorXNS(attrTextArea);
    attrTextArea.append("TEST2\n"); //works fine
    aTextArea.append("TEST3\n"); // this is NOT printed in the TextArea
    //use the default (non-validating) parser
    SAXParserFactory factory = SAXParserFactory.newInstance();
    try
    //get the output stream
    File file = new File("debug.txt");
    out = new FileWriter(file);
    //parse the input
    SAXParser saxParser = factory.newSAXParser();
    saxParser.parse(new File (fileName), handler);
    out.close();
    catch (Throwable t)
    t.printStackTrace();
    Is there something wrong with the initialization??
    THX

  • NullPointerException in 1.4.2 but not in  1.4.1

    Am I going nuts or is there anyone else who experiense strange NullPointerExceptions when running code with JRE 1.4.2 that was once compiled with javac 1.4.1? The code compiles fine with 1.4.1 and runns fine in java 1.4.1, but when using 1.4.2 I get NullPointerExceptions at strage places like JTable.getValueAt for example. There seams to be some kind of diffrence in the behaviour of JComboBox also. Is there something in the new release 1.4.2 that I have missed?

    Any ideas anyone? I seem to have pretty consistent behaviour in a couple of forms - I've stripped out a lot of code and now the overloaded paint does nothing.
    Under java 1.4.2 nothing is painted (as expected) but under 1.5 the window paints!!
    Why??? It seems almost like AWT decides it's going to paint regardless, although it shouldn't.
    I've also noticed that under 1.5 if you move another application over the top of the window, it DOESN'T repaint areas that have needed it (after the initial paint), so in this situation it IS seeing (and obeying) the code in my overloaded paint.
    I tried overloading paintAll(...) with an empty implementation and sure enough under 1.4.2 nothing is painted, but under 1.5 it is painted; but also in this case when I move another application over the top of the window, it DOES repaint!!
    What gives, is this a JVM, compiler, swing or EDT bug??
    Getting desperate...

  • I want to create a "clean" sawtooth wave with my own inserted array.

    I have a PXI module with a fgen5411. I can make a arbitrary waveform with my own array. that's not the problem. The real problem is that if I insert a waveform array with 4096 steps, Labview divides the steps and the 4096 steps are no longer 4096 steps but less. Because of this the created steps of the sawtooth wave excists one time out of 4 points, and the other time out of 5 points and so on.
    I use the "create arbitrary waveform" and the "app sequence waveforms" VI's. And because I use the create arb waveform VI, I have to devide my array values with 10000 so that my scale comes between the values �1 and 1.

    Hello Ben,
    I solved the problem I had with the number of points. The problem was that I was using 1/5 part of the �create arb waveform� scale(between �1 and 1) so that labview generated five points per step.
    Now I can generate a sawtooth with the full 12 bit resolution. But the problem now is that the sawtoothsweep begins negative and ends positive. This is strange because the array I load from file excists out of positive numbers. What I want is a sweep beginning at 2 Volt and ends at at least 8 Volt. I tried to change the offset of the �app sequence waveform� but this did not work. The offset does change, but it can not be made positive. I also tried to devide my array so that it fits in the positive scale of the �create arb waveform
    �(between 0 and 1), but this also did not work. Is it possible to make a positive sweep with the 5411 in ARB mode?
    I send you screenshots from the part of my program. First I load a array from file and devide this by 5000. Then I create a waveform and load this into the �app sequence waveform�.
    Ben, I hope you know what I am doing wrong, because I don�t.
    Attachments:
    load.bmp ‏291 KB
    loadarb.bmp ‏1747 KB
    generate.bmp ‏294 KB

  • Bug in array indicator?

    I found very strange behaviour of Array Indicator (LV 8.20).
    If you look at attached VI, you will see that is very simple VI where only first element of Array should changed randomly every half of second while other element are 8.
    But if I click any element in Array indicator and move mous cursor over it, its value is changed although it should be 8 (see attached video).
    Does anyboby know why is this happening?
    Thanks!
    Attachments:
    Array indicator bug.vi ‏10 KB
    Array indicator.avi ‏176 KB

    Waow... funny bug... A quick work-around would be to set the indicateur as "Disable", but then the user won't be able to use the "index display".
    When my feet touch the ground each morning the devil thinks "bloody hell... He's up again!"

  • New InitialContext() raises a NullPointerException

    Hello gentlemen,
    I have my code that is working nice under Weblogic 8.1 SP 2 and Service Pack 1 (Windows 2000, jdk141_03).
    I switched to Service Pack 5 (no change in my code) and from then I face a strange NullPointerException when I make a call to
    new InitialContext(hashtable).
    (I am creating a Context for making a lookup on an EJB).
    If I revert to Service Pack 2, everything works fine.
    I checked Service Pack 6 too (jdk142_11) and I got the same NullPointerException.
    I am quite in troubles...
    thank you for your help.
    Edited by [email protected] at 01/18/2007 3:34 AM

    franco lazzari wrote:
    Here it is:
    java.lang.NullPointerException
    at weblogic.rjvm.RJVMManager.findExisting(RJVMManager.java:326)
    at weblogic.rjvm.RJVMManager.findOrCreateRemoteInternal(RJVMManager.java:210)
    at weblogic.rjvm.RJVMManager.findOrCreate(RJVMManager.java:184)
    at weblogic.rjvm.RJVMFinder.findOrCreateRemoteServer(RJVMFinder.java:223Odd. The line of code in 81sp5 that supposedly throws an NPE (line 326)
    can't do that in the code I'm looking at. I suggest you open an official
    support case showing this full stacktrace. It presents as a core WLS
    issue.
    Joe
    at weblogic.rjvm.RJVMFinder.findOrCreate(RJVMFinder.java:188)
    at weblogic.rjvm.ServerURL.findOrCreateRJVM(ServerURL.java:125)
    at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLIni
    tialContextFactoryDelegate.java:310)
    at weblogic.jndi.WLInitialContextFactoryDelegate.getInitialContext(WLIni
    tialContextFactoryDelegate.java:253)
    at weblogic.jndi.WLInitialContextFactory.getInitialContext(WLInitialCont
    extFactory.java:135)
    at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:6
    62)
    at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:243
    at javax.naming.InitialContext.init(InitialContext.java:219)
    at javax.naming.InitialContext.<init>(InitialContext.java:195)
    at mnse.securityserver.utenti.GestoreUtentiCentrale.getToken(GestoreUten
    tiCentrale.java:798)
    at mnse.securityserver.utenti.GestoreUtentiCentrale.<init>(GestoreUtenti
    Centrale.java:82)
    at mnse.securityserver.utenti.GestoreUtentiCentrale.createGestoreUtenti(
    GestoreUtentiCentrale.java:72)
    at mnse.securityserver.utenti.GestoreUtentiCentrale.getGestoreUtenti(Ges
    toreUtentiCentrale.java:51)
    at mnse.securityserver.utenti.GestoreFontiCentrale.caricaFonteUtenti(Ges
    toreFontiCentrale.java:216)
    at mnse.securityserver.utenti.GestoreFontiCentrale.<init>(GestoreFontiCe
    ntrale.java:89)
    at mnse.securityserver.utenti.GestoreFontiCentrale.createGestoreFonti(Ge
    storeFontiCentrale.java:62)
    at mnse.securityserver.utenti.GestoreFontiCentrale.getGestoreFonti(Gesto
    reFontiCentrale.java:46)
    at mnse.util.avvio.SecurityLoader.load(SecurityLoader.java:392)
    at mnse.util.avvio.SecurityLoader.getMinosseLogfile(SecurityLoader.java:
    118)
    at mnse.securityserver.logger.MinosseLogger.<init>(MinosseLogger.java:52
    at mnse.securityserver.logger.MinosseLogger.createLogger(MinosseLogger.j
    ava:95)
    at mnse.securityserver.logger.MinosseLogger.getLogger(MinosseLogger.java
    :82)
    at mnse.util.avvio.TimeStamper.getLDAPServerURL(TimeStamper.java:58)
    at mnse.admin.dao.RacsDAO.<init>(RacsDAO.java:59)
    at mnse.admin.impl.AdministratorEJB.getOperatore(AdministratorEJB.java:5
    1)
    at mnse.admin.impl.Administrator_ocrjs3_EOImpl.getOperatore(Administrato
    r_ocrjs3_EOImpl.java:316)
    at mnse.admin.impl.Administrator_ocrjs3_EOImpl_CBV.getOperatore(Unknown
    Source)
    at mnse.console.AdministratorProxy.getOperatore(AdministratorProxy.java:
    85)
    at mnse.console.Controllore.getOperatore(Controllore.java:122)
    at mnse.console.Controllore.esegui(Controllore.java:89)
    at mnse.console.Short.doPost(Short.java:70)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
    at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run
    (ServletStubImpl.java:1077)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:465)
    at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubIm
    pl.java:348)
    at weblogic.servlet.internal.WebAppServletContext$ServletInvocationActio
    n.run(WebAppServletContext.java:7047)
    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
    dSubject.java:321)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
    121)
    at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppSe
    rvletContext.java:3902)
    at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestIm
    pl.java:2773)
    at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:224)
    at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:183)

  • JFormattedTextField array

    Hi all,
    I have this piece of code that runs into a runtime exception error when trying to access an element of its array.
    code snippet
    boolean booln =  true;
    private JFormattedTextField [] formFields = {farm_noFld, block_noFld........};
    for (int i = 0; i < formFields.length; i++)
                System.out.println("length: " + formFields.length);
                System.out.println("index[0] : " + formFields);
                formFields.setEnabled(booln);
    Output from the program..
    length: 27
    index[0] : null
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    The array is created and has a size of 27 objects but I cant seen to access them...Can anyone help?

    The array is created post this part
    [edit]
    actually, the part that creates the objects that are added to the array
    Message was edited by:
    Michael_Dunn

  • Polygon2D.Float

    I created this Polygon class. I've already tested it and it works just like java.awt.Polygon. This class
    supports floating point coordinates. It does not extend Polygon in java.awt. Enjoy
    import java.awt.*;
    import java.awt.geom.*;
    * This is a polygon that supports floating point values.  It does <b> not </b> extend java.awt.Polygon.  A polygon is comprised
    * of an array of x values and an array of it's corrisponding y values.  There is also an integer value - npoints - that determine
    * the number of points you want to be valid.  The polygon starts at xpoints[0] and ypoints[0] (if it exists) and connects a line
    * to xpoints[1] and ypoints[1] and then to xpoints[2] and ypoints[2] and so on until the index equals npoints.  The path is then
    * closed back to xpoints[0] and ypoints[0].  Lets see an example:
    * <p>
    * Polygon2D.Float p = new Polygon2D.Float( new float[] {20,20,40,40}, new float[] {20,40,40,20}, npoints);  //constructs a new new rectangle that is a polygon <br>
    * graphics.fill(p);  // fills a rectangle <br>
    * p.npoints = 3;  // the polygon now ignores the fourth coordinate <br>
    * graphics.fill(p);  // fills a triangle <br>
    * p.npoints = 2; // the polygon now ignores the last two coordinates <br>
    * graphic.fill(p); // does nothing - cannot fill a line (does update the polygon) <br>
    * graphic.draw(p); // draws a line; <br>
    * p.npoints = 5; //not allowed, but no error yet. <br>
    * try{graphic.draw(p)}catch(Exception e) {}// error - IndexOutOfBoundsException <br>
    * p.npoints = 4; <br>
    * p.xpoints[0] = 10; p.ypoints[0] = 10;  // makes it a weard looking rectangle; <br>
    * Rectangle bounds = p.getBounds(); //the bounds is <b> incorrect </b>.  It is the bounds of when p.npoints was set to 2. <br>
    * boolean contains = p.contains(30, 30); //will return false.  Should return true.  The shape is still set to when the p.npoins = 2 <br>
    * p.invalidate(); //updates the the polygon <br>
    * Rectangle bounds = p.getBounds(); //returns the correct bounds <br>
    * boolean contains = p.contains(30, 30); //returns true <br>
    * <p>
    * If the polygon dosen't draw right make sure that your coordinates and npoints are right.  The polygon does not update itself
    * by virtue of changing its coordinates directly or using the translate(float deltaX, float deltaY) method.  The polygon <b> is </b>
    * updated just before every draw (when the getPathIterator(AffineTransform at) method is called).  This has several implications.
    * All the contains, intersects, and getBounds methods go off the state the polygon was after its <b> last </b> update.  So if any of
    * these methods are called after you have manipulated the polygon and before you have redrawn it, then these specific methods return innacurate
    * results, becuase the polygon has not been updated yet.  If such a case occurs, call the invalidate() method to update the polygon forcibly.
    * The documentation for the methods of Polygon2D are coppied straight out of java.awt.Shape.
    * @author Christopher Colon
    * @version 1.0
    public abstract class Polygon2D implements Shape
        protected GeneralPath path;
        public Polygon2D()
           path = new GeneralPath(GeneralPath.WIND_EVEN_ODD);
        /**Call this method after you are done with direct manipulation of the x and y points (including translate) and if you plan
         * to use any of the contains, intersects, or get bounds methods right after the
         * manipulation.  In effect this method 'updates' the polygon to its position and shape.  The polygon is always updated
         * just before drawing, so if you use any of the contains, intersects, or get bounds method
         * right after drawing and before manipulation, then these methods return accurate results.
         * Its in the period between manipulation and drawing that this method should be called if you
         * plan to use the other methods (excluding translate) before drawing.  */
        public abstract void invalidate();
        /**Tests if the specified coordinates are inside the boundary of the Shape.
         * @param x - the specified x coordinate
         * @param y - the specified y coordinate
         * @return true if the specified coordinates are inside the Shape boundary; false otherwise.*/
        public boolean contains(double x, double y)
            {return path.contains(x, y);}
        /**Tests if the interior of the Shape entirely contains the specified rectangular area. All coordinates that lie inside the rectangular area must lie within the Shape for the entire rectanglar area to be considered contained within the Shape.
         * This method might conservatively return false when: <br>
         * <p>
         * the intersect method returns true and <br>
         * the calculations to determine whether or not the Shape entirely contains the rectangular area are prohibitively expensive. <br>
         * <p>
         * This means that this method might return false even though the Shape contains the rectangular area.
         * The Area class can be used to perform more accurate computations of geometric intersection for any Shape
         * object if a more precise answer is required.
         * @param x - the x coordinate of the specified rectangular area
         * @param y - the y coordinate of the specified rectangular area
         * @param w - the width of the specified rectangular area
         * @param h - the height of the specified rectangular area
         * @return true if the interior of the Shape entirely contains the specified rectangular area; false otherwise or, if the Shape
         *          contains the rectangular area and the intersects method returns true and the containment calculations would be too
         *          expensive to perform.*/
        public boolean contains(double x, double y, double w, double h)
            {return path.contains(x,y,w,h);}
        /**Tests if a specified Point2D is inside the boundary of the Shape.
         * @param p - a specified Point2D
         * @return true if the specified Point2D is inside the boundary of the Shape; false otherwise.*/   
        public boolean contains(Point2D p)
            {return path.contains(p);}
        /**Tests if the interior of the Shape entirely contains the specified rectangular area. All coordinates that lie inside the rectangular area must lie within the Shape for the entire rectanglar area to be considered contained within the Shape.
         * This method might conservatively return false when: <br>
         * <p>
         * the intersect method returns true and <br>
         * the calculations to determine whether or not the Shape entirely contains the rectangular area are prohibitively expensive. <br>
         * <p>
         * This means that this method might return false even though the Shape contains the rectangular area.
         * The Area class can be used to perform more accurate computations of geometric intersection for any Shape
         * object if a more precise answer is required.
         * @param r - The specified Rectangle2D
         * @return true if the interior of the Shape entirely contains the specified rectangular area; false otherwise or, if the Shape
         *          contains the rectangular area and the intersects method returns true and the containment calculations would be too
         *          expensive to perform.*/
        public boolean contains(Rectangle2D r)
            {return path.contains(r);}
        /**Returns an integer Rectangle that completely encloses the Shape. Note that there is no guarantee that the returned Rectangle is
         * the smallest bounding box that encloses the Shape, only that the Shape lies entirely within the indicated Rectangle.
         * The returned Rectangle might also fail to completely enclose the Shape if the Shape overflows the limited range of the integer
         * data type. The getBounds2D method generally returns a tighter bounding box due to its greater flexibility in representation.
         * @return an integer Rectangle that completely encloses the Shape.*/
        public Rectangle getBounds()
            {return path.getBounds();}
        /**Returns a high precision and more accurate bounding box of the Shape than the getBounds method. Note that there is no
         * guarantee that the returned Rectangle2D is the smallest bounding box that encloses the Shape, only that the Shape lies
         * entirely within the indicated Rectangle2D. The bounding box returned by this method is usually tighter than that returned by
         * the getBounds method and never fails due to overflow problems since the return value can be an instance of the Rectangle2D that
         * uses double precision values to store the dimensions.
         * @return an instance of Rectangle2D that is a high-precision bounding box of the Shape.*/
        public Rectangle2D getBounds2D()
            {return path.getBounds2D();}
        /**Returns an iterator object that iterates along the Shape boundary and provides access to the geometry of the Shape outline.
         * If an optional AffineTransform is specified, the coordinates returned in the iteration are transformed accordingly.
         * Each call to this method returns a fresh PathIterator object that traverses the geometry of the Shape object independently
         * from any other PathIterator objects in use at the same time.
         * It is recommended, but not guaranteed, that objects implementing the Shape interface
         * isolate iterations that are in process from any changes that might occur to the original object's geometry during such iterations.
         * Before using a particular implementation of the Shape interface in more than one thread simultaneously, refer
         * to its documentation to verify that it guarantees that iterations are isolated from modifications.
         * @param at - an optional AffineTransform to be applied to the coordinates as they are returned in the iteration,
         *              or null if untransformed coordinates are desired
         * @return a new PathIterator object, which independently traverses the geometry of the Shape.*/  
        public abstract PathIterator getPathIterator(AffineTransform at);
         /**Returns an iterator object that iterates along the Shape boundary and provides access to a flattened view of the Shape
          * outline geometry. Only SEG_MOVETO, SEG_LINETO, and SEG_CLOSE point types are returned by the iterator.
          * If an optional AffineTransform is specified, the coordinates returned in the iteration are transformed accordingly.
          * The amount of subdivision of the curved segments is controlled by the flatness parameter, which specifies the maximum
          * distance that any point on the unflattened transformed curve can deviate from the returned flattened path segments.
          * Note that a limit on the accuracy of the flattened path might be silently imposed, causing very small flattening parameters
          * to be treated as larger values. This limit, if there is one, is defined by the particular implementation that is used.
          * Each call to this method returns a fresh PathIterator object that traverses the Shape object geometry independently
          * from any other PathIterator objects in use at the same time. It is recommended, but not guaranteed, that objects implementing
          * the Shape interface isolate iterations that are in process from any changes that might occur to the original object's geometry
          * during such iterations. Before using a particular implementation of this interface in more than one thread simultaneously,
          * refer to its documentation to verify that it guarantees that iterations are isolated from modifications.
          * @param at - an optional AffineTransform to be applied to the coordinates as they are returned in the iteration, or
          *              null if untransformed coordinates are desired
          * @param flatness - the maximum distance that the line segments used to approximate the curved segments are
          *                      allowed to deviate from any point on the original curve
          * @return a new PathIterator that independently traverses the Shape geometry.*/
        public abstract PathIterator getPathIterator(AffineTransform at, double flatness);
        /** Tests if the interior of the Shape intersects the interior of a specified rectangular area. The rectangular area is
         * considered to intersect the Shape if any point is contained in both the interior of the Shape and the specified rectangular area.
         * This method might conservatively return true when: <br>
         * there is a high probability that the rectangular area and the Shape intersect, but  <br>
         * the calculations to accurately determine this intersection are prohibitively expensive. <br>
         * This means that this method might return true even though the rectangular area does not intersect the Shape. <br>
         * The Area class can be used to perform more accurate computations of geometric intersection for any Shape object if a more
         * precise answer is required.
         * @param x - the x coordinate of the specified rectangular area
         * @param y - the y coordinate of the specified rectangular area
         * @param w - the width of the specified rectangular area
         * @param h - the height of the specified rectangular area
         * @return true if the interior of the Shape and the interior of the rectangular area intersect, or are
         *         both highly likely to intersect and intersection calculations would be too expensive to perform; false otherwise.*/
        public boolean intersects(double x, double y, double w, double h)
            {return path.intersects(x, y, w, h);}
        /**Tests if the interior of the Shape intersects the interior of a specified Rectangle2D.
         * This method might conservatively return true when: <br>
         * there is a high probability that the Rectangle2D and the Shape intersect, but <br>
         * the calculations to accurately determine this intersection are prohibitively expensive. <br>
         * This means that this method might return true even though the Rectangle2D does not intersect the Shape.
         * @param r - the specified Rectangle2D
         * @return true if the interior of the Shape and the interior of the specified Rectangle2D intersect, or are both
         *         highly likely to intersect and intersection calculations would be too expensive to perform; false otherwise.*/
        public boolean intersects(Rectangle2D r)
            {return path.intersects(r);}
        public static class Float extends Polygon2D implements Cloneable
            public float xpoints[];
            public float ypoints[];
            public int npoints;
            /**Creates a new empty polygon. The array of xpoints and ypoints is set to a size of 4.  So long as npoints remain 0
             * then everthing is fine.  The addPoint(float x, float y) appends the coordinates to xpoints[npoints+1] and ypoints[npoints+1]
             * and then increments npoints.*/
            public Float()
                xpoints = new float[4];
                ypoints = new float[4];
                npoints = 0;
            /**Creates a new empty polygon. The array of xpoints and ypoints is set to a size of the expectedCapacity.  So long as npoints remain 0
             * then everthing is fine.  The addPoint(float x, float y) appends the coordinates to xpoints[npoints+1] and ypoints[npoints+1]
             * and then increments npoints.
             * @throws NegativeArraySizeException If expectedCapacity < 0*/
            public Float(int expectedCapacity)
                if(expectedCapacity < 0) throw new NegativeArraySizeException("negative array size");
                xpoints = new float[expectedCapacity];
                ypoints = new float[expectedCapacity];
                npoints = 0;
            /**Creates a new polygon that represent the given specifications.*/
            public Float(float[] x, float[] y, int npoints)
                if(npoints < 0) throw new NegativeArraySizeException("negative amount of sides (npoints < 0)");
                if(npoints > x.length || npoints > y.length) throw new IndexOutOfBoundsException("more sides than points");
                if(x == null || y == null) throw new NullPointerException("null array of points");
                this.xpoints = x;
                this.ypoints = y;
                this.npoints = npoints;
                constructPath();
            /**Creates a new polygon that represent the given specifications.  The integers are coppied over as float values.*/
            public Float(int[] x, int[] y, int npoints)
                if(npoints < 0) throw new NegativeArraySizeException("negative amount of sides (npoints < 0)");
                if(npoints > x.length || npoints > y.length) throw new IndexOutOfBoundsException("more sides than points");
                if(x == null || y == null) throw new NullPointerException("null array of points");
                xpoints = new float[x.length];
                for(int index = 0; index < x.length; index++) xpoints[index] = x[index];
                ypoints = new float[y.length];
                for(int index = 0; index < y.length; index++) ypoints[index] = y[index];
                this.npoints = npoints;
                constructPath();           
           /*Updates the polygon.*/    
           private synchronized void constructPath()
                if(npoints < 0) throw new NegativeArraySizeException("negative amound of sides (nPoints < 0)");
                path.reset();
                if(xpoints.length == 0 || ypoints.length == 0) return;
                path.moveTo(xpoints[0], ypoints[0]);
                for(int index = 0; index < npoints; index++)
                    path.lineTo(xpoints[index],ypoints[index]);
                path.closePath();
            /**The addPoint(float x, float y) appends the coordinates to xpoints[npoints+1] and ypoints[npoints+1]
             * and then increments npoints.*/
            public synchronized void addPoint(float x, float y)
                if(xpoints.length == npoints)
                    float[] temp = new float[xpoints.length+1];
                    for(int index = 0; index < xpoints.length; index++) temp[index] = xpoints[index];
                    xpoints = temp;
                if(ypoints.length == npoints)
                    float[] temp = new float[ypoints.length+1];
                    for(int index = 0; index < ypoints.length; index++) temp[index] = ypoints[index];
                    ypoints = temp;
                xpoints[npoints+1] = x;
                ypoints[npoints+1] = y;
                npoints++;
            /**Rotate the polygon by the specified amount of degrees around the specified pivot point. It is entirly possible
             * that the polygon could shrink a little or grow a little, after repeated calls to this method.  This is due to
             * rounding errors (double to float).  If the polygon shrinks a little, it will expand a little the next time and vise versa. 
             * The net result is that the polygon is always within 5 (just an estimate) pixels of the intended polygon rotation. So
             * the polygon will never expand too much or shrink too much.  In general the greatest shrinkage or expansion occurs
             * when the polygon is rotated about its center.*/
            public void rotate(double deltaTheta, double pivotX, double pivotY)
                while(deltaTheta >= 360) deltaTheta -= 360;
                while(deltaTheta < 0) deltaTheta += 360;
                for(int index = 0; index < npoints; index++)
                    if(xpoints[index] == pivotX && ypoints[index] == pivotY) continue;
                    double distance = Point.distance(xpoints[index], ypoints[index], pivotX, pivotY);
                    double angle = Math.atan( -(ypoints[index] - pivotY) / (xpoints[index] - pivotX) );
                    if((xpoints[index] - pivotX) < 0) angle += Math.PI;
                    angle += Math.toRadians(deltaTheta);
                    xpoints[index] = (float) (Math.cos(angle) * distance + pivotX);
                    ypoints[index] = (float) (-Math.sin(angle) * distance + pivotY);
            /**Rotate the polygon about its center by the specified amount of degrees.  This is the equivalent of calling
             * rotate(deltaTheta, (float) getXMid(), (float) getYMid()).*/
            public void rotate(double deltaTheta)
                rotate(deltaTheta, getXMid(), getYMid());
            /**Resize the polygon by the specified factor.  A factor of 1 will not change the polygon.
             * A factor greater than 1 will make the polygon grow.  A factor between 0 and 1 will make the polygon shrink.
             * The polygon shrinks towards its center or grows away from its center.
             * @throws IllegalArgumentException if the factor is less than 0.*/
            public void resize(double factor)
                if(factor < 0) throw new IllegalArgumentException("illegal factor");
                if(factor == 1) return;
                double xMid = getXMid();
                double yMid = getYMid();
                for(int index = 0; index < npoints; index++)
                    xpoints[index] = (float) (((xpoints[index] - xMid) * factor) + xMid);
                    ypoints[index] = (float) (((ypoints[index] - yMid) * factor) + yMid);
            /**Returns the x coordinate of the mid point (center) of this polygon.*/
            public double getXMid()
                double sum = 0;
                for(int index = 0; index < npoints; index++) sum += xpoints[index];
                return sum / npoints;
            /**Returns the y coordinate of the mid point (center) of this polygon.*/
            public double getYMid()
                double sum = 0;
                for(int index = 0; index < npoints; index++) sum += ypoints[index];
                return sum / npoints;
            /**Resets this polygon to an empty polygon.*/
            public synchronized void reset()
                xpoints = new float[xpoints.length];
                ypoints = new float[ypoints.length];
                npoints = 0;
             /**Translates the polygon by the specified x and y amounts.  The polygon is not updated
              * after the transformation.*/
            public void translate(float deltaX, float deltaY)
                for(int index = 0; index < xpoints.length; index++) xpoints[index] += deltaX;
                for(int index = 0; index < ypoints.length; index++) ypoints[index] += deltaY;
            public void invalidate()
                 {constructPath();}
            public PathIterator getPathIterator(AffineTransform at)
            {   constructPath();
                return path.getPathIterator(at);}
            public PathIterator getPathIterator(AffineTransform at, double flatness)
            {   constructPath();
                return path.getPathIterator(at, flatness);}
            /**Returns a polygon with the same shape and points.*/
            public Object clone()
                return new Polygon2D.Float(xpoints, ypoints, npoints);
    }

    I assume the reason you posted your code is because you want feedback. The GeneralPath class does not allow the points to be changed (or even looked at) once an operation has been performed. If that is the problem you were facing, then I probably would recommend using the GeneralPath class as a guideline to implement your new class on. I don't see the need to wrap the "Float" class inside the Polygon2D class. The fact that Polygon2D.Float is a container of points is not very clear by the name. Lastly, it looks like everytime you add a point, you will have to call invalidate() to update the internal storage. That is somewhat inefficient, and probably more confusing than anything. For your clone method, I would recommend doing a deep copy.

  • WebService class

    Hello, everybody!
    I would say that working with arrays returned from the web
    service (written on C# if it matters) is the most peculiar things
    in the FMS. For starting FMS documentation states: "Note: The
    WebService class is not able to retrieve complex data or an array
    returned by a web service.". But it IS able to work with arrays
    return by the web service. The result has length property, you can
    select any array element by index. What is that documentation note
    for? Is it deprecated and authors forgot to remove it from the
    docs?
    The second strange thing with arrays is the following. If I
    try to work with array returned from the web server in the most
    natural way, for example:
    service.onResult = function(result)
    for (var i = 0; i < result.length; i++)
    // do something
    the application often is unloaded WITHOUT any additional
    information besides "Unloaded application instance xxx". And
    application event onAppStop is never called in such cases.
    I found workaround, and it works. The workaround is the
    following:
    service.onResult = function(result)
    for (var k = 0; k < result.length; k++)
    result[k] = result.sCall.decodeResultNode(
    result.xmlNodes[k],result.arrayType);
    // do something
    And it is documented nowhere!
    Now I have bumped into next problem -- the web service
    returns an array with many elements (~650). The FMS application
    again just unloaded with the last words "unloaded application
    instance" even if service onResult handler doesn't contain any code
    at all!
    I am using FMS 3. Does anybody know how to work with arrays
    returned from web service correctly and have explanations for all
    bizarre thing I've just described?

    Thankyou very much for your reply, Eric (both here and in the web services forum).
    The way I generate the web service is just to right click on the java file and say 'generate web service'. I can't seem to get at the code that is generated, but it appears that there is nothing in there that I can change to rename the classes.
    I may just live with it and refactor the existing client code to match the class names that are given.
    Tim

  • Multi-Client TCP Server /w Swing GUI

    Hi everybody,
    i have to develop a Multi-Client TCP Server with a Swing GUI. The GUI mainly consists of a JTable which shows various trace messages from processes running on other computers. As the data needs to be filtered i�m using a custom TableModel derived from AbstractTableModel. I�m creating a new thread for every client that connects as shown in http://java.sun.com/developer/onlineTraining/Programming/BasicJava2/socket.html
    Now every client thread reads data from its TCP connection and puts it into the JTable by calling the method addRow of the model. But i�m getting strange NullPointerExceptions and IndexOutOfBoundExceptions when data arrives (i�m using ArrayList in the model). These exceptions never show in a single-threaded Swing app (i�ve tested this already, so i don�t think it�s a bug in my model), so i think this is a problem with Swing�s thread unsafety? Do you have any hints on how to get away with it? Also general design tips for a Multi-Client TCP Server /w Swing GUI are greatly appreciated.
    Thanks in advance!
    Best regards,
    Disposable_Hero

    Of course, but i don�t think it is the model (as said before it works fine in a single thread swing app)
    Here�s the code:
    public class LogTableModel extends AbstractTableModel{
    private Vector dataVector;
    private Vector filterVector;
    private String[] columnIdentifiers;
    private Vector filteredbyProcess;
    private Vector filteredbyLoglevel;
    private boolean bEnableRefresh;
    /** Creates a new instance of LogTableModel */
    public LogTableModel() {
    dataVector=new Vector(0);
    columnIdentifiers=new String[]{"LogTime","HostName","IP","ProcessName","LogLevel","Handle","PID","TID","LogData"};
    filteredbyProcess=new Vector(0);
    filteredbyLoglevel=new Vector(0);
    filterVector=new Vector(0);
    bEnableRefresh=true;
    public synchronized void enableRefresh(boolean bEnableRefresh){
    this.bEnableRefresh=bEnableRefresh;
    if(bEnableRefresh){
    this.buildIndexListBasedOnFilter();
    public synchronized void addRow(LogLine row){
    dataVector.add(row);
    if(bEnableRefresh)
    this.buildIndexListBasedOnFilter();
    public synchronized void addFilter(Filter filter){
    filterVector.add(filter);
    if(filter.isActive())
    this.buildIndexListBasedOnFilter();
    public synchronized void setFilterActive(String name,boolean active){
    int i;
    for(i=0;i<filterVector.size();i++)
    if(((Filter)filterVector.elementAt(i)).getName().equals(name))
    break;
    Filter tmp=(Filter)filterVector.elementAt(i);
    tmp.setActive(active);
    if(active)
    this.buildIndexListBasedOnFilter();
    public synchronized void setFilterLoglevel(String name,int Loglevel){
    int i;
    for(i=0;i<filterVector.size();i++)
    if(((Filter)filterVector.elementAt(i)).getName().equals(name))
    break;
    Filter tmp=(Filter)filterVector.elementAt(i);
    tmp.setLoglevel(Loglevel);
    if(tmp.isActive()==false)
    this.buildIndexListBasedOnFilter();
    private void buildIndexListBasedOnFilter(){
    filteredbyProcess.clear();
    filteredbyLoglevel.clear();
    applyProcessFilter();
    applyLoglevelFilter();
    if(bEnableRefresh)
    this.fireTableDataChanged();
    private void applyProcessFilter(){
    LogLine line=null;
    Filter filter=null;
    for(int i=0;i<dataVector.size();i++){
    for(int j=0;j<filterVector.size();j++){
    filter=(Filter)filterVector.elementAt(j);
    line=(LogLine)dataVector.elementAt(i);
    if(filter.isActive()&&(filter.getName().equals(line.getProcessName()))){
    line.setHidden(true);
    break;
    else{
    line.setHidden(false);
    if(line.getHidden()!=true)
    filteredbyProcess.add(new Integer(i));
    private void applyLoglevelFilter(){
    for(int i=0;i<filteredbyProcess.size();i++){
    int index=((Integer)filteredbyProcess.get(i)).intValue();
    LogLine line=(LogLine)dataVector.elementAt(index);
    for(int j=0;j<filterVector.size();j++){
    if(((Filter)filterVector.elementAt(j)).getName().equals(line.getProcessName())){
    Filter filter=(Filter)filterVector.elementAt(j);
    if((filter.getLoglevel()&line.getLogLevelAsInt())!=line.getLogLevelAsInt())
    line.setHidden(true);
    else
    filteredbyLoglevel.add(new Integer(index));
    break;
    public synchronized String getColumnName(int columnIndex){
    return columnIdentifiers[columnIndex];
    public synchronized void clearData(){
    dataVector.clear();
    filteredbyProcess.clear();
    filteredbyLoglevel.clear();
    public synchronized int getColumnCount() {
    return columnIdentifiers.length;
    public synchronized int getRowCount() {
    return filteredbyLoglevel.size();
    public synchronized Object getValueAt(int rowIndex, int columnIndex) {
    int iIndex=((Integer)filteredbyLoglevel.get(rowIndex)).intValue();// hier krachts warum???
    LogLine tmp=(LogLine)dataVector.elementAt(iIndex);
    switch(columnIndex){
    case 0:
    return tmp.getLogTime();
    case 1:
    return tmp.getHostName();
    case 2:
    return tmp.getIP();
    case 3:
    return tmp.getProcessName();
    case 4:
    return tmp.getLogLevel();
    case 5:
    return tmp.getHandle();
    case 6:
    return tmp.getProcessID();
    case 7:
    return tmp.getThreadID();
    case 8:
    return tmp.getLogData();
    default:
    return null;

Maybe you are looking for

  • Conversion of string to object

    hello... i am doing a project in java , and m stuck , i would like to find out how to convert a double value into an object to put teh double value into the textfield which i would like to show to teh user who is using my program

  • How to adjust layer over-flow scroll bar?

    I'm using a layer with the overflow set to 'auto'. Is it also possible to set the vertical scroll bar (for the layer) to appear on the left rather than the right?

  • Accounts Reveivable-Applying Credit Memo to and Outstanding invoice

    I have a remote client that can't apply a credit memo to an outstanding invoice in AR. They are on 12.1.3. This seems simple enough. Am I missing something. Thanks Rob

  • Pie Chart Problems

    Hello all. I am trying to create a pie chart that displays 3 categories from a task list: Complete, In Progress, and Not Started. Currently my chart looks like a 5 part pie chart, 3 seperate parts for In Progress, 1 part for Complete, and 1 part for

  • License of Database Mobile server

    Hi all Can any one of you give me the information about the license fee for oracle database mobile server. How is Oracle database mobile server different from SQLite-sync?? Thanks in advance Regards