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 9155521
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:36:47+00:00 2026-06-17T12:36:47+00:00

I have tried to go over this my self but i do not know

  • 0

I have tried to go over this my self but i do not know how to resolve this.

I am getting this error when i try and run my addressBookUi class.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at addressBookUI.startComponents(addressBookUI.java:43)
at addressBookUI.<init>(addressBookUI.java:6)
at addressBookUI$2.run(addressBookUI.java:143)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

Here is my addressBookUi class

    import javax.swing.table.DefaultTableModel;

public class addressBookUI extends javax.swing.JFrame {

    public addressBookUI() {
        startComponents();
    }

    private void startComponents() {
        mainScrollPane = new javax.swing.JScrollPane();
        mainTable = new javax.swing.JTable();
        addButton = new javax.swing.JButton();
        saveButton = new javax.swing.JButton();
        deleteButton = new javax.swing.JButton();
        mainMenuBar = new javax.swing.JMenuBar();
        mainMenu = new javax.swing.JMenu();
        newMenuItem = new javax.swing.JMenuItem();
        openMenuItem = new javax.swing.JMenuItem();
        saveMenuItem = new javax.swing.JMenuItem();
        printMenuItem = new javax.swing.JMenuItem();
        quitMenuItem = new javax.swing.JMenuItem();
        editMenuBar = new javax.swing.JMenu();
        editPersonsMenuItem = new javax.swing.JMenuItem();
        sortNameMenuItem = new javax.swing.JMenuItem();
        sortPostcodeMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

        mainTable.setModel(new javax.swing.table.DefaultTableModel(
                new Object[][] { { null, null, null, null },
                        { null, null, null, null }, { null, null, null, null },
                        { null, null, null, null } }, new String[] { "Title 1",
                        "Title 2", "Title 3", "Title 4" }));

        mainScrollPane.setViewportView(mainTable);

        addButton.setText("Add");

        saveButton.setText("Save Row");

        deleteButton.setText("Delete Row");

        refreshButton.setText("Refresh");
        refreshButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshButtonActionPerformed(evt);
            }
        });

        mainMenu.setText("File");

        newMenuItem.setText("New");
        mainMenu.add(newMenuItem);

        openMenuItem.setText("Open");

        saveMenuItem.setText("Save");
        mainMenu.add(saveMenuItem);

        printMenuItem.setText("Print");
        mainMenu.add(printMenuItem);

        quitMenuItem.setText("Quit");
        mainMenu.add(quitMenuItem);

        mainMenuBar.add(mainMenu);

        editMenuBar.setText("Edit");

        editPersonsMenuItem.setText("Edit Selected Persons");
        editMenuBar.add(editPersonsMenuItem);

        sortNameMenuItem.setText("Sort by Name");
        editMenuBar.add(sortNameMenuItem);

        sortPostcodeMenuItem.setText("Sort by Postcode");
        editMenuBar.add(sortPostcodeMenuItem);

        mainMenuBar.add(editMenuBar);

//      mainMenuBar.add(helpMenuBar);

        setJMenuBar(mainMenuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
                getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(mainScrollPane)
                .addGroup(
                        layout.createSequentialGroup()
                                .addContainerGap()
                                .addComponent(addButton,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        155,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(saveButton,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        155,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(deleteButton,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        155,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(refreshButton,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        155,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addContainerGap(51, Short.MAX_VALUE)));
        layout.setVerticalGroup(layout
                .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(
                        layout.createSequentialGroup()
                                .addComponent(mainScrollPane,
                                        javax.swing.GroupLayout.PREFERRED_SIZE,
                                        163,
                                        javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addPreferredGap(
                                        javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(
                                        layout.createParallelGroup(
                                                javax.swing.GroupLayout.Alignment.BASELINE)
                                                .addComponent(addButton)
                                                .addComponent(saveButton)
                                                .addComponent(deleteButton)
                                                .addComponent(refreshButton))
                                .addGap(0, 17, Short.MAX_VALUE)));

        pack();
    }

    private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {// GEN-FIRST:event_refreshButtonActionPerformed

    }

    public static void main(String[] args) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new addressBookUI().setVisible(true);
            }
        });

    }

//  protected javax.swing.JMenuItem aboutHelpMenuBar;
    protected javax.swing.JButton addButton;
    protected javax.swing.JButton deleteButton;
    private javax.swing.JMenu editMenuBar;
    protected javax.swing.JMenuItem editPersonsMenuItem;
    private javax.swing.JMenu mainMenu;
//  private javax.swing.JMenu helpMenuBar;
    private javax.swing.JScrollPane mainScrollPane;
    private javax.swing.JMenuBar mainMenuBar;
    protected javax.swing.JTable mainTable;
    protected javax.swing.JMenuItem newMenuItem;
    protected javax.swing.JMenuItem openMenuItem;
    protected javax.swing.JMenuItem printMenuItem;
    protected javax.swing.JMenuItem quitMenuItem;
    protected javax.swing.JButton refreshButton;
    protected javax.swing.JButton saveButton;
    protected javax.swing.JMenuItem saveMenuItem;
    protected javax.swing.JMenuItem sortNameMenuItem;
    protected javax.swing.JMenuItem sortPostcodeMenuItem;
}

If anyone could help that would be great

  • 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-17T12:36:47+00:00Added an answer on June 17, 2026 at 12:36 pm

    refreshButton is null. Do this:

    refreshButton = new javax.swing.JButton();
    

    just before refreshButton.setText("Refresh");

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried searching over the internet about this problem but not able to
Have tried to find solutions for this and can't really come up with anything.
I have tried this: #define format(f, ...) \ int size = strlen(f) + (sizeof((int[]){__VA_ARGS__})/sizeof(int))
I have tried many permutations but they all don't seems to work well. Am
I have been all over this one, and I am just plumb stuck. I
Ok, I have read a lot of posts and resources about this but I
I have a view controller called vc0 which is presented like this: [self presentViewController:
I have a class as follows: class Hand(): def __init__(self, hand_a, play_deck, split_count, name):
I see this question asked all over the internet, and I've tried following them
I have tried to go through the jungle (really, PayPal, why don't you weed

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.