Beginner Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsOtherBeginner Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old April 26th, 2002, 02:50 AM
mullinm mullinm is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2002
Location: zim
Posts: 1 mullinm User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Angry Java problem - Cant resolve symbol(JTextFields)??

hi all,

below is my code, which, as you can see, opens a window with two text boxes (which contain numbers) and two buttons. the first "Submit" button allows the user confirm that he is ready to update. When he clicks the "Submit" button a new instance of the stockPrice class is created

The second button, "Increase" activates a percentage increase for the numers. THis percentage increase is input using an input dialog box... ... the appropriate methods of the stockPrice class are called and the updated prices are displayed in the appropriate text boxes.

error messages i just dont understand,,, especially with the JTextFields


CODE:


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

class stockPrice
{
private String stockCode;
private double costPrice;
private double sellingPrice;
double grossProfit, rate, dealerPrice;

public stockPrice(String sCode, double cPrice, double sPrice)
{
stockCode = sCode;
costPrice = cPrice;
sellingPrice = sPrice;
}
public stockPrice(String sCode, double cPrice)
{
stockCode = sCode;
costPrice = cPrice;
sellingPrice = (0.30 * costPrice) + costPrice;
}

public String getStockCode()
{
return stockCode;
}
public double getCostPrice()
{
return costPrice;
}
public double getSellingPrice()
{
return sellingPrice;
}
public void setCostPrice(double cPrice)
{
costPrice = cPrice;
}
public void setSellingPrice(double sPrice)
{
sellingPrice = sPrice;
}
public void incPrices(double rate)
{
costPrice = costPrice + (rate * costPrice);
sellingPrice = sellingPrice + (rate * sellingPrice);
}
public double grossProfit()
{
grossProfit = sellingPrice - costPrice;
return grossProfit;
}
}

public class Ex17_A
{
public static void main(String[] args)
{
JFrame Exercise17_B = new EgWindow();
Exercise17_B.show();
}
}

class EgWindow extends JFrame implements ActionListener
{
double rate, costPrice, sellingPrice;
String stockCode;
stockPrice testStockPrice = new stockPrice("PC", 100, 120);
JTextField cPriceTF = new JTextField(testStockPrice.getCostPrice(),10);
JTextField sPriceTF = new JTextField(testStockPrice.getSellingPrice(),10);

public EgWindow()
{
setTitle("Exercise 17_B");
setSize(500,500);

Container Contents=getContentPane();

JLabel Label1 = new JLabel("Stock Code: ");
JLabel Label2 = new JLabel("Cost Price: ");

JPanel InfoPanel = new JPanel();
InfoPanel.add(Label1);
InfoPanel.add(cPriceTF);
InfoPanel.add(Label2);
InfoPanel.add(sPriceTF);

JButton PIButton = new JButton("Increase");
PIButton.addActionListener(this);
JButton SButton = new JButton("Submit");
SButton.addActionListener(this);
JPanel BPanel = new JPanel();
BPanel.add(SButton);
BPanel.add(PIButton);

Contents.add(InfoPanel,"North");
Contents.add(BPanel,"Center");

addWindowListener(new WindowAdapter()
{public void windowClosing(WindowEvent e)
{System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e)
{
if (e.getActionCommand().equals("Submit")) actSubmit();
else if (e.getActionCommand().equals("Increase")) actIncrease();
}
public void actSubmit()
{
testStockPrice = new stockPrice(cPriceTF.getText(), sPriceTF.getText());
}
public void actIncrease()
{
rate=Double.parseDouble(JOptionPane.showInputDialog("Please enter the rate:"));
}
}

Reply With Quote
Reply

Viewing: Dev Shed ForumsOtherBeginner Programming > Java problem - Cant resolve symbol(JTextFields)??


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway