I am creating an program that allows a user to register for a conference. When I press the "Run" button in Netbeans I get a message saying "Build Successful," but the program does not show up on the screen. What am I missing in my code? I am new to Java so I could use all the help I can get. Thanks!

package ism3230_conference;
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.text.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
import java.util.Scanner;

public class ISM3230_Conference extends JFrame implements ActionListener, KeyListener
    {

    public static void main(String[] args) {
    }   
    // Constants for storing Prices
double registration = 895.00,
                         studentreg = 495.00,
                         dinner = 30.00,
                         ecommerce = 295.00,
                         future = 295.00,
                         java = 395.00,
                         security = 395.00;

    //Graphical components
    Panel topPanel,
          centerPanel,
          centerRegistrationPanel,
          centerDinnerPanel,
          centerWorkshopsPanel,
          centerPricePanel,
          bottomPanel;

    Label titleLabel,
          registrationLabel,
          dinnerLabel,
          workshopLabel,
          priceLabel,
          priceDisplayLabel;

    Button totalButton;

    TextField conferenceText,
              priceText;

    ButtonGroup sizeBGroup;

    JRadioButton nstudentJRadio,
                 studentJRadio;

    JCheckBox dinnerJCheck,
              ecommerceJCheck,
              futureJCheck,
              javaJCheck,
              securityJCheck;

    /**
     * Initialize variable and components
     */
    public void init() {

        // Setting applet
        setBackground(new Color(205,205,205));
        setLayout(new BorderLayout(0,0));

        // Initializing Panels
        topPanel = new Panel();
        topPanel.setBackground(new Color(0,118,157));
        topPanel.setLayout(new FlowLayout());

        centerPanel = new Panel();

        centerRegistrationPanel = new Panel();
        centerRegistrationPanel.setLayout(new FlowLayout());

        centerDinnerPanel = new Panel();
        centerDinnerPanel.setLayout(new FlowLayout());

        centerWorkshopsPanel = new Panel();
        centerWorkshopsPanel.setLayout(new GridLayout(2,3,0,0));

        centerPricePanel = new Panel();
        centerPricePanel.setLayout(new FlowLayout());

        bottomPanel = new Panel();
        bottomPanel.setLayout(new FlowLayout());

        // Initializing Labels
        titleLabel = new Label("Conference Registration 2012");
        titleLabel.setBackground(new Color(0,118,157));
        titleLabel.setForeground(new Color(255,255,255));
        titleLabel.setFont(new Font("Arial",Font.BOLD,50));

        registrationLabel = new Label("Are you a Student or Non-Student? ");
        registrationLabel.setForeground(new Color(0,0,205));
        registrationLabel.setFont(new Font("Arial",Font.BOLD,14));

        dinnerLabel = new Label("Optional Dinner and Keynote Speech? ");
        dinnerLabel.setForeground(new Color(0,0,0));
        dinnerLabel.setFont(new Font("Arial",Font.BOLD,14));

        workshopLabel = new Label("Select any optional Preconference Workshops you would like to attend :");
        workshopLabel.setForeground(new Color(0,0,205));
        workshopLabel.setFont(new Font("Arial",Font.BOLD,14));

        priceLabel = new Label("Total price of your registration : ");
        priceLabel.setForeground(new Color(200,0,0));
        priceLabel.setFont(new Font("Arial",Font.BOLD,14));

        priceDisplayLabel = new Label("$0.00       ");
        priceDisplayLabel.setForeground(new Color(235,0,0));
        priceDisplayLabel.setFont(new Font("Arial",Font.BOLD,34));

        // Initializing Textfields
        conferenceText = new TextField("0",1);
        conferenceText.setFont(new Font("Arial",Font.BOLD,14));

        priceText = new TextField("0",1);
        priceText.setFont(new Font("Arial",Font.BOLD,14));

        // Initializing JRadio buttons
        studentJRadio = new JRadioButton("Student", true);
        nstudentJRadio = new JRadioButton("Non-Student", false);


        // Grouping radio buttons
        sizeBGroup = new ButtonGroup();
        sizeBGroup.add(studentJRadio);
        sizeBGroup.add(nstudentJRadio);

        // Initializing JCheckboxes
        dinnerJCheck = new JCheckBox("Dinner and Keynote Speech",false);
        ecommerceJCheck = new JCheckBox("Introduction to E-commerce Workshop",false);
        futureJCheck = new JCheckBox("The Future of the Web Workshop",false);
        javaJCheck = new JCheckBox("Advanced Java Programming Workshop",false);
        securityJCheck = new JCheckBox("Network Security Workshop",false);

        // Initializing Buttons
        totalButton = new Button("Registration Total");
        totalButton.setFont(new Font("Arial",Font.BOLD,16));

        // Registering listeners to components
        studentJRadio.addActionListener(this);
        nstudentJRadio.addActionListener(this);

        dinnerJCheck.addActionListener(this);
        ecommerceJCheck.addActionListener(this);
        futureJCheck.addActionListener(this);
        javaJCheck.addActionListener(this);
        securityJCheck.addActionListener(this);

        conferenceText.addKeyListener(this);

        totalButton.addActionListener(this);
    }

    public void start() {

        // Top Panel
        topPanel.add(titleLabel);

        // Nested Center Panels
        centerRegistrationPanel.add(registrationLabel);
        centerRegistrationPanel.add(conferenceText);

        centerRegistrationPanel.add(studentJRadio);
        centerRegistrationPanel.add(nstudentJRadio);

        centerDinnerPanel.add(dinnerJCheck);
        centerWorkshopsPanel.add(ecommerceJCheck);
        centerWorkshopsPanel.add(futureJCheck);
        centerWorkshopsPanel.add(javaJCheck);
        centerWorkshopsPanel.add(securityJCheck);

        centerPricePanel.add(priceLabel);
        centerPricePanel.add(priceDisplayLabel);

        // Center Panel
        centerPanel.add(registrationLabel);
        centerPanel.add(centerRegistrationPanel);
        centerPanel.add(dinnerLabel);
        centerPanel.add(centerDinnerPanel);
        centerPanel.add(workshopLabel);
        centerPanel.add(centerWorkshopsPanel);
        centerPanel.add(centerPricePanel);

        // Bottom Panel
        bottomPanel.add(totalButton);

        // Main Window
        add(topPanel, BorderLayout.NORTH);
        add(centerPanel, BorderLayout.CENTER);
        add(bottomPanel, BorderLayout.SOUTH);

        conferenceText.selectAll();
    }

    // Unused interface methods
    public void keyTyped(KeyEvent e) { }
    public void keyPressed(KeyEvent e) { }

    /**
     * Perform validation check on user text input
     */
    public void keyReleased(KeyEvent e) {

        // Trap all non-valid numbers
        try {
            Integer.parseInt(conferenceText.getText());
        }
        catch (NumberFormatException fe) {
            conferenceText.setText("0");
        }

        refreshPrice();
    }  

    /**
     * Traps user input
     */
    public void actionPerformed(ActionEvent e) {

        // If order now button is pressed
        if (e.getSource() == totalButton) {

            JOptionPane.showMessageDialog(this,
                "Your total registration fees are  " + 
                priceDisplayLabel.getText() + " ." +
                "\n\nWe look forward to seeing you at this year's conference !" +
                "\nThank you for registering !",
                "Registration Confirmed",
                JOptionPane.INFORMATION_MESSAGE);
        }

        refreshPrice();
    }

    /**
     * Method to calculate and refresh the price display
     */
    private void refreshPrice() {

        // Local variables used to accumulate total price
        double total = 0;
        int regTotal = Integer.parseInt(conferenceText.getText());

        // Initializing Number Format      
        NumberFormat numberForm = NumberFormat.getNumberInstance();
        DecimalFormat moneyForm = (DecimalFormat)numberForm;
        moneyForm.applyPattern("0.00");

        // Registration prices
        if (studentJRadio.isSelected()) {
            total+= studentreg;
        }

        if (nstudentJRadio.isSelected()) {
            total+= registration;
        }

        // Options prices
        if (dinnerJCheck.isSelected()) {
            total+= dinner;
        }

        if (ecommerceJCheck.isSelected()) {
            total+= ecommerce;
        }

        if (futureJCheck.isSelected()) {
            total+= future;
        }

        if (javaJCheck.isSelected()) {
            total+= java;
        }

        if (securityJCheck.isSelected()) {
            total+= security;
        }

        priceDisplayLabel.setText("$"+moneyForm.format(total));
    }
}

When the java command executes a class,it calls the class's main() method which is responsibe for starting the execution of the rest of the class. You main() metjhod is empty. You need to add some code to it that will call the methods to create the GUI and start things executing.

There are many thing you need to study before trying to write a GUI program. Take a look at this tutorial:
Click Here

Edited 4 Years Ago by NormR1

Am I supposed to use something like this in the main method:

init;
start;

That gives me an error. I read over the site you posted, but am still lost.

This article has been dead for over six months. Start a new discussion instead.