Results 1 to 4 of 4
Thread: JAVA need fix the code
- 03-25-2012, 02:50 AM #1
Member
- Join Date
- Mar 2012
- Posts
- 4
- Rep Power
- 0
JAVA need fix the code
hi guys. I am new to java and I have problems with my java codes. Can anyone help me fix it. Thank You.
the ouput should be like this:
Fee Calculator
ID Code: [Text Box]
Weight: [Text Box]
Rate: [$1.02]
Price Charge: [$ ]
my code:
import java.awt.Color;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*; //Needed for swing components
public class PayrollApplication extends JFrame
implements ActionListener
{
//declare your instance objects here
JPanel mainPanel = new JPanel();
JLabel label1 = new JLabel("Fee Calculator");
JLabel IDcode = new JLabel("ID Code: ");
JLabel Weight = new JLabel ("Weight: ");
JLabel Rate = new JLabel ("Rate: ");
JLabel priceCharge = new JLabel ("Price Charge: ");
JTextField label1Field = new JTextField(20);
JTextField IDCodeField = new JTextField(20);
JTextField WeighttField = new JTextField(20);
JTextField RatetField = new JTextField(20);
JTextField PricetField = new JTextField(20);
JButton calculateButton = new JButton("Calculate Shipping Fee");
JTextArea outputTextArea = new JTextArea(5, 20);
JScrollPane outputScrollPane = new JScrollPane(outputTextArea); //For scroll bars around text area
Font bigFont = new Font("Times New Roman", Font.BOLD, 28);
// This is the first method called in a application
//We will create an object of ourselves to call the
//constructor and then set the default close operation for the frame
public static void main(String[] args)
{
PayrollApplication basicGUI = new PayrollApplication();
basicGUI.setDefaultCloseOperation(JFrame.EXIT_ON_C LOSE);
}//end of main
//This is the constructor for this class. It will be called from main
//It will set up our GUI panel with needed components
//and set up appropriate event listening
public PayrollApplication()
{
//call the superclass' constructor and send a title
super("Fee Calculator");
//add GUI components to the appropriate container
mainPanel.add(label1);
label1.setFont(bigFont);
label1.setForeground(Color.RED);
mainPanel.add(IDcode);
mainPanel.add(Weight);
mainPanel.add(Rate);
mainPanel.add(priceCharge);
mainPanel.add(calculateButton);
mainPanel.add(outputScrollPane);
JTextField IDCodeField = new JTextField(20);
JTextField WeighttField = new JTextField(20);
JTextField RatetField = new JTextField(20);
JTextField priceChargetField = new JTextField(20);
//add the JPanel to the JFrame
add(mainPanel);
//call the listener method
addListeners();
//set the properties of the JFrame for display
this.setSize(300, 500);
this.setVisible(true);
}//end of constructor
//use to register the components to the action listener
public void addListeners()
{
calculateButton.addActionListener(this);
}
//Retrieve and convert text fields and calculate and display the gross pay
public void addPerformed(ActionEvent evt)
{
double Weight = 0,Rate,priceCharge;
Rate = 0.12;
priceCharge = (Weight * Rate);
String sign = "$";
String.format("%s%2d", sign, priceCharge);
}
}//end of class
-
Re: JAVA need fix the code
OK, what we have here is your code and your requirements and not much else but "help me fix it".
Please understand that we're all volunteers who offer help on our own free time, and so we greatly appreciate all efforts you can put in towards making it easiser for us to help you. Would it be asking too much for you to put more effort into asking your question? For instance by telling us what behaviors you're seeing now, what attempts you've made to solve your problem, how they didn't work, any and all error messages. Also, please edit your post and add [code] [/code] tags around your posted code so that it retains its formatting and is readable.
Your efforts in fixing this are greatly appreciated.
- 03-25-2012, 02:59 AM #3
Senior Member
- Join Date
- Oct 2011
- Posts
- 106
- Rep Power
- 0
Re: JAVA need fix the code
this a duplicate post.......here is a link to the original JAVA HELP URGENT ! problem with text box dollar sign You should direct these questions in your original thread
-
Re: JAVA need fix the code
Similar Threads
-
I want the source code of DUK's Bank , the example code in Java EE 5 Tutorial 2010
By zahra in forum New To JavaReplies: 16Last Post: 01-31-2012, 08:36 PM -
Translate Vb.net code into Java code
By Radu in forum New To JavaReplies: 5Last Post: 04-12-2011, 09:27 AM -
C server code - Java CLient Code _ TCP Connection Problem
By rmd22 in forum NetworkingReplies: 0Last Post: 02-21-2011, 11:50 AM -
Convert java code to midlet code
By coldvoice05 in forum New To JavaReplies: 1Last Post: 08-12-2009, 11:14 AM -
Convert java code to midlet code
By coldvoice05 in forum Advanced JavaReplies: 1Last Post: 08-09-2009, 01:21 PM


LinkBack URL
About LinkBacks


Bookmarks