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" ); 
		setSize(40,70);
		JOptionPane.showMessageDialog(null, "Welcome to the Batting Average and OBP Calculator");
		String inputHits = JOptionPane.showInputDialog("Enter the amount of hits:");
			if (inputHits == null)
			    return;
			    double hits = Double.parseDouble(inputHits);
		String inputTotalPA = JOptionPane.showInputDialog("Enter the Total amount of Plate Appearances:");
			if (inputTotalPA == null)
				return;
			 	double PA = Double.parseDouble(inputTotalPA);	
		String inputWalks = JOptionPane.showInputDialog("Enter amount of Walks:");
			if (inputWalks == null)
				return;
				double Walks = Double.parseDouble(inputWalks);	
		String inputSac= JOptionPane.showInputDialog("Enter the amount of sacrifices:");
			if (inputSac == null)
				return;
				double Sac = Double.parseDouble(inputSac);	    
		String inputHBP = JOptionPane.showInputDialog("Enter amount of Hit by Pitches:");
			if (inputHBP == null)
			    return;
			    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		
}
}

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.