Results 1 to 2 of 2
Thread: new to forums but not java
- 02-12-2008, 09:36 PM #1
Member
- Join Date
- Jan 2008
- Posts
- 22
- Rep Power
- 0
new to forums but not java
Hey guys I do not not know to text wrap my code so if someone could tell me for the future id appreciate it... I am finishing this program and I want the last line of output to do a setEditable and not sure i know how to do it...I was sick in class when were doing it but judging from what I have found online it is something like:
outputText.setEditable(false); or something like that I mean I think I am close just can;t get the final piece but here is my code and let me know what anyone thinks Id really appreciate it.
/*
Programmer: Bryan Kruep
Date: February 12, 2008
Filename: TicketApplet.java
Purpose: This program calculates the body mass index based on a person's height and weight in an applet
*/
//package to import
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class TicketApplet extends Applet implements ActionListener
{
//Declare variables
int box_seats, sideline_seats, premium_seats, general_admission_seats, box_seats_total, sideline_seats_total, premium_seats_total, general_admission_seats_total, total_sales;
//Construct Components
Label box_seatsLabel = new Label ("Enter the number of Box Seats sold: ");
TextField box_seatsField = new TextField(10);
Label sideline_seatsLabel = new Label ("Enter the number of Sideline Seats sold: ");
TextField sideline_seatsField = new TextField(10);
Label premium_seatsLabel = new Label ("Enter the number of Premium Seats sold: ");
TextField premium_seatsField = new TextField(10);
Label general_admission_seatsLabel = new Label ("Enter the number of General Admission Seats sold: ");
TextField general_admission_seatsField = new TextField(10);
Button calcButton = new Button("Calculate");
TextField outputField = new TextField ("Press the calculate button to display the total here. ");
// Make the textfield non-editable
public void init()
{//change the color for the applet window
setBackground(Color.green);
setForeground(Color.black);
add(box_seatsLabel);
add(box_seatsField);
box_seatsField.setBackground(Color.blue);
box_seatsField.setForeground(Color.white);
add(sideline_seatsLabel);
add(sideline_seatsField);
sideline_seatsField.setBackground(Color.blue);
sideline_seatsField.setForeground(Color.white);
add(premium_seatsLabel);
add(premium_seatsField);
premium_seatsField.setBackground(Color.blue);
premium_seatsField.setForeground(Color.white);
add(general_admission_seatsLabel);
add(general_admission_seatsField);
general_admission_seatsField.setBackground(Color.b lue);
general_admission_seatsField.setForeground(Color.w hite);
add(calcButton);
calcButton.setForeground(Color.red);
calcButton.addActionListener(this);
add(outputField);
}//end init
public void actionPerformed(ActionEvent e)
{
//get user input and convert to Integer
box_seats = Integer.parseInt(box_seatsField.getText());
sideline_seats = Integer.parseInt(sideline_seatsField.getText());
premium_seats = Integer.parseInt(premium_seatsField.getText());
general_admission_seats = Integer.parseInt(general_admission_seatsField.getT ext());
//perform calculations
box_seats_total = 250 * box_seats;
sideline_seats_total = 100 * sideline_seats;
premium_seats_total = 50 * premium_seats;
general_admission_seats_total = 25 * general_admission_seats;
total_sales = box_seats_total + sideline_seats_total + premium_seats_total + general_admission_seats_total;
//display output
outputField.setText("Total Sales = " + Math.round(total_sales) + ".");
} //end actionPerformed
} //end of file
- 02-13-2008, 06:11 AM #2
Member
- Join Date
- Jan 2008
- Posts
- 22
- Rep Power
- 0
Similar Threads
-
Hi java-forums
By surot in forum IntroductionsReplies: 2Last Post: 04-03-2008, 04:41 PM -
Hello Java Forums
By oasis in forum IntroductionsReplies: 2Last Post: 03-27-2008, 05:09 AM -
Hi All...New to Java Forums...
By veerusvpp in forum IntroductionsReplies: 2Last Post: 02-18-2008, 09:26 AM -
new to java new to forums
By mctruck in forum IntroductionsReplies: 5Last Post: 02-16-2008, 03:35 AM -
Java Forums
By kks_krishna in forum Reviews / AdvertisingReplies: 0Last Post: 01-27-2008, 06:04 AM
Bookmarks