Can anyone tell me why I'm getting these 2 errors in line 73:
"Frame2.java": Error #: 300 : class decimalFormat not found in class untitled2.Frame2 at line 73, column 3 "Frame2.java": Error #: 300 : class decimalFormat not found in class untitled2.Frame2 at line 73, column 30
public class Frame1 extends JFrame { JPanel contentPane; XYLayout xYLayout1 = new XYLayout(); JButton jButton1 = new JButton(); JButton jButton2 = new JButton();
/**Construct the frame*/ public Frame1() { enableEvents(AWTEvent.WINDOW_EVENT_MASK); try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { //setIconImage(Toolkit.getDefaultToolkit().createImage(Frame1.class.getResource("[Your Icon]"))); contentPane = (JPanel) this.getContentPane(); jButton1.setText("jButton1"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); contentPane.setLayout(xYLayout1); this.setSize(new Dimension(400, 400)); this.setTitle("Frame Title"); jButton2.setText("jButton2"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton2_actionPerformed(e); } }); contentPane.add(jButton1, new XYConstraints(93, 87, 205, 115)); contentPane.add(jButton2, new XYConstraints(100, 225, 206, 45)); } /**Overridden so we can exit when window is closed*/ protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } }
I see that the total number of lines in the source code is less than 73. Can you exactly tell which line it is? Also, please make sure there is nothing after the end of braces }.
Thanks,<br />Priya
Priyaa Vijay
Greenhorn
Joined: Mar 10, 2005
Posts: 9
posted
0
I meant the closing braces of the class
class .... { ..... ..... }
//NOTHING IS IN HERE
miguel lisboa
Ranch Hand
Joined: Feb 08, 2004
Posts: 1281
posted
0
but this is Frame1 probably you posted the wrong class
java amateur
Ernest Friedman-Hill
author and iconoclast
Marshal
It doesn't matter how many lines there are or what the code is -- look at the error message. It says there's no class "decimalFormat". That's probably true. Every single class in the Java APIs uses the standard naming convention that class names start with a capital letter. You're probably trying to use java.text.DecimalFormat. Make sure you've imported it, and capitalize the name.
SORRY! Stupid me posted the wrong Frame! Heres the Errors:
"Frame2.java": Error #: 300 : class decimalFormat not found in class untitled2.Frame2 at line 73, column 3 "Frame2.java": Error #: 300 : class decimalFormat not found in class untitled2.Frame2 at line 73, column 30
Heres the code:
[ March 18, 2005: Message edited by: Joel McNary ]
miguel lisboa
Ranch Hand
Joined: Feb 08, 2004
Posts: 1281
posted
0
you should pay more atention to Ernest Friedman-Hill's post
The number one rule of programming: always know what you're doing. Copying stuff that you don't understand, that seems to work, has been called "Cargo Cult Programming." It's always a bad idea, because if you don't understand something, then you never really know if it works correctly or not.
So what you need to do is find out what these statements mean. Presumably you've got an introductory Java book, yes? Look up "import" in the index.
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
posted
0
I'm surprised that EFH hasn't suggested that you use UBB tags when you post your code. It will preserve your indentation so that we can more easily read your code. So for future reference, please use them
Its OK I've managed to get it working now thanks, all I've done is import.java.text.DecimalFormatat the top of the page. Thanks for help all!
Joel McNary
Bartender
Joined: Aug 20, 2001
Posts: 1815
posted
0
Originally posted by Layne Lund: I'm surprised that EFH hasn't suggested that you use UBB tags when you post your code. It will preserve your indentation so that we can more easily read your code. So for future reference, please use them
Layne
[ March 17, 2005: Message edited by: Layne Lund ]
Ernest may not have mentioned it, but I did somethign about it. Surrounding your code with [CODE] and [/CODE] tags prints in in a monopsaced font with preserved indentation. And if you say [CODE] and [/CODE] in your post, you can say [CODE] and [/CODE] without its being interpreted as tags...
Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.