Results 1 to 2 of 2
Thread: GUI problem
- 11-16-2008, 06:39 AM #1
Member
- Join Date
- Oct 2008
- Posts
- 19
- Rep Power
- 0
GUI problem
Hi,
I need your help in checking what is the error in this program?? When I try to run it error messages appear ??
Run Test:Java Code:import javax.swing.*; import java.awt.event.*; /** The RetailPriceWindow class displays a JFrame that lets a user enter a wholecost of an item and markup percentage of the item.When the calculate button is clicked, a dialog box is displayed with the item`s retail price. */ public class RetailPriceWindow extends JFrame { private JPanel panel; private JLabel costLabel; private JLabel markupLabel; private JTextField costeTextField; private JTextField markuptextField; private JButton calcButton; private final int WINDOW_WIDTH = 350; private final int WINDOW_HEIGHT = 200; /** constructor */ public RetailPriceWindow() { setTitle("Item Retail Price"); setSize(WINDOW_WIDTH, WINDOW_HEIGHT); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); buildPanel(); add(panel); setVisible(true); } public static void main (String[] args) { new RetailPriceWindow(); private void buildPanel() { panel = new JPanel(); panel.add(costLabel); panel.add(markupLabel); panel.add(costTextField); panel.add(markupTextField); costLabel = new JLabel("Enter the item wholecost"); markupLabel = new JLabel("Enter the item markup percentage"); costTextField = new JTextField(10); markupTextField = new JTextField(10); calcButton = new JButton("Calculate"); calcButton.addActionListener(new ButtonListener()); panel.add(calcButton); private class ButtonListener implements ActionListener { /** The actionperformed methods executes when the user clicks on the Calculate button. @param e The event object. */ public void actionPerformed(ActionEvent e) { String input1; String input2; double retailprice; input = costTextField.getText(); input = markupTextField.getText(); retailprice = Double.parseDouble(input1)*(input2)/50; JOptionPane.showMessageDialog(null, "The retail price for" + "the item`s wholecost" + input1 + " and the item`s markup percentage" + input2 + " is" + retailprice); } } } } }
RetailPriceWindow.java:34: illegal start of expression
private void buildPanel() {
^
RetailPriceWindow.java:34: illegal start of expression
private void buildPanel() {
^
RetailPriceWindow.java:34: ';' expected
private void buildPanel() {
^
RetailPriceWindow.java:49: illegal start of expression
private class ButtonListener implements ActionListener
^
4 errors
- 11-16-2008, 08:57 AM #2


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks