Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 02-12-2008, 11:36 PM
Member
 
Join Date: Jan 2008
Posts: 18
jimJohnson is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 02-13-2008, 08:11 AM
Member
 
Join Date: Jan 2008
Posts: 18
jimJohnson is on a distinguished road
can anyone help me its just a simple problem I missed class for
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hi java-forums surot Introductions 2 04-03-2008 06:41 PM
Hello Java Forums oasis Introductions 2 03-27-2008 07:09 AM
Hi All...New to Java Forums... veerusvpp Introductions 2 02-18-2008 11:26 AM
new to java new to forums mctruck Introductions 5 02-16-2008 05:35 AM
Java Forums kks_krishna Reviews / Advertising 0 01-27-2008 08:04 AM


All times are GMT +3. The time now is 04:43 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org