• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Errors in Frame

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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);
}
}
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 }.
 
Priyaa Vijay
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I meant the closing braces of the class

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

//NOTHING IS IN HERE
 
Ranch Hand
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
but this is Frame1
probably you posted the wrong class
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Mike Meakin
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 1282
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you should pay more atention to Ernest Friedman-Hill's post
 
Mike Meakin
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, so how do import java.text.DecimalFormat into the frame ?
 
Ernest Friedman-Hill
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Mike Meakin
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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...
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic