Home Answers Viewqa Java-Beginners Till Slip Program Error Free - No Main Method

 
 


Sahil Muniram
Till Slip Program Error Free - No Main Method
0 Answer(s)      3 months and 2 days ago
Posted in : Java Beginners

Hi there i am a java begineer programmer i recently started developing programes on NetBeans using the GUI as it is more reliable and efficent - the current program that i am working on is a GUI interface for a Till Slip called TillSslipUI. I have meet the recquirements for the variable names and the necessary code that is needed to be inputed as the rest is generated but the problem that i have found out that the program recquires a main() method in order to be runned - here is the following code:

import java.util.*;

import java.text.*;

public class TillSlipUI extends javax.swing.JPanel {

double num1;
double num2;
double num3;
double totalItems;
double vat;
double finTotal;
double amt;
double change;

DecimalFormat d = new DecimalFormat ("0.00");

/**
 * Creates new form TillSlipUI
 */
public TillSlipUI() {
    initComponents();
}

/**
 * This method is called from within the constructor to initialize the form.
 * WARNING: Do NOT modify this code. The content of this method is always
 * regenerated by the Form Editor.
 */
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">                          
private void initComponents() {

    jPanel1 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jLabel2 = new javax.swing.JLabel();
    jLabel3 = new javax.swing.JLabel();
    totalButton = new javax.swing.JButton();
    vatButton = new javax.swing.JButton();
    finalTotButton = new javax.swing.JButton();
    jLabel4 = new javax.swing.JLabel();
    changeButton = new javax.swing.JButton();
    item1TxtFld = new javax.swing.JTextField();
    item2TxtFld = new javax.swing.JTextField();
    item3TxtFld = new javax.swing.JTextField();
    totalTxtFld = new javax.swing.JTextField();
    vatTxtFld = new javax.swing.JTextField();
    finalTotalTxtFld = new javax.swing.JTextField();
    amountTxtFld = new javax.swing.JTextField();
    changeTxtFld = new javax.swing.JTextField();

    jPanel1.setBackground(new java.awt.Color(153, 255, 255));
    jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Till Slip", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Brush Script MT", 1, 36), new java.awt.Color(0, 204, 0))); // NOI18N

    jLabel1.setText("Price of Item1");

    jLabel2.setText("Price of Item2");

    jLabel3.setText("Price of Item3");

    totalButton.setText("Total");
    totalButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            totalButtonActionPerformed(evt);
        }
    });

    vatButton.setText("VAT");
    vatButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            vatButtonActionPerformed(evt);
        }
    });

    finalTotButton.setText("Final Total");
    finalTotButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            finalTotButtonActionPerformed(evt);
        }
    });

    jLabel4.setText("Amount Tendered");

    changeButton.setText("Change");
    changeButton.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(java.awt.event.ActionEvent evt) {
            changeButtonActionPerformed(evt);
        }
    });

    javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
    jPanel1.setLayout(jPanel1Layout);
    jPanel1Layout.setHorizontalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addContainerGap()
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(vatButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(totalButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(finalTotButton, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGap(0, 0, Short.MAX_VALUE))
                .addComponent(changeButton, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, 88, Short.MAX_VALUE)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(item1TxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addGap(31, 31, 31)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(finalTotalTxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(amountTxtFld)
                            .addComponent(changeTxtFld, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE))
                        .addComponent(vatTxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(totalTxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(item3TxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(item2TxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 200, javax.swing.GroupLayout.PREFERRED_SIZE))))
            .addGap(425, 425, 425))
    );
    jPanel1Layout.setVerticalGroup(
        jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(jPanel1Layout.createSequentialGroup()
            .addGap(20, 20, 20)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(item1TxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 35, Short.MAX_VALUE)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(item2TxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(30, 30, 30)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(item3TxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(45, 45, 45)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(totalButton)
                .addComponent(totalTxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(33, 33, 33)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(vatButton)
                .addComponent(vatTxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(40, 40, 40)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(finalTotButton)
                .addComponent(finalTotalTxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(26, 26, 26)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addComponent(amountTxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(33, 33, 33)
            .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                .addComponent(changeButton)
                .addComponent(changeTxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE))
            .addGap(23, 23, 23))
    );

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addContainerGap())
    );
    layout.setVerticalGroup(
        layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
        .addGroup(layout.createSequentialGroup()
            .addContainerGap()
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addContainerGap())
    );
}// </editor-fold>                        

private void totalButtonActionPerformed(java.awt.event.ActionEvent evt) {                                            
num1 = Double.parseDouble(item1TxtFld.getText()); 
num2 = Double.parseDouble(item2TxtFld.getText());
num3 = Double.parseDouble(item3TxtFld.getText());
totalItems = num1 + num2 + num3;
totalTxtFld.setText(""+d.format(totalItems));
item1TxtFld.setText("");
item2TxtFld.setText("");
item3TxtFld.setText("");
amountTxtFld.setText("");
}                                           

private void vatButtonActionPerformed(java.awt.event.ActionEvent evt) {                                          
    vat = totalItems*14/100;
    vatTxtFld.setText(""+d.format(vat));
    vatTxtFld.setText("");
}                                         

private void finalTotButtonActionPerformed(java.awt.event.ActionEvent evt) {                                               
  finTotal = totalItems + vat;
  finalTotalTxtFld.setText(""+d.format(finTotal));
}                                              

private void changeButtonActionPerformed(java.awt.event.ActionEvent evt) {                                             
    amt = Double.parseDouble(amountTxtFld.getText());
    change = amt - finTotal;
    changeTxtFld.setText(""+d.format(change));
}                                            

// Variables declaration - do not modify                     
private javax.swing.JTextField amountTxtFld;
private javax.swing.JButton changeButton;
private javax.swing.JTextField changeTxtFld;
private javax.swing.JButton finalTotButton;
private javax.swing.JTextField finalTotalTxtFld;
private javax.swing.JTextField item1TxtFld;
private javax.swing.JTextField item2TxtFld;
private javax.swing.JTextField item3TxtFld;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JPanel jPanel1;
private javax.swing.JButton totalButton;
private javax.swing.JTextField totalTxtFld;
private javax.swing.JButton vatButton;
private javax.swing.JTextField vatTxtFld;
// End of variables declaration

}

I would really appreciate it if someone would help me with the developing of a main method for this program. Thank You.

View Answers









Related Pages:
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... on is a GUI interface for a Till Slip called TillSslipUI. I have meet
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... on is a GUI interface for a Till Slip called TillSslipUI. I have meet
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... on is a GUI interface for a Till Slip called TillSslipUI. I have meet
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... on is a GUI interface for a Till Slip called TillSslipUI. I have meet
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... on is a GUI interface for a Till Slip called TillSslipUI. I have meet
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code... on is a GUI interface for a Till Slip called TillSslipUI. I have meet
main method
can not make multiple main with in the same class program fails to compile. Compiler gives error that the main method is already defined in the class...main method  hello, Can I make multiple main methods in the same
main method
main method  What is the argument type of a program's main() method
MAin error
MAin error  Error while running hello program in another dir rather in bin. path is already set. java -version jdk1.6.0_24 no error while compilation but @ d tym of runnin error in main class is generated Exception in thread
main() method
main() method  Can we define two main() methods having same parameter but with different return type in a program
How to eliminate error," Could not find the main class: filecopy.FileCopy. Program will exit." ?
How to eliminate error," Could not find the main class: filecopy.FileCopy. Program will exit." ?  run: java.lang.NoClassDefFoundError: filecopy... class: filecopy.FileCopy. Program will exit. Exception in thread "main" Java
Can a main method be overloaded?
Can a main method be overloaded?   Hi, Can a main method be overloaded? thanks,   Hi, Yes, In Java program we could having multiple number of main() methods with different Signature and implementation in the class
When is java main method called?
When is java main method called?  When is java main method called? Please explain the main method in Java with the help of code.   In a java class, main(..) method is the first method called by java environment when
What is the return type of the main method?
What is the return type of the main method?  hi, What is the return type of the main method? thanks   Hi, In the java programming the Main() method doesn't return anything hence declared void. In Java, you need
main method
main method  Why is the java main method static
main method
in paranthesis denote?   Hi Friend, public-It indicates that the main() method can be called by any object. static-It indicates that the main() method is a class method. void- It indicates that the main() method has no return value
What is the first argument of the String array in main() method?
What is the first argument of the String array in main() method?  Hi, What is the first argument of the String array in main() method? Thanks... of the String array in main() method
Display free disk space
Description: This example will demonstrate how to get the free disk space for your drive. The getFreeSpace method introduced in the Jdk 6 and found in java.io.File. This method get the free disk space in the bytes. Code
exception in thread main while running servlet
exception in thread main while running servlet  I got exception in thread main no such method error while running servlet. I have added servlet.api.jar file in classpath.my classpath is C:\Program Files\Apache Software Foundation
Main method overloading
Main method overloading  Can we overload main()method
main() syntax - Java Beginners
main() syntax  Hi, I would like to know the complete structure of the main() in jdk1.5 with sample program. Regards, UsmanAli Shaik,  ...] [import statements] [class declaration] [main() method] For Example: package
What is the arguement of main method?
What is the arguement of main method?  hi, What is the arguement of main method? thanks,   Hi, For main() method accepts only an array of String object as arguement. For moe details on http://www.roseindia.net/java
error
error  whats the error.............. import java.util.Scanner; public class g { public static void main(String[] args) { Scanner s=new Scanner...; hi friend, you are defining the add and sub method at the wrong place
error
"+it); } } this is my program i am getting an error saying cannot find symbol class string... inside the method 'accept()'. Here is your modified code: import java.util.
error
error  import java.io.*; public class sereies { public static void main(String args[])throws IOException { BufferedReader keyin=new... is"+sum); } } this is my program i need to print the series (1+2/12)+(1+2
Why we should use string args[] in main method in java?
Why we should use string args[] in main method in java?  we use only string in the main method not any other one.. specify the reason... and tell me... line from the command prompt   In the main method,the String array args
Can I have multiple main() methods in the same class?
use multiple main() method within the same class. If we do this then the program fails to compile. The Compiler gives error that the main method is already defined in the class.. For more details related to use of multiple main() method
A programm for error free transmission of data using UDP in java
is to create applications for error-free transmission of data (transmitter and receiver). The program will use UDP for transmission. Error-free transmission...A programm for error free transmission of data using UDP in java  Hi
What is Public static void main
the rules otherwise your program will not run. Signature of main method in java... are the variation of main method. public static void main(String[] args) public...[]) //this is most classic signature of main method. Remember the varargs version of java
Method overloading in java program
Method overloading in java program  How can we use method overloading in java program?   Method overloading:?In method overloading methods... are passing two char type parameters. In main method we are calling the all three
Java Program Complication error - Java Beginners
Java Program Complication error  Hi there, I have this program I had to write called ThreeArrayLists.java, but I keep getting this error "use of unchecked or unsafe operations" This is the criteria for the program
java main program
java main program  how to write a main program for the following code public class JaroWinkler { private String compOne; private String compTwo; private String theMatchA = ""; private String theMatchB
What if the main() method is declared as private?
What if the main() method is declared as private?  Hi, What if the main() method is declared as private? Thanks   Hi, I have found some reference site for java programming coding for Main() method is declared
Can a main method be declared final?
Can a main method be declared final?   Hi, Can a main method be declared final? Thanks   Hi, Yes we can. The final method can... be override in a subclass. for more about main method be declared final in Java
Why is the main method declared static?
Why is the main method declared static?  Hi, Why is the main method declared static? thanks   Hi, When we declare main() method in any Java class always has the same signature, and we declare public static void main
java Method Error - Java Beginners
java Method Error  class mathoperation { static int add(int...-n); } } class mathdemo { public static void main(String args... Errors ,Please Give Me solution of Following Error G:\>javac mathdemo.java
Java get Free Memory
Java get Free Memory       In this section, we are going to obtain the free memory. In order to get the memory left of being allocated, the method getruntime() returns
Java error stream
the execution of a program. The execution of program display an output and error... stream, For this we have a class name'errorstreamexample'.Inside the main method... Java error stream      
error - JDBC
error  i wrote the program using dbms type 4 driver.it is comipled...) at java.security.AccessController.doPrivileged(Native Method...) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName
Java error unreachable statement
have a class name' unreachable error', Inside the main method  we have...) To resolve this error remove continue; from this program Download... Java error unreachable statement   
program
program  )Create a class called College with a method displayDetails which should print "IIT Mumbai" in console. Inside the main method instantiate the College class and invoke the method.   hi dhivya, Here I am giving
what error in this program plese correct it
what error in this program plese correct it  import java.io.*; class y { public static void main (String args[]) { Data inputStream dis = new Data inputstream(System.in); float l,b,a; Systyem.out.println("enter the lengh"); l
JAVA what is different between static block and public static void main(String a[]) method
void main(String a[]) method,we execute method without main method(by static... are meant to be run once the corresponding class is loaded. The main() method...() method for various reasons, it coexists with main() method which is static too
JAVA Method Wait
JAVA Method Wait       The Wait method in Java hold the thread to release the lock till... the main method we instantiate a wait method class.  wait.start
sleep method in thread java program
sleep method in thread java program  How can we use sleep method in thread ?   public class test { public static void main(String... example ,we have used sleep method. we are passing some interval to the sleep
main function defnition in class - Java Beginners
and will subsequently invoke all the other methods required by your program. The main method... of a main function   Hi friend, The main method is similar to the main... because we can use that method(main) not only in the current directory
Exception Handling-Error Messages in Program
Exception Handling-Error Messages in Program  Hi Friend, I am having... with this. Here is the code with the error messages as Follows: import... String getGrade(){ return grade; } public static void main(String args
Java file get free space
Java file get free space In this section, you will learn how to find the free... a disc of our file system. Then we have called the method getFreeSpace() of class File through the object of File class. getFreeSpace() method- This method
I/O Program output error
I/O Program output error  Hello All, I am working on a program... of the program in that it reads the text file and analyzes it, however I need it to take... java.util.TreeSet; /** * * @author zubeda.a.hemani */ //This program reads
Main function parameter in C language - Ajax
Main function parameter in C language  Please let me know how this Main(int argc,char*argv[]) works and detailed example on their roles in command...; Hi Friend, int main(int argc, char **argv) The main function serves

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.