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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T00:49:07+00:00 2026-05-22T00:49:07+00:00

This is a follow up question due to changes being made to the OP

  • 0

This is a follow up question due to changes being made to the OP code. Another user suggested I link the other question to this one.

The OP is : Why does the compiler not run the program even though there are not any errors?

I have a code that compiles but it does not run. I am trying to get the GUI to run so that I can then add the code to perform the functions I need it to. the code follows as:

import java.awt.*;
import javax.swing.*;

import java.awt.event.*;

public class Transaction extends JFrame {

private static final long serialVersionUID = 1L;
// JFrame frame = new JFrame("Bank Account - S Standridge");
JMenuBar menuBar;
JMenu file = new JMenu("File");
JMenu edit = new JMenu("Edit");
JMenu about = new JMenu("About");
JMenuItem transaction = new JMenuItem("Transaction");
JMenuItem summary = new JMenuItem("Summary");
JMenuItem exit = new JMenuItem("Exit");
private JPanel mp;
private JPanel tp;
private JPanel bp;
private JButton calcButton;    
private JButton exitButton; 
private JMenuItem summaryMenuItem;
private JMenuItem aboutMenuItem;
private JMenuItem exitMenuItem;

public Transaction() {
    setTitle("Bank Account - S Standridge");

    mp = new JPanel();
    tp = new JPanel();
    bp = new JPanel();

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    setLayout(new BorderLayout());

    menuPanel();        
    transactionPanel();
    BuildButtonPanel();     

    add(mp, BorderLayout.NORTH);
    add(tp, BorderLayout.WEST);
    add(bp, BorderLayout.SOUTH);

    pack();
    setVisible(true);
}

public void summary() {

}

private void menuPanel() {
    b
    menuBar = new JMenuBar();

    setJMenuBar(menuBar);
    setVisible(true);

    menuBar.add(file);
    menuBar.add(edit);
    menuBar.add(about);

    summaryMenuItem.addActionListener(new SummaryMenuListener());
    aboutMenuItem.addActionListener(new AboutMenuListener());

    file.add(transaction);
    file.add(summaryMenuItem);
    file.add(exitMenuItem);


}

private void BuildButtonPanel() {

     // Create a panel for the buttons.
      bp = new JPanel();

      // Create the buttons.
      calcButton = new JButton("Calculate");
      exitButton = new JButton("Exit");

      // Register the action listeners.
      calcButton.addActionListener(new CalcButtonListener());
      exitButton.addActionListener(new ExitButtonListener());

      // Add the buttons to the button panel.
      bp.add(calcButton);
      bp.add(exitButton);

}

private void transactionPanel()
{
    setLayout(new FlowLayout());

    JRadioButton b1 = new JRadioButton("Checkings");
    // b1.addActionListener(this);
    add(b1);

    JRadioButton b2 = new JRadioButton("Savings");
    // b2.addActionListener(this);
    add(b2);



    ButtonGroup bg = new ButtonGroup();
    bg.add(b1);
    bg.add(b2);


    JTextField tf = new JTextField(5);
    add(tf);
  }

}

class CalcButtonListener implements ActionListener
{
   public void actionPerformed(ActionEvent e)
   {

   }
}

class SummaryMenuListener implements ActionListener
   {
      public void actionPerformed(ActionEvent e)
      {

      }
   }

class ExitButtonListener implements ActionListener
   {
      public void actionPerformed(ActionEvent e)
      {
          System.exit(0);
      }
   }

class AboutMenuListener implements ActionListener
   {
      public void actionPerformed(ActionEvent e)
      {
       // Displays Message Box
      }
   }

The errors that I get in the console are as follows:

java.lang.reflect.InvocationTargetException
IWAV0052E Invocation Target Exception creating Transaction
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.eclipse.ve.internal.java.vce.launcher.remotevm.JFCLauncher$1.run(JFCLauncher.java:59)
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$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$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)
Caused by: java.lang.NullPointerException
at Transaction.menuPanel(Transaction.java:64)
at Transaction.<init>(Transaction.java:37)
... 19 more
  • 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-05-22T00:49:08+00:00Added an answer on May 22, 2026 at 12:49 am

    Something is null on line 64 in Transaction.java

    You have to sets of menu items. These 3 aren’t null.

    JMenuItem transaction = new JMenuItem("Transaction");
    JMenuItem summary = new JMenuItem("Summary");
    JMenuItem exit = new JMenuItem("Exit");
    

    These 3 are null:

    private JMenuItem summaryMenuItem;
    private JMenuItem aboutMenuItem;
    private JMenuItem exitMenuItem;
    

    Remove the last 3 ones, and use your previous 3 ones in the code.

    Your menuPanel method should then look something like this:

    private void menuPanel() {
        menuBar = new JMenuBar();
    
        setJMenuBar(menuBar);
        setVisible(true);
    
        menuBar.add(file);
        menuBar.add(edit);
        menuBar.add(about);
    
        summary.addActionListener(new SummaryMenuListener());
        //aboutMenuItem.addActionListener(new AboutMenuListener());
    
        file.add(transaction);
        file.add(summary);
        file.add(exit);
    }
    

    Your code is working after that change.

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

Sidebar

Related Questions

This is a follow-up question to this one . Take a look at these
This is a follow-on question from the one I asked here . Can constraints
this is a follow up to my recent question ( Code for identifying programming
Update: Check out this follow-up question: Gem Update on Windows - is it broken?
This is a follow on question to How do I delete 1 file from
This is a follow-on question to the How do you use ssh in a
This is a follow up question to This Question . I like (and understand)
This is a follow up question . So, Java store's integers in two's-complements and
This is a follow up question to a previous question I asked about calculating
This is a follow-up question to ASP.NET How to pass container value as javascript

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.