aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Printing date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Printing date" Watch "Printing date" New topic
Author

Printing date

shree vijay
Ranch Hand

Joined: Sep 18, 2000
Posts: 208
Hi,
Consider the following program:
/* Creating a purchase order screen */
import java.awt.*;
import javax.swing.*;
import java.text.*;
import java.util.*;
class POFrame extends JFrame
{


// constructor
public POFrame()
{
super("Purchase Order");

Panel leftPanel;
Panel rightPanel;
Panel topPanel;
Panel paymentPanel;
Panel submitCancelPanel;

setBounds(50,50,600,500);
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().setLayout(new GridLayout(3,0));


leftPanel=new Panel();
rightPanel=new Panel();
topPanel=new Panel();
paymentPanel=new Panel();
submitCancelPanel=new Panel();

// Filling the TopPanel

leftPanel.setLayout(new GridLayout(4,1));
leftPanel.add(new Label("Date"));
Date today = new Date();
DateFormat df = getDateInstanceDateFormat.LONG,Locale.US);//1
String prntDate = df.format(today);
TextField dateText = new TextField();
dateText.setText(prntDate);
leftPanel.add(dateText);
leftPanel.add(new Label("ITEM CATEGORY"));
Choice item_category = new Choice();
item_category.addItem("Hardware");
item_category.addItem("Software");
leftPanel.add(item_category);

rightPanel.setLayout(new GridLayout(4,1));
rightPanel.add(new Label("ITEM DESCRIPTION"));
rightPanel.add(new TextArea());
rightPanel.add(new Label("ITEM COMPONENT"));
java.awt.List compList = new java.awt.List(3,false);
compList.add("Network");
compList.add("CDROM");
compList.add("Desktop");
rightPanel.add(compList);

topPanel.setLayout(new GridLayout(1,2));
topPanel.add(leftPanel);
topPanel.add(rightPanel);

paymentPanel.setLayout(new GridLayout(4,1));
paymentPanel.add(new Label("PAYMENT METHOD"));

CheckboxGroup cbg=new CheckboxGroup();
Checkbox cbx1=new Checkbox("Visa",false,cbg);
Checkbox cbx2=new Checkbox("MasterCard",false,cbg);
Checkbox cbx3=new Checkbox("American Express",false,cbg);

paymentPanel.add(cbx1);
paymentPanel.add(cbx2);
paymentPanel.add(cbx3);



// Filling the submitCancelPanel

// add Buttons

Button CancelButton = new Button("Cancel");
Button SubmitButton = new Button("Submit");

CancelButton.setBackground(Color.blue);
SubmitButton.setBackground(Color.red);

submitCancelPanel.add(CancelButton);
submitCancelPanel.add(SubmitButton);


getContentPane().add(topPanel);
getContentPane().add(paymentPanel);
getContentPane().add(submitCancelPanel);
setVisible(true);


}
}

In the getDateInstance() call in line marked // 1
i am getting a cannot resolve symbol error. I checked the syntax and the import statements , but couldn't find the bug
... Any help?


Regards,<BR>Shree
Viji Bharat
Ranch Hand

Joined: Sep 18, 2000
Posts: 101
There seems to be a dangling paranthesis at the end of the statement marked 1!! May be that's causing the error.
shree vijay
Ranch Hand

Joined: Sep 18, 2000
Posts: 208
Hi,
The Paranthesis is proper in the program -- i checked it -- probably got erased when i tried to comment it
any more help?
Govinda
Greenhorn

Joined: Nov 20, 2000
Posts: 29
nothing is problum.
you have commited a very general mistake and that is
the getDateInstance Method is static and the call to that
method is not perfect.call it as
<pre>
DateFormat df = DateFormat.getDateInstance(DateFormat.LONG,Locale.US);//1
</pre>
and definately every thing will be fine.
one suuggestion (if you accept)
" change your coding style . this style almost suffering from
this kind of problums. "
Originally posted by shree vijay:
Hi,
Consider the following program:
/* Creating a purchase order screen */
import java.awt.*;
import javax.swing.*;
import java.text.*;
import java.util.*;
class POFrame extends JFrame
{


// constructor
public POFrame()
{
super("Purchase Order");

Panel leftPanel;
Panel rightPanel;
Panel topPanel;
Panel paymentPanel;
Panel submitCancelPanel;

setBounds(50,50,600,500);
setDefaultCloseOperation(EXIT_ON_CLOSE);
getContentPane().setLayout(new GridLayout(3,0));


leftPanel=new Panel();
rightPanel=new Panel();
topPanel=new Panel();
paymentPanel=new Panel();
submitCancelPanel=new Panel();

// Filling the TopPanel

leftPanel.setLayout(new GridLayout(4,1));
leftPanel.add(new Label("Date"));
Date today = new Date();
DateFormat df = getDateInstanceDateFormat.LONG,Locale.US);//1
String prntDate = df.format(today);
TextField dateText = new TextField();
dateText.setText(prntDate);
leftPanel.add(dateText);
leftPanel.add(new Label("ITEM CATEGORY"));
Choice item_category = new Choice();
item_category.addItem("Hardware");
item_category.addItem("Software");
leftPanel.add(item_category);

rightPanel.setLayout(new GridLayout(4,1));
rightPanel.add(new Label("ITEM DESCRIPTION"));
rightPanel.add(new TextArea());
rightPanel.add(new Label("ITEM COMPONENT"));
java.awt.List compList = new java.awt.List(3,false);
compList.add("Network");
compList.add("CDROM");
compList.add("Desktop");
rightPanel.add(compList);

topPanel.setLayout(new GridLayout(1,2));
topPanel.add(leftPanel);
topPanel.add(rightPanel);

paymentPanel.setLayout(new GridLayout(4,1));
paymentPanel.add(new Label("PAYMENT METHOD"));

CheckboxGroup cbg=new CheckboxGroup();
Checkbox cbx1=new Checkbox("Visa",false,cbg);
Checkbox cbx2=new Checkbox("MasterCard",false,cbg);
Checkbox cbx3=new Checkbox("American Express",false,cbg);

paymentPanel.add(cbx1);
paymentPanel.add(cbx2);
paymentPanel.add(cbx3);



// Filling the submitCancelPanel

// add Buttons

Button CancelButton = new Button("Cancel");
Button SubmitButton = new Button("Submit");

CancelButton.setBackground(Color.blue);
SubmitButton.setBackground(Color.red);

submitCancelPanel.add(CancelButton);
submitCancelPanel.add(SubmitButton);


getContentPane().add(topPanel);
getContentPane().add(paymentPanel);
getContentPane().add(submitCancelPanel);
setVisible(true);


}
}

In the getDateInstance() call in line marked // 1
i am getting a cannot resolve symbol error. I checked the syntax and the import statements , but couldn't find the bug
... Any help?

shree vijay
Ranch Hand

Joined: Sep 18, 2000
Posts: 208
Hi,
It worked! thanks. How should i improve my coding style?
Would you clarify?
Thanks,
Shree
Govinda
Greenhorn

Joined: Nov 20, 2000
Posts: 29
enable your mail-id , i will tell you .
Originally posted by shree vijay:
Hi,
It worked! thanks. How should i improve my coding style?
Would you clarify?
Thanks,
Shree

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Printing date