It's not a secret anymore!*
The moose likes Beginning Java and the fly likes Errors in Frame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Errors in Frame" Watch "Errors in Frame" New topic
Author

Errors in Frame

Mike Meakin
Ranch Hand

Joined: Dec 30, 2004
Posts: 88
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


Heres the code:

package untitled2;

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import com.borland.jbcl.layout.*;

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);
}
}

void jButton1_actionPerformed(ActionEvent e) {
Frame2 frame = new Frame2();
frame.setSize(new Dimension(200, 200));
frame.validate();
frame.setVisible(true);
}

void jButton2_actionPerformed(ActionEvent e) {
Frame3 frame = new Frame3();
frame.setSize(new Dimension(200, 200));
frame.validate();
frame.setVisible(true);
}
}
Priyaa Vijay
Greenhorn

Joined: Mar 10, 2005
Posts: 9
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
I meant the closing braces of the class

class .... {
.....
.....
}

//NOTHING IS IN HERE
miguel lisboa
Ranch Hand

Joined: Feb 08, 2004
Posts: 1281
but this is Frame1
probably you posted the wrong class


java amateur
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

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.


[Jess in Action][AskingGoodQuestions]
Mike Meakin
Ranch Hand

Joined: Dec 30, 2004
Posts: 88
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
you should pay more atention to Ernest Friedman-Hill's post
Mike Meakin
Ranch Hand

Joined: Dec 30, 2004
Posts: 88
Thanks, so how do import java.text.DecimalFormat into the frame ?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Your code starts out:



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
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 ]

Java API Documentation
The Java Tutorial
Mike Meakin
Ranch Hand

Joined: Dec 30, 2004
Posts: 88
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: 1821

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 &#91;CODE] and &#91;/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://aspose.com/file-tools
 
subject: Errors in Frame