Hi everyone. I am trying to make a batting average calculator, but i am pretty new to java.
I want to make it look like this: http://www.kll.org/batting-average.htm
All i have right now is JOptionPanes, and it works, but it doesnt look very nice.
So i know i need to put it in a JFrame and use JTextArea and all of that, but everytime i try to add a text box i cannot give it a simple boundry like the one shown in the link.
So can anyone help?
Here is my project so far

import javax.swing.*;
import java.awt.*;
import java.awt.SystemColor;
public class battingaverage {
	public static void main(String[] args) {
		double average;
		double OBP;
		setTitle("Batting Average" ); 
		JOptionPane.showMessageDialog(null, "Welcome to the Batting Average and OBP Calculator");
		String inputHits = JOptionPane.showInputDialog("Enter the amount of hits:");
			if (inputHits == null)
			    double hits = Double.parseDouble(inputHits);
		String inputTotalPA = JOptionPane.showInputDialog("Enter the Total amount of Plate Appearances:");
			if (inputTotalPA == null)
			 	double PA = Double.parseDouble(inputTotalPA);	
		String inputWalks = JOptionPane.showInputDialog("Enter amount of Walks:");
			if (inputWalks == null)
				double Walks = Double.parseDouble(inputWalks);	
		String inputSac= JOptionPane.showInputDialog("Enter the amount of sacrifices:");
			if (inputSac == null)
				double Sac = Double.parseDouble(inputSac);	    
		String inputHBP = JOptionPane.showInputDialog("Enter amount of Hit by Pitches:");
			if (inputHBP == null)
			    double HBP = Double.parseDouble(inputTotalPA);    
			    average = hits / PA - Sac - Walks - HBP;
			    OBP = hits + Walks + Sac + HBP / PA;
			    if (hits > PA){
			    JOptionPane.showMessageDialog(null, "The Total Amount of Hits cannot be m ore than the total number of At Bats.");
			    }else if (PA > hits){
			    average = (hits / PA);
			    JOptionPane.showMessageDialog(null, "Your batting " +
			    "average is " + average + ".");
			    OBP = (hits + Walks + HBP / PA);
			    JOptionPane.showMessageDialog(null, "Your On Base " +
					    "% is " + OBP + ".");		
	private static void setSize(int i, int j) {
		// TODO Auto-generated method stub		
	private static void setTitle(String string) {
		// TODO Auto-generated method stub		
5 Years
Discussion Span
Last Post by NormR1

Do you have the code for the GUI that is giving you the problems?
Post a small code that will compile and execute to demonstrate the problem

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.