• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Printing date

 
Ranch Hand
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 101
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The Paranthesis is proper in the program -- i checked it -- probably got erased when i tried to comment it
any more help?
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 208
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
It worked! thanks. How should i improve my coding style?
Would you clarify?
Thanks,
Shree
 
Govinda
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
    Bookmark Topic Watch Topic
  • New Topic