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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T17:07:10+00:00 2026-05-20T17:07:10+00:00

I have a pretty good size project I’m working on here and I was

  • 0

I have a pretty good size project I’m working on here and I was adjusting one part and now I’m getting this errer box that pops up when I try and run the code. It was working before and the only are that I changed was “CREATE CONTRACTORS”. The error is either going to be in that section, or all the way at the bottom, I think. I am using Eclipse to run the code and after I run it I not only get that box to pop up, but a message at the bottom of the code that says: java.lang.NoSuchMethodError: main Exception in thread “main”

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

public class test extends JFrame implements ActionListener{
private JTabbedPane jtabbedPane;
private JPanel General;
private JPanel Pools;
private JPanel HotTub;
private JPanel Customers;
private JPanel Contractors;

JTextField lengthTextPool, widthTextPool, depthTextPool, volumeTextPool,
lengthTextHotTub, widthTextHotTub, depthTextHotTub, volumeTextHotTub;

JTextArea NameTextCustomers, ExistTextCustomers;


public test(){
setTitle("Volume Calculator");
setSize(300, 200);

JPanel topPanel = new JPanel();
topPanel.setLayout( new BorderLayout() );
getContentPane().add( topPanel );

createGeneral();
createPools();
createHotTub();
createCustomers();
createContractors();

jtabbedPane = new JTabbedPane();
jtabbedPane.addTab("General", General);
jtabbedPane.addTab("Pool", Pools);
jtabbedPane.addTab("Hot Tub", HotTub);
jtabbedPane.addTab("Customers", Customers);
jtabbedPane.addTab("Contractors", Contractors);
topPanel.add(jtabbedPane, BorderLayout.CENTER);
              }

/*        GENERAL        */

public void createGeneral(){
    General = new JPanel();
    General.setLayout( null );

    JLabel DateLabel = new JLabel("Today's Date");
    DateLabel.setBounds(10, 15, 150, 20);
    General.add( DateLabel );
    JFormattedTextField date = new JFormattedTextField(
            java.util.Calendar.getInstance().getTime());
            date.setEditable(false);
            date.setBounds(90,15,150,20);
            General.add(date);

            JButton Exit = new JButton("Exit");
            Exit.setBounds(20,50,80,20);
            Exit.addActionListener(this);
            Exit.setBackground(Color.white);
            General.add(Exit);
                                     }
/*        CREATE POOL        */

public void createPools(){
    Pools = new JPanel();
    Pools.setLayout( null );
JLabel lengthLabelPool = new JLabel("Length of pool (ft):");
    lengthLabelPool.setBounds(10, 15, 260, 20);
    Pools.add( lengthLabelPool );
lengthTextPool = new JTextField();
    lengthTextPool.setBounds(180, 15, 150, 20);
    Pools.add( lengthTextPool );
JLabel widthLabelPool = new JLabel("Width of pool (ft):");
    widthLabelPool.setBounds(10, 40, 260, 20);
    Pools.add( widthLabelPool );
widthTextPool = new JTextField();
    widthTextPool.setBounds(180, 40, 150, 20);
    Pools.add( widthTextPool );
JLabel depthLabelPool = new JLabel("Average Depth of pool (ft):");
    depthLabelPool.setBounds( 10, 65, 260, 20 );
    Pools.add( depthLabelPool );
depthTextPool = new JTextField();
    depthTextPool.setBounds(180, 65, 150, 20);
    Pools.add( depthTextPool );
JLabel volumeLabelPool = new JLabel("The pool's volume is:(ft ^3");
    volumeLabelPool.setBounds(10, 110, 260, 20);
    Pools.add( volumeLabelPool );
    volumeTextPool = new JTextField();
    volumeTextPool.setBounds(180, 110, 150, 20);
    volumeTextPool.setEditable(false);
Pools.add(volumeTextPool);

JButton calcVolumePool = new JButton("Calculate Pool Volume");
    calcVolumePool.setBounds(20,250,180,20);
    calcVolumePool.addActionListener(this);
    calcVolumePool.setBackground(Color.white);
    Pools.add(calcVolumePool);

JButton Exit = new JButton("Exit");
    Exit.setBounds(220,250,80,20);
    Exit.addActionListener(this);
    Exit.setBackground(Color.white);
    Pools.add(Exit);
                       }

/*        CREATE HOT TUB        */

public void createHotTub(){
    HotTub = new JPanel();
    HotTub.setLayout( null );
JLabel lengthLabel2 = new JLabel("Length of Hot Tub (ft):");
    lengthLabel2.setBounds(10, 15, 260, 20);
    HotTub.add( lengthLabel2 );
lengthTextHotTub = new JTextField();
    lengthTextHotTub.setBounds(180, 15, 150, 20);
    HotTub.add( lengthTextHotTub );
JLabel widthLabelHotTub = new JLabel("Width of Hot Tub (ft):");
    widthLabelHotTub.setBounds(10, 40, 260, 20);
    HotTub.add( widthLabelHotTub );
widthTextHotTub = new JTextField();
    widthTextHotTub.setBounds(180, 40, 150, 20);
    HotTub.add( widthTextHotTub );
JLabel depthLabelHotTub = new JLabel("Average Depth of Hot Tub (ft):");
    depthLabelHotTub.setBounds( 10, 65, 260, 20 );
    HotTub.add( depthLabelHotTub );
depthTextHotTub = new JTextField();
    depthTextHotTub.setBounds(180, 65, 150, 20);
    HotTub.add( depthTextHotTub );
JLabel volumeLabelHotTub = new JLabel("The Hot Tub's volume is:(ft ^3");
    volumeLabelHotTub.setBounds(10, 110, 260, 20);
    HotTub.add( volumeLabelHotTub );
    volumeTextHotTub = new JTextField();
    volumeTextHotTub.setBounds(180, 110, 150, 20);
    volumeTextHotTub.setEditable(false);
    HotTub.add(volumeTextHotTub);

JButton calcVolume = new JButton("Calculate Hot Tub Volume");
    calcVolume.setBounds(20,250,180,20);
    calcVolume.addActionListener(this);
    calcVolume.setBackground(Color.white);
    HotTub.add(calcVolume);

JButton Exit = new JButton("Exit");
    Exit.setBounds(220,250,80,20);
    Exit.addActionListener(this);
    Exit.setBackground(Color.white);
    HotTub.add(Exit);
                       }
/*        CREATE CUSTOMERS        */

public void createCustomers(){
    Customers = new JPanel();
    Customers.setLayout( null );

    NameTextCustomers = new JTextArea();
    NameTextCustomers.setBounds(10, 10, 350, 150);
    NameTextCustomers.setLineWrap(true);
    Customers.add(NameTextCustomers);

    JButton Exit = new JButton("Exit");
    Exit.setBounds(30,170,80,20);
    Exit.addActionListener(this);
    Exit.setBackground(Color.white);
    Customers.add(Exit);

    JButton AddCustomers = new JButton("Add Customer");
    AddCustomers.setBounds(130,170,120,20);
    AddCustomers.setBackground(Color.white);
    Customers.add(AddCustomers);

    JButton Refresh = new JButton("Refresh");
    Refresh.setBounds(260,170,80,20);
    Refresh.setBackground(Color.white);
    Customers.add(Refresh);

    ExistTextCustomers = new JTextArea();
    ExistTextCustomers.setBounds(10, 200, 350, 60);
    ExistTextCustomers.setLineWrap(true);
    Customers.add(ExistTextCustomers);

}
/*        CREATE CONTRACTORS        */

public JPanel createContractors(){ 
    final JTextArea contArea = new JTextArea(6, 30); 
    final JTextArea contMessage; 
    JButton addContractor = new JButton("Add Contractor"); 

    addContractor.setMnemonic('a'); 

JPanel contPanel = new JPanel(); 
contArea.setText("Select Add Contractor to add contractor. Select Refresh to refresh this pane."); 
contArea.setForeground(Color.orange); 
contArea.setLineWrap(true); 
contArea.setWrapStyleWord(true); 
JButton contRefButton = new JButton("Refresh"); 
contMessage = new JTextArea(2, 30); 
contMessage.setLineWrap(true); 
contMessage.setWrapStyleWord(true); 

addContractor.addActionListener(new ActionListener() 
{ 
public void actionPerformed(ActionEvent e) 
{ // action if button is used 
new Contractor("Contractor"); 
}// end actionPerformed()//end action performed 
}); // end performed action 

contPanel.add(contArea); 
contPanel.add(addContractor); 
contPanel.add(contRefButton); 
contPanel.add(contMessage); 
contRefButton.setMnemonic('R'); 

contRefButton.addActionListener(new ActionListener() 
{ 
public void actionPerformed(ActionEvent e) 
{ 
contMessage.setText(""); 
try
{ 
File contOpen = new File("contractor.txt"); 
FileReader contAreaIn = new FileReader(contOpen); 
contArea.read(contAreaIn, contOpen.toString()); 
contMessage.setText("The file exists and can be read from."); 
} 
catch (IOException e3) 
{ 
contMessage.setText("The file can't be read." + e3.getMessage()); 
} 
} 
}); 

return contPanel; 
} 

class Contractor extends JFrame 
{ 
private String[] states = { "AL", "AK", "AZ", "AR", "CA", "CO", "CT", "DE", 
"FL", "GA", "HI", "ID", "IL", "IN", "IA", "KS", "KY", "LA", "ME", 
"MD", "MA", "MI", "MN", "MS", "MO", "MT", "NE", "NV", "NH", "NJ", 
"NM", "NY", "NC", "ND", "OH", "OK", "OR", "PA", "RI", "SC", "SD", 
"TN", "TX", "UT", "VT", "VA", "WA", "WV", "WI", "WY" }; 
private JComboBox StateList = new JComboBox(states); 
private JTextField NameText = new JTextField(25); 
private JTextField AddressText = new JTextField(25); 
private JTextField CityText = new JTextField(25); 
private JTextField ZipText = new JTextField(9); 
private JTextField PhoneText = new JTextField(10); 
private JTextField PopMessageText = new JTextField(30); 
private static final long serialVersionUID = 1L; 

private AddContButtonHandler addContHandler = new AddContButtonHandler(); 

public Contractor(String who) 
{ 
popUpWindow(who); 
} 

public void popUpWindow(final String who) { 

final JFrame popWindow; 
popWindow = new JFrame(who); 
popWindow.setSize(425, 350); 
popWindow.setLocation(100, 100); 
popWindow.setVisible(true); 
setDefaultCloseOperation(EXIT_ON_CLOSE); 

Container A = new Container(); 

popWindow.add(A); 

A.setLayout(new FlowLayout()); 

JPanel Name = new JPanel(); 
JPanel Address = new JPanel(); 
JPanel City = new JPanel(); 
JPanel SZP = new JPanel(); 
JPanel File = new JPanel(); 
JPanel Message = new JPanel(); 

Name.add(new JLabel(who + "Name")); 
Name.add(NameText); 
Address.add(new JLabel("Address")); 
Address.add(AddressText); 
City.add(new JLabel("City")); 
City.add(CityText); 
SZP.add(new JLabel("State")); 
StateList.setSelectedIndex(0); 
SZP.add(StateList); 
SZP.add(new JLabel("Zip")); 
SZP.add(ZipText); 
SZP.add(new JLabel("Phone")); 
SZP.add(PhoneText); 
JButton addwho = new JButton("Add" + who); 
addwho.setMnemonic('A'); 
JButton close = new JButton("Close"); 
close.setMnemonic('C'); 
JButton deleteFile = new JButton("Delete File"); 
deleteFile.setMnemonic('D'); 
File.add(addwho); 
File.add(close); 
File.add(deleteFile); 
        PopMessageText.setEditable(false); 
        PopMessageText.setHorizontalAlignment(JTextField.CENTER); 

Message.add(PopMessageText); 
    A.add(Name); 
    A.add(Address); 
    A.add(City); 
    A.add(SZP); 
    A.add(File); 
    A.add(Message); 

deleteFile.setToolTipText("Delete File"); 
addwho.setToolTipText("Add "+ who); 
close.setToolTipText("Close"); 

if (who == "Contractor") 
    addwho.addActionListener(addContHandler); // registers listener 

close.addActionListener(new ActionListener() { 
public void actionPerformed(ActionEvent e) { 
    NameText.setText(""); 
    AddressText.setText(""); 
    CityText.setText(""); 
    ZipText.setText(""); 
    PhoneText.setText(""); 
    PopMessageText.setText(""); 
    popWindow.dispose(); 
                                          } 
                   }); 

deleteFile.addActionListener(new ActionListener() { 
public void actionPerformed(ActionEvent e) { 
PopMessageText.setText(""); 
if (who == "Contractor") { 
    File file = new File("Contractor.txt"); 
boolean contFileDeleted = file.delete(); 
if (contFileDeleted) { 
    PopMessageText 
    .setText("Contractor file deleted"); 
               } else { 
                       PopMessageText 
                       .setText("Error deleting file"); 
        } 
                         } 
                                        } 
                         }); 
}

class AddContButtonHandler implements ActionListener { 
public void actionPerformed(ActionEvent addContHandler) { 
int StateIndex; 
try { 
File file = new File("Contractor.txt"); 

boolean success = file.createNewFile(); 

if (success) { 
   PopMessageText 
    .setText("Contractor.txt file created file added"); 
                            } else if (file.canWrite()) { 
    PopMessageText 
    .setText("Writing info. to Contractor.txt, file added"); 
                            } else { 
                              PopMessageText.setText("Cannot create file: Contractor.txt"); 
       } 
try { 
FileWriter fileW = new FileWriter("Contractor.txt", true); 
fileW.write(NameText.getText()); 
fileW.write(","); 
fileW.write(AddressText.getText()); 
fileW.write(","); 
fileW.write(CityText.getText()); 
fileW.write(","); 
StateIndex = StateList.getSelectedIndex(); 
fileW.write(states[StateIndex]); 
fileW.write(","); 
fileW.write(ZipText.getText()); 
fileW.write(","); 
fileW.write(PhoneText.getText()); 
fileW.write("\r\n"); 
fileW.close(); 
PopMessageText.setText("Contractor has been added!"); 

FileReader fileR = new FileReader("Contractor.txt"); 
BufferedReader buffIn = new BufferedReader(fileR); 

buffIn.readLine(); 
buffIn.close(); 
   }

catch (IOException e1) { 
JOptionPane.showMessageDialog(null, e1.getMessage(), 
"Error", 2);
                       }
    NameText.setText(""); 
    AddressText.setText(""); 
    CityText.setText(""); 
    ZipText.setText(""); 
    PhoneText.setText(""); 
} catch (IOException e1) { 
                         }

}
}


public void actionPerformed(ActionEvent event){
JButton button = (JButton)event.getSource();
String buttonLabel = button.getText();
if ("Exit".equalsIgnoreCase(buttonLabel)){
Exit_pressed(); return;
    }
    if ("Calculate Pool Volume".equalsIgnoreCase(buttonLabel)){
        Calculate_VolumePool(); return;
    }
        if ("Calculate Hot Tub Volume".equalsIgnoreCase(buttonLabel)){
            Calculate_VolumeHotTub(); return;
    }
                                             }
private void Exit_pressed(){
System.exit(0);
                           }
private void Calculate_VolumePool(){
String lengthStringPool, widthStringPool, depthStringPool;
    int lengthPool=0;
    int widthPool=0;
    int depthPool=0;
lengthStringPool = lengthTextPool.getText();
widthStringPool = widthTextPool.getText();
depthStringPool = depthTextPool.getText();
if (lengthStringPool.length() < 1 || widthStringPool.length() < 1 || depthStringPool.length() < 1 ){
    volumeTextPool.setText("Enter All 3 Numbers"); return;
    }
        lengthPool = Integer.parseInt(lengthStringPool);
        widthPool = Integer.parseInt(widthStringPool);
        depthPool = Integer.parseInt(depthStringPool);
            if (lengthPool != 0 || widthPool != 0 || depthPool != 0 ){
                volumeTextPool.setText((lengthPool * widthPool * depthPool) + "");
    } else{
        volumeTextPool.setText("Enter All 3 Numbers"); return;
      }
                               }

private void Calculate_VolumeHotTub(){
    String lengthStringHotTub, widthStringHotTub, depthStringHotTub;
        int lengthHotTub=0;
        int widthHotTub=0;
        int depthHotTub=0;
    lengthStringHotTub = lengthTextHotTub.getText();
    widthStringHotTub = widthTextHotTub.getText();
    depthStringHotTub = depthTextHotTub.getText();
    if (lengthStringHotTub.length() < 1 || widthStringHotTub.length() < 1 || depthStringHotTub.length() < 1 ){
        volumeTextHotTub.setText("Enter All 3 Numbers"); return;
        }
            lengthHotTub = Integer.parseInt(lengthStringHotTub);
            widthHotTub = Integer.parseInt(widthStringHotTub);
            depthHotTub = Integer.parseInt(depthStringHotTub);
                if (lengthHotTub != 0 || widthHotTub != 0 || depthHotTub != 0 ){
                    volumeTextHotTub.setText((lengthHotTub * widthHotTub * depthHotTub) + "");
        } else{
            volumeTextHotTub.setText("Enter All 3 Numbers"); return;
          }
                                   }
public void main(String[] args){
JFrame frame = new test();
frame.setSize(380, 350);
frame.setVisible(true);
}
}
public void actionPerformed(ActionEvent e) {

}
}
  • 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-20T17:07:11+00:00Added an answer on May 20, 2026 at 5:07 pm

    Move your main method to class “test” (from Contractor) and change declaration to static. Btw. regarding to java naming conventions class name should start with capital letter

    Change your 469 line:

    public void main(String[] args) // bad
    

    To:

    public static void main(String[] args) // good
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

SETUP: Imagine I have a pretty good size program, and #defines and various means
I have a pretty basic database. I need to drop a good size users
I have pretty good skills in PHP , Mysql and Javascript for a junior
I have a pretty good understanding of Javascript, except that I can't figure out
I have a pretty good idea how to implement fulltext search with MySQL. I
See my snippet below. I have a pretty good idea what the error is,
i am pretty good in android but have not developed any games yet, and
I have a CMS with a WYSIWYG editor which produces pretty good xhtml. Based
I have pretty much finished my first working Symbian application, but in my hastened
I'm considering developing a medium-size project for a client in IronPython. It's a pretty

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.