Java Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesJava Help

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, 03:02 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
Unhappy cannot resolve symbol JTextField

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

please help anyone.... no matter what i do i just cant get it right

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
  #2  
Old April 26th, 2002, 08:58 AM
aabha aabha is offline
Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2002
Location: India
Posts: 7 aabha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via Yahoo to aabha
hi,
the error was due to the wrong value passed in the constructor...u shud pass a string....

try replacin this code in the EgWindow class...

JTextField cPriceTF = new JTextField(String.valudOf(testStockPrice.getCostPrice()),10);
JTextField sPriceTF = new JTextField(String.valueOf(testStockPrice.getSellingPrice()),10);

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesJava Help > cannot resolve symbol JTextField


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


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





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