Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8345505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:41:37+00:00 2026-06-09T06:41:37+00:00

Na is a parameter. I’m sure that this parameter is correct. I’ve declared an

  • 0

Na is a parameter. I’m sure that this parameter is correct.
I’ve declared an array of Na JTextField, And I would like to use one of them. But when I run my code, There is an exception…

That’s my code :

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

class Panneau_fenetre1A extends JPanel                      
{   
    public Panneau_fenetre1A(int Na)
    {
        JTextField[] allField = new JTextField [Na];
        for(int i = 0;i<Na;i++)
        {
            allField[i].setText(String.valueOf(0));
            allField[i].setBounds(150, 350+i*25,20, 20);
        }
    }

}

That’s the exception :

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at Panneau_fenetre1A.<init>(Panneau_fenetre1A.java:18)
    at Cadre_fenetre1A.<init>(Cadre_fenetre1A.java:13)
    at Panneau_fenetre$ecout1.actionPerformed(Panneau_fenetre.java:64)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
    at java.awt.Component.processMouseEvent(Component.java:6268)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
    at java.awt.Component.processEvent(Component.java:6033)
    at java.awt.Container.processEvent(Container.java:2045)
    at java.awt.Component.dispatchEventImpl(Component.java:4629)
    at java.awt.Container.dispatchEventImpl(Container.java:2103)
    at java.awt.Component.dispatchEvent(Component.java:4455)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
    at java.awt.Container.dispatchEventImpl(Container.java:2089)
    at java.awt.Window.dispatchEventImpl(Window.java:2517)
    at java.awt.Component.dispatchEvent(Component.java:4455)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:649)
    at java.awt.EventQueue.access$000(EventQueue.java:96)
    at java.awt.EventQueue$1.run(EventQueue.java:608)
    at java.awt.EventQueue$1.run(EventQueue.java:606)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
    at java.awt.EventQueue$2.run(EventQueue.java:622)
    at java.awt.EventQueue$2.run(EventQueue.java:620)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:619)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T06:41:41+00:00Added an answer on June 9, 2026 at 6:41 am

    This line…

    JTextField[] allField = new JTextField [Na];
    

    initializes a new ARRAY, which will hold JTextField objects. The array has -Na- spaces in it, but each space is still empty. You still need to create the JTextField object to go into the empty array spaces.

    Something like this should work…

    for(int i = 0;i < Na;i++)
    {
        allField[i] = new JTextField(String.valueOf(0));
        allField[i].setBounds(150, 350 + i * 25, 20, 20);
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use requestAction with parameter return $this->requestAction (....,array('return'); request action in plugin . plugin
I am calculating one parameter(X) this way: <?php $link=mysql_connect(localhost,root,); mysql_select_db(hand); $result = mysql_query(select *
My method has a parameter, I have to use that in my For loop
Like the parameter in ISNULL function? Something we can use to define: create function
When specifying a parameter to execute() in psycopg2 in Python, like this: cursor.execute('SELECT *
I like to use parameter for FILENAME in the code below, instead of N'D:\DBName.mdf'
Facebook allows a distance parameter for their search like https://graph.facebook.com/search?q=coffee&type=place&center=37.76,-122.427&distance=1000 They don't say what
EventDispatcher.addEventListener() expects first parameter for event type (parameter of String type). But the current
In this display.newText parameter, what does 16*2 mean? Thanks. local display_txt=display.newText(Wait,0,0,native.SystemFont,16*2)
I want my request parameter map in my custom map like Map<String, String> reqMap

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.